2009-08-21 22:21:05 +02:00
|
|
|
/*
|
|
|
|
* This file is part of OpenTTD.
|
|
|
|
* OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
|
|
|
|
* OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
* See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2011-11-30 00:15:35 +01:00
|
|
|
/** @file script_engine.cpp Implementation of ScriptEngine. */
|
2009-01-12 18:11:45 +01:00
|
|
|
|
2011-01-22 11:33:16 +01:00
|
|
|
#include "../../stdafx.h"
|
2011-11-30 00:07:38 +01:00
|
|
|
#include "script_engine.hpp"
|
|
|
|
#include "script_cargo.hpp"
|
2010-01-02 16:52:29 +01:00
|
|
|
#include "../../company_base.h"
|
2009-01-12 18:11:45 +01:00
|
|
|
#include "../../strings_func.h"
|
2009-03-18 20:32:13 +01:00
|
|
|
#include "../../rail.h"
|
2019-04-06 21:50:00 +02:00
|
|
|
#include "../../road.h"
|
2009-03-18 20:32:13 +01:00
|
|
|
#include "../../engine_base.h"
|
2010-05-22 14:25:47 +02:00
|
|
|
#include "../../engine_func.h"
|
2009-01-12 18:11:45 +01:00
|
|
|
#include "../../articulated_vehicles.h"
|
2021-11-01 21:30:34 +01:00
|
|
|
#include "../../engine_cmd.h"
|
2023-12-19 15:09:46 +01:00
|
|
|
#include "../../timer/timer_game_calendar.h"
|
2009-01-12 18:11:45 +01:00
|
|
|
#include "table/strings.h"
|
|
|
|
|
2014-04-23 22:13:33 +02:00
|
|
|
#include "../../safeguards.h"
|
|
|
|
|
2011-11-30 00:15:35 +01:00
|
|
|
/* static */ bool ScriptEngine::IsValidEngine(EngineID engine_id)
|
2010-01-02 16:52:29 +01:00
|
|
|
{
|
2023-03-02 21:22:37 +01:00
|
|
|
EnforceDeityOrCompanyModeValid(false);
|
2010-01-02 16:52:29 +01:00
|
|
|
const Engine *e = ::Engine::GetIfValid(engine_id);
|
2019-04-10 23:07:06 +02:00
|
|
|
if (e == nullptr || !e->IsEnabled()) return false;
|
2012-08-21 21:53:08 +02:00
|
|
|
|
|
|
|
/* AIs have only access to engines they can purchase or still have in use.
|
|
|
|
* Deity has access to all engined that will be or were available ever. */
|
|
|
|
CompanyID company = ScriptObject::GetCompany();
|
2024-01-21 15:09:44 +01:00
|
|
|
return ScriptCompanyMode::IsDeity() || ::IsEngineBuildable(engine_id, e->type, company) || ::Company::Get(company)->group_all[e->type].GetNumEngines(engine_id) > 0;
|
2010-01-02 16:52:29 +01:00
|
|
|
}
|
|
|
|
|
2011-11-30 00:15:35 +01:00
|
|
|
/* static */ bool ScriptEngine::IsBuildable(EngineID engine_id)
|
2009-01-12 18:11:45 +01:00
|
|
|
{
|
2023-03-02 21:22:37 +01:00
|
|
|
EnforceDeityOrCompanyModeValid(false);
|
2009-05-18 21:32:16 +02:00
|
|
|
const Engine *e = ::Engine::GetIfValid(engine_id);
|
2019-04-10 23:07:06 +02:00
|
|
|
return e != nullptr && ::IsEngineBuildable(engine_id, e->type, ScriptObject::GetCompany());
|
2009-01-12 18:11:45 +01:00
|
|
|
}
|
|
|
|
|
2023-05-05 23:19:35 +02:00
|
|
|
/* static */ std::optional<std::string> ScriptEngine::GetName(EngineID engine_id)
|
2009-01-12 18:11:45 +01:00
|
|
|
{
|
2023-05-05 23:19:35 +02:00
|
|
|
if (!IsValidEngine(engine_id)) return std::nullopt;
|
2009-01-12 18:11:45 +01:00
|
|
|
|
|
|
|
::SetDParam(0, engine_id);
|
2012-01-08 22:48:05 +01:00
|
|
|
return GetString(STR_ENGINE_NAME);
|
2009-01-12 18:11:45 +01:00
|
|
|
}
|
|
|
|
|
2011-11-30 00:15:35 +01:00
|
|
|
/* static */ CargoID ScriptEngine::GetCargoType(EngineID engine_id)
|
2009-01-12 18:11:45 +01:00
|
|
|
{
|
2024-01-06 16:15:37 +01:00
|
|
|
if (!IsValidEngine(engine_id)) return INVALID_CARGO;
|
2009-01-12 18:11:45 +01:00
|
|
|
|
2009-10-28 21:15:46 +01:00
|
|
|
CargoArray cap = ::GetCapacityOfArticulatedParts(engine_id);
|
|
|
|
|
2023-11-26 22:38:49 +01:00
|
|
|
auto it = std::max_element(std::cbegin(cap), std::cend(cap));
|
2024-01-06 16:15:37 +01:00
|
|
|
if (*it == 0) return INVALID_CARGO;
|
2023-11-26 22:38:49 +01:00
|
|
|
|
|
|
|
return CargoID(std::distance(std::cbegin(cap), it));
|
2009-01-12 18:11:45 +01:00
|
|
|
}
|
|
|
|
|
2011-11-30 00:15:35 +01:00
|
|
|
/* static */ bool ScriptEngine::CanRefitCargo(EngineID engine_id, CargoID cargo_id)
|
2009-01-12 18:11:45 +01:00
|
|
|
{
|
|
|
|
if (!IsValidEngine(engine_id)) return false;
|
2011-11-30 00:15:35 +01:00
|
|
|
if (!ScriptCargo::IsValidCargo(cargo_id)) return false;
|
2009-01-12 18:11:45 +01:00
|
|
|
|
2009-10-28 21:15:46 +01:00
|
|
|
return HasBit(::GetUnionOfArticulatedRefitMasks(engine_id, true), cargo_id);
|
2009-01-12 18:11:45 +01:00
|
|
|
}
|
|
|
|
|
2011-11-30 00:15:35 +01:00
|
|
|
/* static */ bool ScriptEngine::CanPullCargo(EngineID engine_id, CargoID cargo_id)
|
2009-01-12 18:11:45 +01:00
|
|
|
{
|
|
|
|
if (!IsValidEngine(engine_id)) return false;
|
2011-11-30 00:15:35 +01:00
|
|
|
if (GetVehicleType(engine_id) != ScriptVehicle::VT_RAIL) return false;
|
|
|
|
if (!ScriptCargo::IsValidCargo(cargo_id)) return false;
|
2009-01-12 18:11:45 +01:00
|
|
|
|
2011-11-30 00:15:35 +01:00
|
|
|
return (::RailVehInfo(engine_id)->ai_passenger_only != 1) || ScriptCargo::HasCargoClass(cargo_id, ScriptCargo::CC_PASSENGERS);
|
2009-01-12 18:11:45 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-02-11 16:31:43 +01:00
|
|
|
/* static */ SQInteger ScriptEngine::GetCapacity(EngineID engine_id)
|
2009-01-12 18:11:45 +01:00
|
|
|
{
|
|
|
|
if (!IsValidEngine(engine_id)) return -1;
|
|
|
|
|
2009-05-17 01:34:14 +02:00
|
|
|
const Engine *e = ::Engine::Get(engine_id);
|
2009-03-14 00:49:12 +01:00
|
|
|
switch (e->type) {
|
2009-01-12 18:11:45 +01:00
|
|
|
case VEH_ROAD:
|
|
|
|
case VEH_TRAIN: {
|
2009-10-06 21:52:38 +02:00
|
|
|
CargoArray capacities = GetCapacityOfArticulatedParts(engine_id);
|
2023-11-26 22:30:31 +01:00
|
|
|
for (uint &cap : capacities) {
|
|
|
|
if (cap != 0) return cap;
|
2009-01-12 18:11:45 +01:00
|
|
|
}
|
|
|
|
return -1;
|
2010-08-01 20:53:30 +02:00
|
|
|
}
|
2009-01-12 18:11:45 +01:00
|
|
|
|
2009-03-14 00:49:12 +01:00
|
|
|
case VEH_SHIP:
|
|
|
|
case VEH_AIRCRAFT:
|
2009-03-18 20:32:13 +01:00
|
|
|
return e->GetDisplayDefaultCapacity();
|
2009-01-12 18:11:45 +01:00
|
|
|
|
|
|
|
default: NOT_REACHED();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-02-11 16:31:43 +01:00
|
|
|
/* static */ SQInteger ScriptEngine::GetReliability(EngineID engine_id)
|
2009-01-12 18:11:45 +01:00
|
|
|
{
|
|
|
|
if (!IsValidEngine(engine_id)) return -1;
|
2011-11-30 00:15:35 +01:00
|
|
|
if (GetVehicleType(engine_id) == ScriptVehicle::VT_RAIL && IsWagon(engine_id)) return -1;
|
2009-01-12 18:11:45 +01:00
|
|
|
|
2009-08-27 15:31:26 +02:00
|
|
|
return ::ToPercent16(::Engine::Get(engine_id)->reliability);
|
2009-01-12 18:11:45 +01:00
|
|
|
}
|
|
|
|
|
2023-02-11 16:31:43 +01:00
|
|
|
/* static */ SQInteger ScriptEngine::GetMaxSpeed(EngineID engine_id)
|
2009-01-12 18:11:45 +01:00
|
|
|
{
|
|
|
|
if (!IsValidEngine(engine_id)) return -1;
|
|
|
|
|
2009-05-17 01:34:14 +02:00
|
|
|
const Engine *e = ::Engine::Get(engine_id);
|
2023-02-11 16:31:43 +01:00
|
|
|
uint max_speed = e->GetDisplayMaxSpeed(); // km-ish/h
|
2009-02-01 17:10:06 +01:00
|
|
|
if (e->type == VEH_AIRCRAFT) max_speed /= _settings_game.vehicle.plane_speed;
|
|
|
|
return max_speed;
|
2009-01-12 18:11:45 +01:00
|
|
|
}
|
|
|
|
|
2011-11-30 00:15:35 +01:00
|
|
|
/* static */ Money ScriptEngine::GetPrice(EngineID engine_id)
|
2009-01-12 18:11:45 +01:00
|
|
|
{
|
|
|
|
if (!IsValidEngine(engine_id)) return -1;
|
|
|
|
|
2009-05-17 01:34:14 +02:00
|
|
|
return ::Engine::Get(engine_id)->GetCost();
|
2009-01-12 18:11:45 +01:00
|
|
|
}
|
|
|
|
|
2023-02-11 16:31:43 +01:00
|
|
|
/* static */ SQInteger ScriptEngine::GetMaxAge(EngineID engine_id)
|
2009-01-12 18:11:45 +01:00
|
|
|
{
|
|
|
|
if (!IsValidEngine(engine_id)) return -1;
|
2011-11-30 00:15:35 +01:00
|
|
|
if (GetVehicleType(engine_id) == ScriptVehicle::VT_RAIL && IsWagon(engine_id)) return -1;
|
2009-01-12 18:11:45 +01:00
|
|
|
|
2023-11-06 21:29:35 +01:00
|
|
|
return ::Engine::Get(engine_id)->GetLifeLengthInDays().base();
|
2009-01-12 18:11:45 +01:00
|
|
|
}
|
|
|
|
|
2011-11-30 00:15:35 +01:00
|
|
|
/* static */ Money ScriptEngine::GetRunningCost(EngineID engine_id)
|
2009-01-12 18:11:45 +01:00
|
|
|
{
|
|
|
|
if (!IsValidEngine(engine_id)) return -1;
|
|
|
|
|
2009-05-17 01:34:14 +02:00
|
|
|
return ::Engine::Get(engine_id)->GetRunningCost();
|
2009-01-12 18:11:45 +01:00
|
|
|
}
|
|
|
|
|
2023-02-11 16:31:43 +01:00
|
|
|
/* static */ SQInteger ScriptEngine::GetPower(EngineID engine_id)
|
2009-02-19 20:44:19 +01:00
|
|
|
{
|
|
|
|
if (!IsValidEngine(engine_id)) return -1;
|
2011-11-30 00:15:35 +01:00
|
|
|
if (GetVehicleType(engine_id) != ScriptVehicle::VT_RAIL && GetVehicleType(engine_id) != ScriptVehicle::VT_ROAD) return -1;
|
2009-02-19 20:44:19 +01:00
|
|
|
if (IsWagon(engine_id)) return -1;
|
|
|
|
|
2009-05-17 01:34:14 +02:00
|
|
|
return ::Engine::Get(engine_id)->GetPower();
|
2009-02-19 20:44:19 +01:00
|
|
|
}
|
|
|
|
|
2023-02-11 16:31:43 +01:00
|
|
|
/* static */ SQInteger ScriptEngine::GetWeight(EngineID engine_id)
|
2009-02-19 20:44:19 +01:00
|
|
|
{
|
|
|
|
if (!IsValidEngine(engine_id)) return -1;
|
2011-11-30 00:15:35 +01:00
|
|
|
if (GetVehicleType(engine_id) != ScriptVehicle::VT_RAIL && GetVehicleType(engine_id) != ScriptVehicle::VT_ROAD) return -1;
|
2009-02-19 20:44:19 +01:00
|
|
|
|
2009-05-17 01:34:14 +02:00
|
|
|
return ::Engine::Get(engine_id)->GetDisplayWeight();
|
2009-02-19 20:44:19 +01:00
|
|
|
}
|
|
|
|
|
2023-02-11 16:31:43 +01:00
|
|
|
/* static */ SQInteger ScriptEngine::GetMaxTractiveEffort(EngineID engine_id)
|
2009-02-19 20:44:19 +01:00
|
|
|
{
|
|
|
|
if (!IsValidEngine(engine_id)) return -1;
|
2011-11-30 00:15:35 +01:00
|
|
|
if (GetVehicleType(engine_id) != ScriptVehicle::VT_RAIL && GetVehicleType(engine_id) != ScriptVehicle::VT_ROAD) return -1;
|
2009-02-19 20:44:19 +01:00
|
|
|
if (IsWagon(engine_id)) return -1;
|
|
|
|
|
2023-05-09 00:10:14 +02:00
|
|
|
return ::Engine::Get(engine_id)->GetDisplayMaxTractiveEffort() / 1000;
|
2009-02-19 20:44:19 +01:00
|
|
|
}
|
|
|
|
|
2014-02-06 20:50:34 +01:00
|
|
|
/* static */ ScriptDate::Date ScriptEngine::GetDesignDate(EngineID engine_id)
|
2009-08-01 01:22:49 +02:00
|
|
|
{
|
2014-02-06 20:50:34 +01:00
|
|
|
if (!IsValidEngine(engine_id)) return ScriptDate::DATE_INVALID;
|
2009-08-01 01:22:49 +02:00
|
|
|
|
2023-11-06 21:29:35 +01:00
|
|
|
return (ScriptDate::Date)::Engine::Get(engine_id)->intro_date.base();
|
2009-08-01 01:22:49 +02:00
|
|
|
}
|
|
|
|
|
2011-11-30 00:15:35 +01:00
|
|
|
/* static */ ScriptVehicle::VehicleType ScriptEngine::GetVehicleType(EngineID engine_id)
|
2009-01-12 18:11:45 +01:00
|
|
|
{
|
2011-11-30 00:15:35 +01:00
|
|
|
if (!IsValidEngine(engine_id)) return ScriptVehicle::VT_INVALID;
|
2009-01-12 18:11:45 +01:00
|
|
|
|
2009-05-17 01:34:14 +02:00
|
|
|
switch (::Engine::Get(engine_id)->type) {
|
2011-11-30 00:15:35 +01:00
|
|
|
case VEH_ROAD: return ScriptVehicle::VT_ROAD;
|
|
|
|
case VEH_TRAIN: return ScriptVehicle::VT_RAIL;
|
|
|
|
case VEH_SHIP: return ScriptVehicle::VT_WATER;
|
|
|
|
case VEH_AIRCRAFT: return ScriptVehicle::VT_AIR;
|
2009-01-12 18:11:45 +01:00
|
|
|
default: NOT_REACHED();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-11-30 00:15:35 +01:00
|
|
|
/* static */ bool ScriptEngine::IsWagon(EngineID engine_id)
|
2009-01-12 18:11:45 +01:00
|
|
|
{
|
|
|
|
if (!IsValidEngine(engine_id)) return false;
|
2011-11-30 00:15:35 +01:00
|
|
|
if (GetVehicleType(engine_id) != ScriptVehicle::VT_RAIL) return false;
|
2009-01-12 18:11:45 +01:00
|
|
|
|
|
|
|
return ::RailVehInfo(engine_id)->power == 0;
|
|
|
|
}
|
|
|
|
|
2011-11-30 00:15:35 +01:00
|
|
|
/* static */ bool ScriptEngine::CanRunOnRail(EngineID engine_id, ScriptRail::RailType track_rail_type)
|
2009-01-12 18:11:45 +01:00
|
|
|
{
|
|
|
|
if (!IsValidEngine(engine_id)) return false;
|
2011-11-30 00:15:35 +01:00
|
|
|
if (GetVehicleType(engine_id) != ScriptVehicle::VT_RAIL) return false;
|
|
|
|
if (!ScriptRail::IsRailTypeAvailable(track_rail_type)) return false;
|
2009-01-12 18:11:45 +01:00
|
|
|
|
|
|
|
return ::IsCompatibleRail((::RailType)::RailVehInfo(engine_id)->railtype, (::RailType)track_rail_type);
|
|
|
|
}
|
|
|
|
|
2011-11-30 00:15:35 +01:00
|
|
|
/* static */ bool ScriptEngine::HasPowerOnRail(EngineID engine_id, ScriptRail::RailType track_rail_type)
|
2009-01-12 18:11:45 +01:00
|
|
|
{
|
|
|
|
if (!IsValidEngine(engine_id)) return false;
|
2011-11-30 00:15:35 +01:00
|
|
|
if (GetVehicleType(engine_id) != ScriptVehicle::VT_RAIL) return false;
|
|
|
|
if (!ScriptRail::IsRailTypeAvailable(track_rail_type)) return false;
|
2009-01-12 18:11:45 +01:00
|
|
|
|
|
|
|
return ::HasPowerOnRail((::RailType)::RailVehInfo(engine_id)->railtype, (::RailType)track_rail_type);
|
|
|
|
}
|
|
|
|
|
2019-04-06 21:50:00 +02:00
|
|
|
/* static */ bool ScriptEngine::CanRunOnRoad(EngineID engine_id, ScriptRoad::RoadType road_type)
|
|
|
|
{
|
|
|
|
return HasPowerOnRoad(engine_id, road_type);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* static */ bool ScriptEngine::HasPowerOnRoad(EngineID engine_id, ScriptRoad::RoadType road_type)
|
|
|
|
{
|
|
|
|
if (!IsValidEngine(engine_id)) return false;
|
|
|
|
if (GetVehicleType(engine_id) != ScriptVehicle::VT_ROAD) return false;
|
|
|
|
if (!ScriptRoad::IsRoadTypeAvailable(road_type)) return false;
|
|
|
|
|
|
|
|
return ::HasPowerOnRoad((::RoadType)::RoadVehInfo(engine_id)->roadtype, (::RoadType)road_type);
|
|
|
|
}
|
|
|
|
|
2011-11-30 00:15:35 +01:00
|
|
|
/* static */ ScriptRoad::RoadType ScriptEngine::GetRoadType(EngineID engine_id)
|
2009-01-12 18:11:45 +01:00
|
|
|
{
|
2011-11-30 00:15:35 +01:00
|
|
|
if (!IsValidEngine(engine_id)) return ScriptRoad::ROADTYPE_INVALID;
|
|
|
|
if (GetVehicleType(engine_id) != ScriptVehicle::VT_ROAD) return ScriptRoad::ROADTYPE_INVALID;
|
2009-01-12 18:11:45 +01:00
|
|
|
|
2019-04-06 08:46:15 +02:00
|
|
|
return (ScriptRoad::RoadType)(uint)::RoadVehInfo(engine_id)->roadtype;
|
2009-01-12 18:11:45 +01:00
|
|
|
}
|
|
|
|
|
2011-11-30 00:15:35 +01:00
|
|
|
/* static */ ScriptRail::RailType ScriptEngine::GetRailType(EngineID engine_id)
|
2009-01-12 18:11:45 +01:00
|
|
|
{
|
2011-11-30 00:15:35 +01:00
|
|
|
if (!IsValidEngine(engine_id)) return ScriptRail::RAILTYPE_INVALID;
|
|
|
|
if (GetVehicleType(engine_id) != ScriptVehicle::VT_RAIL) return ScriptRail::RAILTYPE_INVALID;
|
2009-01-12 18:11:45 +01:00
|
|
|
|
2011-11-30 00:15:35 +01:00
|
|
|
return (ScriptRail::RailType)(uint)::RailVehInfo(engine_id)->railtype;
|
2009-01-12 18:11:45 +01:00
|
|
|
}
|
|
|
|
|
2011-11-30 00:15:35 +01:00
|
|
|
/* static */ bool ScriptEngine::IsArticulated(EngineID engine_id)
|
2009-01-12 18:11:45 +01:00
|
|
|
{
|
|
|
|
if (!IsValidEngine(engine_id)) return false;
|
2011-11-30 00:15:35 +01:00
|
|
|
if (GetVehicleType(engine_id) != ScriptVehicle::VT_ROAD && GetVehicleType(engine_id) != ScriptVehicle::VT_RAIL) return false;
|
2009-01-12 18:11:45 +01:00
|
|
|
|
2012-03-14 21:49:54 +01:00
|
|
|
return IsArticulatedEngine(engine_id);
|
2009-01-12 18:11:45 +01:00
|
|
|
}
|
|
|
|
|
2011-11-30 00:15:35 +01:00
|
|
|
/* static */ ScriptAirport::PlaneType ScriptEngine::GetPlaneType(EngineID engine_id)
|
2009-01-12 18:11:45 +01:00
|
|
|
{
|
2011-11-30 00:15:35 +01:00
|
|
|
if (!IsValidEngine(engine_id)) return ScriptAirport::PT_INVALID;
|
|
|
|
if (GetVehicleType(engine_id) != ScriptVehicle::VT_AIR) return ScriptAirport::PT_INVALID;
|
2009-01-12 18:11:45 +01:00
|
|
|
|
2011-11-30 00:15:35 +01:00
|
|
|
return (ScriptAirport::PlaneType)::AircraftVehInfo(engine_id)->subtype;
|
2009-01-12 18:11:45 +01:00
|
|
|
}
|
2011-12-13 01:43:59 +01:00
|
|
|
|
2023-02-11 16:31:43 +01:00
|
|
|
/* static */ SQInteger ScriptEngine::GetMaximumOrderDistance(EngineID engine_id)
|
2011-12-13 01:43:59 +01:00
|
|
|
{
|
|
|
|
if (!IsValidEngine(engine_id)) return 0;
|
2023-02-11 16:31:43 +01:00
|
|
|
if (GetVehicleType(engine_id) != ScriptVehicle::VT_AIR) return 0;
|
2011-12-13 01:43:59 +01:00
|
|
|
|
2023-02-11 16:31:43 +01:00
|
|
|
return (SQInteger)::Engine::Get(engine_id)->GetRange() * ::Engine::Get(engine_id)->GetRange();
|
2011-12-13 01:43:59 +01:00
|
|
|
}
|
2020-01-15 18:46:26 +01:00
|
|
|
|
|
|
|
/* static */ bool ScriptEngine::EnableForCompany(EngineID engine_id, ScriptCompany::CompanyID company)
|
|
|
|
{
|
|
|
|
company = ScriptCompany::ResolveCompanyID(company);
|
|
|
|
|
2023-03-02 19:44:13 +01:00
|
|
|
EnforceDeityMode(false);
|
2020-01-15 18:46:26 +01:00
|
|
|
EnforcePrecondition(false, IsValidEngine(engine_id));
|
|
|
|
EnforcePrecondition(false, company != ScriptCompany::COMPANY_INVALID);
|
|
|
|
|
2021-11-05 23:55:23 +01:00
|
|
|
return ScriptObject::Command<CMD_ENGINE_CTRL>::Do(engine_id, (::CompanyID)company, true);
|
2020-01-15 18:46:26 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* static */ bool ScriptEngine::DisableForCompany(EngineID engine_id, ScriptCompany::CompanyID company)
|
|
|
|
{
|
|
|
|
company = ScriptCompany::ResolveCompanyID(company);
|
|
|
|
|
2023-03-02 19:44:13 +01:00
|
|
|
EnforceDeityMode(false);
|
2020-01-15 18:46:26 +01:00
|
|
|
EnforcePrecondition(false, IsValidEngine(engine_id));
|
|
|
|
EnforcePrecondition(false, company != ScriptCompany::COMPANY_INVALID);
|
|
|
|
|
2021-11-05 23:55:23 +01:00
|
|
|
return ScriptObject::Command<CMD_ENGINE_CTRL>::Do(engine_id, (::CompanyID)company, false);
|
2020-01-15 18:46:26 +01:00
|
|
|
}
|