1
0
mirror of https://github.com/OpenTTD/OpenTTD.git synced 2025-08-24 06:59:10 +00:00

Codechange: Use DateAtStartOfYear() instead of multiplying by DAYS_IN_LEAP_YEAR (#11174)

This commit is contained in:
Tyler Trahan
2023-08-11 08:18:59 -04:00
committed by GitHub
parent 93069066f9
commit e4fd99a33a
4 changed files with 40 additions and 39 deletions

View File

@@ -437,8 +437,7 @@ uint Engine::GetDisplayMaxTractiveEffort() 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;
return DateAtStartOfYear(this->info.lifelength + _settings_game.vehicle.extend_vehicle_life);
}
/**
@@ -663,7 +662,7 @@ void SetYearEngineAgingStops()
/* Base year ending date on half the model life */
TimerGameCalendar::YearMonthDay ymd;
TimerGameCalendar::ConvertDateToYMD(ei->base_intro + (ei->lifelength * DAYS_IN_LEAP_YEAR) / 2, &ymd);
TimerGameCalendar::ConvertDateToYMD(ei->base_intro + DateAtStartOfYear(ei->lifelength) / 2, &ymd);
_year_engine_aging_stops = std::max(_year_engine_aging_stops, ymd.year);
}