mirror of https://github.com/OpenTTD/OpenTTD.git
(svn r16581) -Codechange: unify the access to Engine::lifelength.
This commit is contained in:
parent
4b05617c42
commit
512b021e26
|
@ -117,7 +117,7 @@
|
|||
if (!IsValidEngine(engine_id)) return -1;
|
||||
if (GetVehicleType(engine_id) == AIVehicle::VT_RAIL && IsWagon(engine_id)) return -1;
|
||||
|
||||
return ::Engine::Get(engine_id)->lifelength * DAYS_IN_LEAP_YEAR;
|
||||
return ::Engine::Get(engine_id)->GetLifeLengthInDays();
|
||||
}
|
||||
|
||||
/* static */ Money AIEngine::GetRunningCost(EngineID engine_id)
|
||||
|
|
|
@ -334,7 +334,7 @@ CommandCost CmdBuildAircraft(TileIndex tile, DoCommandFlag flags, uint32 p1, uin
|
|||
|
||||
v->reliability = e->reliability;
|
||||
v->reliability_spd_dec = e->reliability_spd_dec;
|
||||
v->max_age = e->lifelength * DAYS_IN_LEAP_YEAR;
|
||||
v->max_age = e->GetLifeLengthInDays();
|
||||
|
||||
_new_vehicle_id = v->index;
|
||||
|
||||
|
|
|
@ -676,7 +676,7 @@ int DrawVehiclePurchaseInfo(int left, int right, int y, EngineID engine_number)
|
|||
if (e->type != VEH_TRAIN || RailVehInfo(engine_number)->railveh_type != RAILVEH_WAGON) {
|
||||
/* Design date - Life length */
|
||||
SetDParam(0, ymd.year);
|
||||
SetDParam(1, e->lifelength);
|
||||
SetDParam(1, e->GetLifeLengthInDays() / DAYS_IN_LEAP_YEAR);
|
||||
DrawString(left, right, y, STR_PURCHASE_INFO_DESIGNED_LIFE);
|
||||
y += FONT_HEIGHT_NORMAL;
|
||||
|
||||
|
|
|
@ -315,6 +315,16 @@ uint Engine::GetDisplayMaxTractiveEffort() const
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the vehicle's life length in days.
|
||||
* @return the life length
|
||||
*/
|
||||
Date Engine::GetLifeLengthInDays() const
|
||||
{
|
||||
/* Assume leap years; this gives the player a bit more than the given amount of years, but never less. */
|
||||
return this->lifelength * DAYS_IN_LEAP_YEAR;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the EngineOverrideManager with the default engines.
|
||||
*/
|
||||
|
|
|
@ -59,6 +59,7 @@ struct Engine : EnginePool::PoolItem<&_engine_pool> {
|
|||
uint GetPower() const;
|
||||
uint GetDisplayWeight() const;
|
||||
uint GetDisplayMaxTractiveEffort() const;
|
||||
Date GetLifeLengthInDays() const;
|
||||
};
|
||||
|
||||
struct EngineIDMapping {
|
||||
|
|
|
@ -230,7 +230,7 @@ CommandCost CmdBuildRoadVeh(TileIndex tile, DoCommandFlag flags, uint32 p1, uint
|
|||
|
||||
v->reliability = e->reliability;
|
||||
v->reliability_spd_dec = e->reliability_spd_dec;
|
||||
v->max_age = e->lifelength * DAYS_IN_LEAP_YEAR;
|
||||
v->max_age = e->GetLifeLengthInDays();
|
||||
_new_vehicle_id = v->index;
|
||||
|
||||
v->name = NULL;
|
||||
|
|
|
@ -799,7 +799,7 @@ CommandCost CmdBuildShip(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32
|
|||
|
||||
v->reliability = e->reliability;
|
||||
v->reliability_spd_dec = e->reliability_spd_dec;
|
||||
v->max_age = e->lifelength * DAYS_IN_LEAP_YEAR;
|
||||
v->max_age = e->GetLifeLengthInDays();
|
||||
_new_vehicle_id = v->index;
|
||||
|
||||
v->name = NULL;
|
||||
|
|
|
@ -869,7 +869,7 @@ CommandCost CmdBuildRailVehicle(TileIndex tile, DoCommandFlag flags, uint32 p1,
|
|||
|
||||
v->reliability = e->reliability;
|
||||
v->reliability_spd_dec = e->reliability_spd_dec;
|
||||
v->max_age = e->lifelength * DAYS_IN_LEAP_YEAR;
|
||||
v->max_age = e->GetLifeLengthInDays();
|
||||
|
||||
v->name = NULL;
|
||||
v->railtype = rvi->railtype;
|
||||
|
|
Loading…
Reference in New Issue