1
0
Fork 0

Codechange: Use SQInteger for generic numbers in script_engine

pull/10532/head
glx22 2023-02-11 16:31:43 +01:00 committed by Loïc Guilloux
parent 2f40bf8097
commit 6b8b4c392f
2 changed files with 19 additions and 24 deletions

View File

@ -83,7 +83,7 @@
} }
/* static */ int32 ScriptEngine::GetCapacity(EngineID engine_id) /* static */ SQInteger ScriptEngine::GetCapacity(EngineID engine_id)
{ {
if (!IsValidEngine(engine_id)) return -1; if (!IsValidEngine(engine_id)) return -1;
@ -107,7 +107,7 @@
} }
} }
/* static */ int32 ScriptEngine::GetReliability(EngineID engine_id) /* static */ SQInteger ScriptEngine::GetReliability(EngineID engine_id)
{ {
if (!IsValidEngine(engine_id)) return -1; if (!IsValidEngine(engine_id)) return -1;
if (GetVehicleType(engine_id) == ScriptVehicle::VT_RAIL && IsWagon(engine_id)) return -1; if (GetVehicleType(engine_id) == ScriptVehicle::VT_RAIL && IsWagon(engine_id)) return -1;
@ -115,12 +115,12 @@
return ::ToPercent16(::Engine::Get(engine_id)->reliability); return ::ToPercent16(::Engine::Get(engine_id)->reliability);
} }
/* static */ int32 ScriptEngine::GetMaxSpeed(EngineID engine_id) /* static */ SQInteger ScriptEngine::GetMaxSpeed(EngineID engine_id)
{ {
if (!IsValidEngine(engine_id)) return -1; if (!IsValidEngine(engine_id)) return -1;
const Engine *e = ::Engine::Get(engine_id); const Engine *e = ::Engine::Get(engine_id);
int32 max_speed = e->GetDisplayMaxSpeed(); // km-ish/h uint max_speed = e->GetDisplayMaxSpeed(); // km-ish/h
if (e->type == VEH_AIRCRAFT) max_speed /= _settings_game.vehicle.plane_speed; if (e->type == VEH_AIRCRAFT) max_speed /= _settings_game.vehicle.plane_speed;
return max_speed; return max_speed;
} }
@ -132,7 +132,7 @@
return ::Engine::Get(engine_id)->GetCost(); return ::Engine::Get(engine_id)->GetCost();
} }
/* static */ int32 ScriptEngine::GetMaxAge(EngineID engine_id) /* static */ SQInteger ScriptEngine::GetMaxAge(EngineID engine_id)
{ {
if (!IsValidEngine(engine_id)) return -1; if (!IsValidEngine(engine_id)) return -1;
if (GetVehicleType(engine_id) == ScriptVehicle::VT_RAIL && IsWagon(engine_id)) return -1; if (GetVehicleType(engine_id) == ScriptVehicle::VT_RAIL && IsWagon(engine_id)) return -1;
@ -147,7 +147,7 @@
return ::Engine::Get(engine_id)->GetRunningCost(); return ::Engine::Get(engine_id)->GetRunningCost();
} }
/* static */ int32 ScriptEngine::GetPower(EngineID engine_id) /* static */ SQInteger ScriptEngine::GetPower(EngineID engine_id)
{ {
if (!IsValidEngine(engine_id)) return -1; if (!IsValidEngine(engine_id)) return -1;
if (GetVehicleType(engine_id) != ScriptVehicle::VT_RAIL && GetVehicleType(engine_id) != ScriptVehicle::VT_ROAD) return -1; if (GetVehicleType(engine_id) != ScriptVehicle::VT_RAIL && GetVehicleType(engine_id) != ScriptVehicle::VT_ROAD) return -1;
@ -156,7 +156,7 @@
return ::Engine::Get(engine_id)->GetPower(); return ::Engine::Get(engine_id)->GetPower();
} }
/* static */ int32 ScriptEngine::GetWeight(EngineID engine_id) /* static */ SQInteger ScriptEngine::GetWeight(EngineID engine_id)
{ {
if (!IsValidEngine(engine_id)) return -1; if (!IsValidEngine(engine_id)) return -1;
if (GetVehicleType(engine_id) != ScriptVehicle::VT_RAIL && GetVehicleType(engine_id) != ScriptVehicle::VT_ROAD) return -1; if (GetVehicleType(engine_id) != ScriptVehicle::VT_RAIL && GetVehicleType(engine_id) != ScriptVehicle::VT_ROAD) return -1;
@ -164,7 +164,7 @@
return ::Engine::Get(engine_id)->GetDisplayWeight(); return ::Engine::Get(engine_id)->GetDisplayWeight();
} }
/* static */ int32 ScriptEngine::GetMaxTractiveEffort(EngineID engine_id) /* static */ SQInteger ScriptEngine::GetMaxTractiveEffort(EngineID engine_id)
{ {
if (!IsValidEngine(engine_id)) return -1; if (!IsValidEngine(engine_id)) return -1;
if (GetVehicleType(engine_id) != ScriptVehicle::VT_RAIL && GetVehicleType(engine_id) != ScriptVehicle::VT_ROAD) return -1; if (GetVehicleType(engine_id) != ScriptVehicle::VT_RAIL && GetVehicleType(engine_id) != ScriptVehicle::VT_ROAD) return -1;
@ -265,17 +265,12 @@
return (ScriptAirport::PlaneType)::AircraftVehInfo(engine_id)->subtype; return (ScriptAirport::PlaneType)::AircraftVehInfo(engine_id)->subtype;
} }
/* static */ uint ScriptEngine::GetMaximumOrderDistance(EngineID engine_id) /* static */ SQInteger ScriptEngine::GetMaximumOrderDistance(EngineID engine_id)
{ {
if (!IsValidEngine(engine_id)) return 0; if (!IsValidEngine(engine_id)) return 0;
if (GetVehicleType(engine_id) != ScriptVehicle::VT_AIR) return 0;
switch (GetVehicleType(engine_id)) { return (SQInteger)::Engine::Get(engine_id)->GetRange() * ::Engine::Get(engine_id)->GetRange();
case ScriptVehicle::VT_AIR:
return ::Engine::Get(engine_id)->GetRange() * ::Engine::Get(engine_id)->GetRange();
default:
return 0;
}
} }
/* static */ bool ScriptEngine::EnableForCompany(EngineID engine_id, ScriptCompany::CompanyID company) /* static */ bool ScriptEngine::EnableForCompany(EngineID engine_id, ScriptCompany::CompanyID company)

View File

@ -89,7 +89,7 @@ public:
* @pre IsValidEngine(engine_id). * @pre IsValidEngine(engine_id).
* @return The capacity of the engine. * @return The capacity of the engine.
*/ */
static int32 GetCapacity(EngineID engine_id); static SQInteger GetCapacity(EngineID engine_id);
/** /**
* Get the reliability of an engine. The value is between 0 and 100, where * Get the reliability of an engine. The value is between 0 and 100, where
@ -100,7 +100,7 @@ public:
* @pre GetVehicleType(engine_id) != ScriptVehicle::VT_TRAIN || !IsWagon(engine_id). * @pre GetVehicleType(engine_id) != ScriptVehicle::VT_TRAIN || !IsWagon(engine_id).
* @return The reliability the engine has. * @return The reliability the engine has.
*/ */
static int32 GetReliability(EngineID engine_id); static SQInteger GetReliability(EngineID engine_id);
/** /**
* Get the maximum speed of an engine. * Get the maximum speed of an engine.
@ -111,7 +111,7 @@ public:
* This is mph / 1.6, which is roughly km/h. * This is mph / 1.6, which is roughly km/h.
* To get km/h multiply this number by 1.00584. * To get km/h multiply this number by 1.00584.
*/ */
static int32 GetMaxSpeed(EngineID engine_id); static SQInteger GetMaxSpeed(EngineID engine_id);
/** /**
* Get the new cost of an engine. * Get the new cost of an engine.
@ -128,7 +128,7 @@ public:
* @returns The maximum age of a new engine in days. * @returns The maximum age of a new engine in days.
* @note Age is in days; divide by 366 to get per year. * @note Age is in days; divide by 366 to get per year.
*/ */
static int32 GetMaxAge(EngineID engine_id); static SQInteger GetMaxAge(EngineID engine_id);
/** /**
* Get the running cost of an engine. * Get the running cost of an engine.
@ -146,7 +146,7 @@ public:
* @pre (GetVehicleType(engine_id) == ScriptVehicle::VT_RAIL || GetVehicleType(engine_id) == ScriptVehicle::VT_ROAD) && !IsWagon(engine_id). * @pre (GetVehicleType(engine_id) == ScriptVehicle::VT_RAIL || GetVehicleType(engine_id) == ScriptVehicle::VT_ROAD) && !IsWagon(engine_id).
* @return The power of the engine in hp. * @return The power of the engine in hp.
*/ */
static int32 GetPower(EngineID engine_id); static SQInteger GetPower(EngineID engine_id);
/** /**
* Get the weight of an engine. * Get the weight of an engine.
@ -155,7 +155,7 @@ public:
* @pre (GetVehicleType(engine_id) == ScriptVehicle::VT_RAIL || GetVehicleType(engine_id) == ScriptVehicle::VT_ROAD). * @pre (GetVehicleType(engine_id) == ScriptVehicle::VT_RAIL || GetVehicleType(engine_id) == ScriptVehicle::VT_ROAD).
* @return The weight of the engine in metric tons. * @return The weight of the engine in metric tons.
*/ */
static int32 GetWeight(EngineID engine_id); static SQInteger GetWeight(EngineID engine_id);
/** /**
* Get the maximum tractive effort of an engine. * Get the maximum tractive effort of an engine.
@ -164,7 +164,7 @@ public:
* @pre (GetVehicleType(engine_id) == ScriptVehicle::VT_RAIL || GetVehicleType(engine_id) == ScriptVehicle::VT_ROAD) && !IsWagon(engine_id). * @pre (GetVehicleType(engine_id) == ScriptVehicle::VT_RAIL || GetVehicleType(engine_id) == ScriptVehicle::VT_ROAD) && !IsWagon(engine_id).
* @return The maximum tractive effort of the engine in kN. * @return The maximum tractive effort of the engine in kN.
*/ */
static int32 GetMaxTractiveEffort(EngineID engine_id); static SQInteger GetMaxTractiveEffort(EngineID engine_id);
/** /**
* Get the date this engine was designed. * Get the date this engine was designed.
@ -286,7 +286,7 @@ public:
* not be compared with map distances * not be compared with map distances
* @see ScriptOrder::GetOrderDistance * @see ScriptOrder::GetOrderDistance
*/ */
static uint GetMaximumOrderDistance(EngineID engine_id); static SQInteger GetMaximumOrderDistance(EngineID engine_id);
/** /**
* Allows a company to use an engine before its intro date or after retirement. * Allows a company to use an engine before its intro date or after retirement.