|
@@ -44,13 +44,13 @@ INSTANTIATE_POOL_METHODS(Engine)
|
|
|
EngineOverrideManager _engine_mngr;
|
|
|
|
|
|
/**
|
|
|
* Year that engine aging stops. Engines will not reduce in reliability
|
|
|
* and no more engines will be introduced
|
|
|
*/
|
|
|
static Year _year_engine_aging_stops;
|
|
|
static TimerGameCalendar::Year _year_engine_aging_stops;
|
|
|
|
|
|
/** Number of engines of each vehicle type in original engine data */
|
|
|
const uint8 _engine_counts[4] = {
|
|
|
lengthof(_orig_rail_vehicle_info),
|
|
|
lengthof(_orig_road_vehicle_info),
|
|
|
lengthof(_orig_ship_vehicle_info),
|
|
@@ -433,13 +433,13 @@ uint Engine::GetDisplayMaxTractiveEffort
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* Returns the vehicle's (not model's!) life length in days.
|
|
|
* @return the life length
|
|
|
*/
|
|
|
Date Engine::GetLifeLengthInDays() const
|
|
|
TimerGameCalendar::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->info.lifelength + _settings_game.vehicle.extend_vehicle_life) * DAYS_IN_LEAP_YEAR;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -673,13 +673,13 @@ void SetYearEngineAgingStops()
|
|
|
/**
|
|
|
* Start/initialise one engine.
|
|
|
* @param e The engine to initialise.
|
|
|
* @param aging_date The date used for age calculations.
|
|
|
* @param seed Random seed.
|
|
|
*/
|
|
|
void StartupOneEngine(Engine *e, Date aging_date, uint32 seed)
|
|
|
void StartupOneEngine(Engine *e, TimerGameCalendar::Date aging_date, uint32 seed)
|
|
|
{
|
|
|
const EngineInfo *ei = &e->info;
|
|
|
|
|
|
e->age = 0;
|
|
|
e->flags = 0;
|
|
|
e->company_avail = 0;
|
|
@@ -695,13 +695,13 @@ void StartupOneEngine(Engine *e, Date ag
|
|
|
e->GetGRFID());
|
|
|
uint32 r = Random();
|
|
|
|
|
|
/* Don't randomise the start-date in the first two years after gamestart to ensure availability
|
|
|
* of engines in early starting games.
|
|
|
* Note: TTDP uses fixed 1922 */
|
|
|
e->intro_date = ei->base_intro <= ConvertYMDToDate(_settings_game.game_creation.starting_year + 2, 0, 1) ? ei->base_intro : (Date)GB(r, 0, 9) + ei->base_intro;
|
|
|
e->intro_date = ei->base_intro <= ConvertYMDToDate(_settings_game.game_creation.starting_year + 2, 0, 1) ? ei->base_intro : (TimerGameCalendar::Date)GB(r, 0, 9) + ei->base_intro;
|
|
|
if (e->intro_date <= TimerGameCalendar::date) {
|
|
|
e->age = (aging_date - e->intro_date) >> 5;
|
|
|
e->company_avail = MAX_UVALUE(CompanyMask);
|
|
|
e->flags |= ENGINE_AVAILABLE;
|
|
|
}
|
|
|
|
|
@@ -742,13 +742,13 @@ void StartupOneEngine(Engine *e, Date ag
|
|
|
* Start/initialise all our engines. Must be called whenever there are changes
|
|
|
* to the NewGRF config.
|
|
|
*/
|
|
|
void StartupEngines()
|
|
|
{
|
|
|
/* Aging of vehicles stops, so account for that when starting late */
|
|
|
const Date aging_date = std::min(TimerGameCalendar::date, ConvertYMDToDate(_year_engine_aging_stops, 0, 1));
|
|
|
const TimerGameCalendar::Date aging_date = std::min(TimerGameCalendar::date, ConvertYMDToDate(_year_engine_aging_stops, 0, 1));
|
|
|
uint32 seed = Random();
|
|
|
|
|
|
for (Engine *e : Engine::Iterate()) {
|
|
|
StartupOneEngine(e, aging_date, seed);
|
|
|
}
|
|
|
for (Engine *e : Engine::Iterate()) {
|
|
@@ -1262,13 +1262,13 @@ bool IsEngineRefittable(EngineID engine)
|
|
|
|
|
|
/**
|
|
|
* Check for engines that have an appropriate availability.
|
|
|
*/
|
|
|
void CheckEngines()
|
|
|
{
|
|
|
Date min_date = INT32_MAX;
|
|
|
TimerGameCalendar::Date min_date = INT32_MAX;
|
|
|
|
|
|
for (const Engine *e : Engine::Iterate()) {
|
|
|
if (!e->IsEnabled()) continue;
|
|
|
|
|
|
/* Don't consider train wagons, we need a powered engine available. */
|
|
|
if (e->type == VEH_TRAIN && e->u.rail.railveh_type == RAILVEH_WAGON) continue;
|