mirror of
https://github.com/OpenTTD/OpenTTD
synced 2025-12-10 06:52:05 +01:00
Change: [Script] Decouple RAILTYPE_INVALID from internal presentation. (#14630)
RAILTYPE_INVALID is now -1, which matches ROADTYPE_INVALID.
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -242,7 +242,10 @@
|
|||||||
if (!IsValidEngine(engine_id)) return ScriptRail::RAILTYPE_INVALID;
|
if (!IsValidEngine(engine_id)) return ScriptRail::RAILTYPE_INVALID;
|
||||||
if (GetVehicleType(engine_id) != ScriptVehicle::VT_RAIL) return ScriptRail::RAILTYPE_INVALID;
|
if (GetVehicleType(engine_id) != ScriptVehicle::VT_RAIL) return ScriptRail::RAILTYPE_INVALID;
|
||||||
|
|
||||||
return static_cast<ScriptRail::RailType>(::RailVehInfo(engine_id)->railtypes.GetNthSetBit(0).value_or(::RailType::INVALID_RAILTYPE));
|
auto railtype = ::RailVehInfo(engine_id)->railtypes.GetNthSetBit(0);
|
||||||
|
if (!railtype.has_value()) return ScriptRail::RAILTYPE_INVALID;
|
||||||
|
|
||||||
|
return static_cast<ScriptRail::RailType>(railtype.value());
|
||||||
}
|
}
|
||||||
|
|
||||||
/* static */ ScriptList *ScriptEngine::GetAllRailTypes(EngineID engine_id)
|
/* static */ ScriptList *ScriptEngine::GetAllRailTypes(EngineID engine_id)
|
||||||
|
|||||||
@@ -44,9 +44,8 @@ public:
|
|||||||
/**
|
/**
|
||||||
* Types of rail known to the game.
|
* Types of rail known to the game.
|
||||||
*/
|
*/
|
||||||
enum RailType : uint8_t {
|
enum RailType {
|
||||||
/* Note: these values represent part of the in-game static values */
|
RAILTYPE_INVALID = -1, ///< Invalid RailType.
|
||||||
RAILTYPE_INVALID = ::INVALID_RAILTYPE, ///< Invalid RailType.
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user