(svn r19591) -Add: [NoAI] AIRail::GetMaxSpeed(RailType) to get the speed limit of railtypes
This commit is contained in:
@@ -469,3 +469,10 @@ static bool IsValidSignalType(int signal_type)
|
||||
default: return -1;
|
||||
}
|
||||
}
|
||||
|
||||
/* static */ int32 AIRail::GetMaxSpeed(RailType railtype)
|
||||
{
|
||||
if (!AIRail::IsRailTypeAvailable(railtype)) return -1;
|
||||
|
||||
return ::GetRailTypeInfo((::RailType)railtype)->max_speed;
|
||||
}
|
||||
|
@@ -440,6 +440,18 @@ public:
|
||||
* @return The baseprice of building the given object.
|
||||
*/
|
||||
static Money GetBuildCost(RailType railtype, BuildType build_type);
|
||||
|
||||
/**
|
||||
* Get the maximum speed of trains running on this railtype.
|
||||
* @param railtype The railtype to get the maximum speed of.
|
||||
* @pre IsRailTypeAvailable(railtype)
|
||||
* @return The maximum speed trains can run on this railtype
|
||||
* or 0 if there is no limit.
|
||||
* @note The speed is in OpenTTD's internal speed unit.
|
||||
* This is mph / 1.6, which is roughly km/h.
|
||||
* To get km/h multiply this number by 1.00584.
|
||||
*/
|
||||
static int32 GetMaxSpeed(RailType railtype);
|
||||
};
|
||||
|
||||
#endif /* AI_RAIL_HPP */
|
||||
|
@@ -106,6 +106,7 @@ void SQAIRail_Register(Squirrel *engine)
|
||||
SQAIRail.DefSQStaticMethod(engine, &AIRail::BuildSignal, "BuildSignal", 4, ".iii");
|
||||
SQAIRail.DefSQStaticMethod(engine, &AIRail::RemoveSignal, "RemoveSignal", 3, ".ii");
|
||||
SQAIRail.DefSQStaticMethod(engine, &AIRail::GetBuildCost, "GetBuildCost", 3, ".ii");
|
||||
SQAIRail.DefSQStaticMethod(engine, &AIRail::GetMaxSpeed, "GetMaxSpeed", 2, ".i");
|
||||
|
||||
SQAIRail.PostRegister(engine);
|
||||
}
|
||||
|
Reference in New Issue
Block a user