mirror of https://github.com/OpenTTD/OpenTTD
(svn r15524) -Add [NoAI]: AIEngine::GetPower, AIEngine::GetWeight and AIEngine::GetMaxTractiveEffort.
parent
ce5b380a1d
commit
3491b0fab9
|
@ -453,6 +453,9 @@ function Regression::Engine()
|
|||
print(" GetPrice(): " + AIEngine.GetPrice(i));
|
||||
print(" GetMaxAge(): " + AIEngine.GetMaxAge(i));
|
||||
print(" GetRunningCost(): " + AIEngine.GetRunningCost(i));
|
||||
print(" GetPower(): " + AIEngine.GetPower(i));
|
||||
print(" GetWeight(): " + AIEngine.GetWeight(i));
|
||||
print(" GetMaxTractiveEffort(): " + AIEngine.GetMaxTractiveEffort(i));
|
||||
print(" GetVehicleType(): " + AIEngine.GetVehicleType(i));
|
||||
print(" GetRailType(): " + AIEngine.GetRailType(i));
|
||||
print(" GetRoadType(): " + AIEngine.GetRoadType(i));
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -110,6 +110,7 @@
|
|||
/* static */ int32 AIEngine::GetReliability(EngineID engine_id)
|
||||
{
|
||||
if (!IsValidEngine(engine_id)) return -1;
|
||||
if (GetVehicleType(engine_id) == AIVehicle::VT_RAIL && IsWagon(engine_id)) return -1;
|
||||
|
||||
return (::GetEngine(engine_id)->reliability * 100 >> 16);
|
||||
}
|
||||
|
@ -134,6 +135,7 @@
|
|||
/* static */ int32 AIEngine::GetMaxAge(EngineID engine_id)
|
||||
{
|
||||
if (!IsValidEngine(engine_id)) return -1;
|
||||
if (GetVehicleType(engine_id) == AIVehicle::VT_RAIL && IsWagon(engine_id)) return -1;
|
||||
|
||||
return ::GetEngine(engine_id)->lifelength * DAYS_IN_LEAP_YEAR;
|
||||
}
|
||||
|
@ -145,6 +147,32 @@
|
|||
return ::GetEngine(engine_id)->GetRunningCost();
|
||||
}
|
||||
|
||||
/* static */ int32 AIEngine::GetPower(EngineID engine_id)
|
||||
{
|
||||
if (!IsValidEngine(engine_id)) return -1;
|
||||
if (GetVehicleType(engine_id) != AIVehicle::VT_RAIL) return -1;
|
||||
if (IsWagon(engine_id)) return -1;
|
||||
|
||||
return ::GetEngine(engine_id)->GetPower();
|
||||
}
|
||||
|
||||
/* static */ int32 AIEngine::GetWeight(EngineID engine_id)
|
||||
{
|
||||
if (!IsValidEngine(engine_id)) return -1;
|
||||
if (GetVehicleType(engine_id) != AIVehicle::VT_RAIL) return -1;
|
||||
|
||||
return ::GetEngine(engine_id)->GetDisplayWeight();
|
||||
}
|
||||
|
||||
/* static */ int32 AIEngine::GetMaxTractiveEffort(EngineID engine_id)
|
||||
{
|
||||
if (!IsValidEngine(engine_id)) return -1;
|
||||
if (GetVehicleType(engine_id) != AIVehicle::VT_RAIL) return -1;
|
||||
if (IsWagon(engine_id)) return -1;
|
||||
|
||||
return ::GetEngine(engine_id)->GetDisplayMaxTractiveEffort();
|
||||
}
|
||||
|
||||
/* static */ AIVehicle::VehicleType AIEngine::GetVehicleType(EngineID engine_id)
|
||||
{
|
||||
if (!IsValidEngine(engine_id)) return AIVehicle::VT_INVALID;
|
||||
|
|
|
@ -82,6 +82,7 @@ public:
|
|||
* reliability (you most likely don't want to buy it).
|
||||
* @param engine_id The engine to get the reliability of.
|
||||
* @pre IsValidEngine(engine_id).
|
||||
* @pre GetVehicleType(engine_id) != AIVehicle::VT_TRAIN || !IsWagon(engine_id).
|
||||
* @return The reliability the engine has.
|
||||
*/
|
||||
static int32 GetReliability(EngineID engine_id);
|
||||
|
@ -90,6 +91,7 @@ public:
|
|||
* Get the maximum speed of an engine.
|
||||
* @param engine_id The engine to get the maximum speed of.
|
||||
* @pre IsValidEngine(engine_id).
|
||||
* @pre GetVehicleType(engine_id) != AIVehicle::VT_TRAIN || !IsWagon(engine_id).
|
||||
* @return The maximum speed the engine has.
|
||||
* @note The speed is in OpenTTD's internal speed unit.
|
||||
* This is mph / 1.6, which is roughly km/h.
|
||||
|
@ -123,6 +125,33 @@ public:
|
|||
*/
|
||||
static Money GetRunningCost(EngineID engine_id);
|
||||
|
||||
/**
|
||||
* Get the power of an engine.
|
||||
* @param engine_id The engine to get the power of.
|
||||
* @pre IsValidEngine(engine_id).
|
||||
* @pre GetVehicleType(engine_id) == AIVehicle::VT_RAIL && !IsWagon(engine_id).
|
||||
* @return The power of the engine in hp.
|
||||
*/
|
||||
static int32 GetPower(EngineID engine_id);
|
||||
|
||||
/**
|
||||
* Get the weight of an engine.
|
||||
* @param engine_id The engine to get the weight of.
|
||||
* @pre IsValidEngine(engine_id).
|
||||
* @pre GetVehicleType(engine_id) == AIVehicle::VT_RAIL.
|
||||
* @return The weight of the engine in metric tons.
|
||||
*/
|
||||
static int32 GetWeight(EngineID engine_id);
|
||||
|
||||
/**
|
||||
* Get the maximum tractive effort of an engine.
|
||||
* @param engine_id The engine to get the maximum tractive effort of.
|
||||
* @pre IsValidEngine(engine_id).
|
||||
* @pre GetVehicleType(engine_id) == AIVehicle::VT_RAIL && !IsWagon(engine_id).
|
||||
* @return The maximum tractive effort of the engine in kN.
|
||||
*/
|
||||
static int32 GetMaxTractiveEffort(EngineID engine_id);
|
||||
|
||||
/**
|
||||
* Get the type of an engine.
|
||||
* @param engine_id The engine to get the type of.
|
||||
|
|
|
@ -17,25 +17,28 @@ void SQAIEngine_Register(Squirrel *engine) {
|
|||
SQAIEngine.PreRegister(engine);
|
||||
SQAIEngine.AddConstructor<void (AIEngine::*)(), 1>(engine, "x");
|
||||
|
||||
SQAIEngine.DefSQStaticMethod(engine, &AIEngine::IsValidEngine, "IsValidEngine", 2, "?i");
|
||||
SQAIEngine.DefSQStaticMethod(engine, &AIEngine::GetName, "GetName", 2, "?i");
|
||||
SQAIEngine.DefSQStaticMethod(engine, &AIEngine::GetCargoType, "GetCargoType", 2, "?i");
|
||||
SQAIEngine.DefSQStaticMethod(engine, &AIEngine::CanRefitCargo, "CanRefitCargo", 3, "?ii");
|
||||
SQAIEngine.DefSQStaticMethod(engine, &AIEngine::CanPullCargo, "CanPullCargo", 3, "?ii");
|
||||
SQAIEngine.DefSQStaticMethod(engine, &AIEngine::GetCapacity, "GetCapacity", 2, "?i");
|
||||
SQAIEngine.DefSQStaticMethod(engine, &AIEngine::GetReliability, "GetReliability", 2, "?i");
|
||||
SQAIEngine.DefSQStaticMethod(engine, &AIEngine::GetMaxSpeed, "GetMaxSpeed", 2, "?i");
|
||||
SQAIEngine.DefSQStaticMethod(engine, &AIEngine::GetPrice, "GetPrice", 2, "?i");
|
||||
SQAIEngine.DefSQStaticMethod(engine, &AIEngine::GetMaxAge, "GetMaxAge", 2, "?i");
|
||||
SQAIEngine.DefSQStaticMethod(engine, &AIEngine::GetRunningCost, "GetRunningCost", 2, "?i");
|
||||
SQAIEngine.DefSQStaticMethod(engine, &AIEngine::GetVehicleType, "GetVehicleType", 2, "?i");
|
||||
SQAIEngine.DefSQStaticMethod(engine, &AIEngine::IsWagon, "IsWagon", 2, "?i");
|
||||
SQAIEngine.DefSQStaticMethod(engine, &AIEngine::CanRunOnRail, "CanRunOnRail", 3, "?ii");
|
||||
SQAIEngine.DefSQStaticMethod(engine, &AIEngine::HasPowerOnRail, "HasPowerOnRail", 3, "?ii");
|
||||
SQAIEngine.DefSQStaticMethod(engine, &AIEngine::GetRoadType, "GetRoadType", 2, "?i");
|
||||
SQAIEngine.DefSQStaticMethod(engine, &AIEngine::GetRailType, "GetRailType", 2, "?i");
|
||||
SQAIEngine.DefSQStaticMethod(engine, &AIEngine::IsArticulated, "IsArticulated", 2, "?i");
|
||||
SQAIEngine.DefSQStaticMethod(engine, &AIEngine::GetPlaneType, "GetPlaneType", 2, "?i");
|
||||
SQAIEngine.DefSQStaticMethod(engine, &AIEngine::IsValidEngine, "IsValidEngine", 2, "?i");
|
||||
SQAIEngine.DefSQStaticMethod(engine, &AIEngine::GetName, "GetName", 2, "?i");
|
||||
SQAIEngine.DefSQStaticMethod(engine, &AIEngine::GetCargoType, "GetCargoType", 2, "?i");
|
||||
SQAIEngine.DefSQStaticMethod(engine, &AIEngine::CanRefitCargo, "CanRefitCargo", 3, "?ii");
|
||||
SQAIEngine.DefSQStaticMethod(engine, &AIEngine::CanPullCargo, "CanPullCargo", 3, "?ii");
|
||||
SQAIEngine.DefSQStaticMethod(engine, &AIEngine::GetCapacity, "GetCapacity", 2, "?i");
|
||||
SQAIEngine.DefSQStaticMethod(engine, &AIEngine::GetReliability, "GetReliability", 2, "?i");
|
||||
SQAIEngine.DefSQStaticMethod(engine, &AIEngine::GetMaxSpeed, "GetMaxSpeed", 2, "?i");
|
||||
SQAIEngine.DefSQStaticMethod(engine, &AIEngine::GetPrice, "GetPrice", 2, "?i");
|
||||
SQAIEngine.DefSQStaticMethod(engine, &AIEngine::GetMaxAge, "GetMaxAge", 2, "?i");
|
||||
SQAIEngine.DefSQStaticMethod(engine, &AIEngine::GetRunningCost, "GetRunningCost", 2, "?i");
|
||||
SQAIEngine.DefSQStaticMethod(engine, &AIEngine::GetPower, "GetPower", 2, "?i");
|
||||
SQAIEngine.DefSQStaticMethod(engine, &AIEngine::GetWeight, "GetWeight", 2, "?i");
|
||||
SQAIEngine.DefSQStaticMethod(engine, &AIEngine::GetMaxTractiveEffort, "GetMaxTractiveEffort", 2, "?i");
|
||||
SQAIEngine.DefSQStaticMethod(engine, &AIEngine::GetVehicleType, "GetVehicleType", 2, "?i");
|
||||
SQAIEngine.DefSQStaticMethod(engine, &AIEngine::IsWagon, "IsWagon", 2, "?i");
|
||||
SQAIEngine.DefSQStaticMethod(engine, &AIEngine::CanRunOnRail, "CanRunOnRail", 3, "?ii");
|
||||
SQAIEngine.DefSQStaticMethod(engine, &AIEngine::HasPowerOnRail, "HasPowerOnRail", 3, "?ii");
|
||||
SQAIEngine.DefSQStaticMethod(engine, &AIEngine::GetRoadType, "GetRoadType", 2, "?i");
|
||||
SQAIEngine.DefSQStaticMethod(engine, &AIEngine::GetRailType, "GetRailType", 2, "?i");
|
||||
SQAIEngine.DefSQStaticMethod(engine, &AIEngine::IsArticulated, "IsArticulated", 2, "?i");
|
||||
SQAIEngine.DefSQStaticMethod(engine, &AIEngine::GetPlaneType, "GetPlaneType", 2, "?i");
|
||||
|
||||
SQAIEngine.PostRegister(engine);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue