mirror of https://github.com/OpenTTD/OpenTTD
Add: [Script] Function to get all rail types of an rail engine.
parent
164423a424
commit
d59095aa5e
|
@ -28,6 +28,7 @@
|
|||
* \li AICargo::CC_POTABLE
|
||||
* \li AICargo::CC_NON_POTABLE
|
||||
* \li AIVehicleList_Waypoint
|
||||
* \li AIRail::GetAllRailTypes
|
||||
*
|
||||
* Other changes:
|
||||
* \li AIBridge::GetBridgeID renamed to AIBridge::GetBridgeType
|
||||
|
@ -35,6 +36,7 @@
|
|||
* \li AIList instances can now be saved
|
||||
* \li AIVehicleList_Station accepts an optional AIVehicle::VehicleType parameter
|
||||
* \li AIList instances can now be cloned
|
||||
* \li AIRail::GetRailType will only return the first RailType of an engine, use AIRail::GetAllRailTypes instead
|
||||
*
|
||||
* \b 14.0
|
||||
*
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
* \li GSCargo::CC_NON_POTABLE
|
||||
* \li GSVehicleList_Waypoint
|
||||
* \li GSBaseStation::GetOwner
|
||||
* \li GSRail::GetAllRailTypes
|
||||
*
|
||||
* Other changes:
|
||||
* \li GSBridge::GetBridgeID renamed to GSBridge::GetBridgeType
|
||||
|
@ -36,6 +37,7 @@
|
|||
* \li GSList instances can now be saved
|
||||
* \li GSVehicleList_Station accepts an optional GSVehicle::VehicleType parameter
|
||||
* \li GSList instances can now be cloned
|
||||
* \li GSRail::GetRailType will only return the first RailType of an engine, use GSRail::GetAllRailTypes instead
|
||||
*
|
||||
* \b 14.0
|
||||
*
|
||||
|
|
|
@ -245,6 +245,14 @@
|
|||
return static_cast<ScriptRail::RailType>(::RailVehInfo(engine_id)->railtypes.GetNthSetBit(0).value_or(::RailType::INVALID_RAILTYPE));
|
||||
}
|
||||
|
||||
/* static */ ScriptRail::RailTypes ScriptEngine::GetAllRailTypes(EngineID engine_id)
|
||||
{
|
||||
if (!IsValidEngine(engine_id)) return ScriptRail::INVALID_RAILTYPES;
|
||||
if (GetVehicleType(engine_id) != ScriptVehicle::VT_RAIL) return ScriptRail::INVALID_RAILTYPES;
|
||||
|
||||
return static_cast<ScriptRail::RailTypes>(::RailVehInfo(engine_id)->railtypes.base());
|
||||
}
|
||||
|
||||
/* static */ bool ScriptEngine::IsArticulated(EngineID engine_id)
|
||||
{
|
||||
if (!IsValidEngine(engine_id)) return false;
|
||||
|
|
|
@ -249,6 +249,7 @@ public:
|
|||
|
||||
/**
|
||||
* Get the first RailType of the engine.
|
||||
* @note This will only return the first RailType of a multi-system engine. Use GetAllRailTypes to get all rail types of the engine.
|
||||
* @param engine_id The engine to get the RailType of.
|
||||
* @pre IsValidEngine(engine_id).
|
||||
* @pre GetVehicleType(engine_id) == ScriptVehicle::VT_RAIL.
|
||||
|
@ -256,6 +257,15 @@ public:
|
|||
*/
|
||||
static ScriptRail::RailType GetRailType(EngineID engine_id);
|
||||
|
||||
/**
|
||||
* Get all RailType's of the engine.
|
||||
* @param engine_id The engine to get all RailTypes of.
|
||||
* @pre IsValidEngine(engine_id).
|
||||
* @pre GetVehicleType(engine_id) == ScriptVehicle::VT_RAIL.
|
||||
* @return All rail types of the engine.
|
||||
*/
|
||||
static ScriptRail::RailTypes GetAllRailTypes(EngineID engine_id);
|
||||
|
||||
/**
|
||||
* Check if the engine is articulated.
|
||||
* @param engine_id The engine to check.
|
||||
|
|
|
@ -49,6 +49,14 @@ public:
|
|||
RAILTYPE_INVALID = ::INVALID_RAILTYPE, ///< Invalid RailType.
|
||||
};
|
||||
|
||||
/**
|
||||
* A bitmap with all possible rail types.
|
||||
*/
|
||||
enum RailTypes : int64_t {
|
||||
/* Note: these values represent part of the in-game RailTypes enum */
|
||||
INVALID_RAILTYPES = INT64_MAX, ///< Invalid RailTypes.
|
||||
};
|
||||
|
||||
/**
|
||||
* A bitmap with all possible rail tracks on a tile.
|
||||
*/
|
||||
|
|
|
@ -270,7 +270,7 @@ void Squirrel::AddMethod(std::string_view method_name, SQFUNCTION proc, std::str
|
|||
sq_newslot(this->vm, -3, SQFalse);
|
||||
}
|
||||
|
||||
void Squirrel::AddConst(std::string_view var_name, int value)
|
||||
void Squirrel::AddConst(std::string_view var_name, SQInteger value)
|
||||
{
|
||||
ScriptAllocatorScope alloc_scope(this);
|
||||
|
||||
|
|
|
@ -104,15 +104,21 @@ public:
|
|||
* Adds a const to the stack. Depending on the current state this means
|
||||
* either a const to a class or to the global space.
|
||||
*/
|
||||
void AddConst(std::string_view var_name, int value);
|
||||
void AddConst(std::string_view var_name, SQInteger value);
|
||||
|
||||
/**
|
||||
* Adds a const to the stack. Depending on the current state this means
|
||||
* either a const to a class or to the global space.
|
||||
*/
|
||||
void AddConst(std::string_view var_name, uint value) { this->AddConst(var_name, (int)value); }
|
||||
void AddConst(std::string_view var_name, uint value) { this->AddConst(var_name, (SQInteger)value); }
|
||||
|
||||
void AddConst(std::string_view var_name, const ConvertibleThroughBase auto &value) { this->AddConst(var_name, static_cast<int>(value.base())); }
|
||||
/**
|
||||
* Adds a const to the stack. Depending on the current state this means
|
||||
* either a const to a class or to the global space.
|
||||
*/
|
||||
void AddConst(std::string_view var_name, int value) { this->AddConst(var_name, (SQInteger)value); }
|
||||
|
||||
void AddConst(std::string_view var_name, const ConvertibleThroughBase auto &value) { this->AddConst(var_name, static_cast<SQInteger>(value.base())); }
|
||||
|
||||
/**
|
||||
* Adds a const to the stack. Depending on the current state this means
|
||||
|
|
Loading…
Reference in New Issue