1
0
mirror of https://github.com/OpenTTD/OpenTTD synced 2026-01-24 04:34:16 +01:00

Codechange: Add base() method to StrongType to allow access to the base type without casting. (#11445)

This removes the ability to explicitly cast to the base type, but the requirement
to use .base() means the conversion is still explicit.
This commit is contained in:
Peter Nelson
2023-11-06 20:29:35 +00:00
committed by GitHub
parent 737775f834
commit ab535c0a86
73 changed files with 174 additions and 173 deletions

View File

@@ -311,7 +311,7 @@
{
if (!IsValidVehicle(vehicle_id)) return -1;
return (int32_t)::Vehicle::Get(vehicle_id)->age;
return ::Vehicle::Get(vehicle_id)->age.base();
}
/* static */ SQInteger ScriptVehicle::GetWagonAge(VehicleID vehicle_id, SQInteger wagon)
@@ -323,21 +323,21 @@
if (v->type == VEH_TRAIN) {
while (wagon-- > 0) v = ::Train::From(v)->GetNextUnit();
}
return (int32_t)v->age;
return v->age.base();
}
/* static */ SQInteger ScriptVehicle::GetMaxAge(VehicleID vehicle_id)
{
if (!IsPrimaryVehicle(vehicle_id)) return -1;
return (int32_t)::Vehicle::Get(vehicle_id)->max_age;
return ::Vehicle::Get(vehicle_id)->max_age.base();
}
/* static */ SQInteger ScriptVehicle::GetAgeLeft(VehicleID vehicle_id)
{
if (!IsPrimaryVehicle(vehicle_id)) return -1;
return (int32_t)(::Vehicle::Get(vehicle_id)->max_age - ::Vehicle::Get(vehicle_id)->age);
return (::Vehicle::Get(vehicle_id)->max_age - ::Vehicle::Get(vehicle_id)->age).base();
}
/* static */ SQInteger ScriptVehicle::GetCurrentSpeed(VehicleID vehicle_id)