mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-03-11 09:59:42 +00:00
(svn r16790) -Add [NoAI]: AIVehicle::GetReliability to get the current reliability of vehicles
This commit is contained in:
parent
4843b3c45d
commit
b58001f695
@ -425,3 +425,11 @@
|
|||||||
Vehicle *v = ::Vehicle::Get(vehicle_id);
|
Vehicle *v = ::Vehicle::Get(vehicle_id);
|
||||||
return v->orders.list != NULL && v->orders.list->GetNumVehicles() > 1;
|
return v->orders.list != NULL && v->orders.list->GetNumVehicles() > 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* static */ int AIVehicle::GetReliability(VehicleID vehicle_id)
|
||||||
|
{
|
||||||
|
if (!IsValidVehicle(vehicle_id)) return -1;
|
||||||
|
|
||||||
|
const Vehicle *v = ::Vehicle::Get(vehicle_id);
|
||||||
|
return v->reliability * 100 >> 16;
|
||||||
|
}
|
||||||
|
@ -525,6 +525,14 @@ public:
|
|||||||
*/
|
*/
|
||||||
static bool HasSharedOrders(VehicleID vehicle_id);
|
static bool HasSharedOrders(VehicleID vehicle_id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the current reliability of a vehicle.
|
||||||
|
* @param vehicle_id The vehicle to check.
|
||||||
|
* @pre IsValidVehicle(vehicle_id).
|
||||||
|
* @return The current reliability (0-100%).
|
||||||
|
*/
|
||||||
|
static int GetReliability(VehicleID vehicle_id);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/**
|
/**
|
||||||
* Internal function used by SellWagon(Chain).
|
* Internal function used by SellWagon(Chain).
|
||||||
|
@ -142,6 +142,7 @@ void SQAIVehicle_Register(Squirrel *engine) {
|
|||||||
SQAIVehicle.DefSQStaticMethod(engine, &AIVehicle::GetGroupID, "GetGroupID", 2, ".i");
|
SQAIVehicle.DefSQStaticMethod(engine, &AIVehicle::GetGroupID, "GetGroupID", 2, ".i");
|
||||||
SQAIVehicle.DefSQStaticMethod(engine, &AIVehicle::IsArticulated, "IsArticulated", 2, ".i");
|
SQAIVehicle.DefSQStaticMethod(engine, &AIVehicle::IsArticulated, "IsArticulated", 2, ".i");
|
||||||
SQAIVehicle.DefSQStaticMethod(engine, &AIVehicle::HasSharedOrders, "HasSharedOrders", 2, ".i");
|
SQAIVehicle.DefSQStaticMethod(engine, &AIVehicle::HasSharedOrders, "HasSharedOrders", 2, ".i");
|
||||||
|
SQAIVehicle.DefSQStaticMethod(engine, &AIVehicle::GetReliability, "GetReliability", 2, ".i");
|
||||||
|
|
||||||
SQAIVehicle.PostRegister(engine);
|
SQAIVehicle.PostRegister(engine);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user