Fix #10334: Store separate newgrf-safe version of date_of_last_service. (#11124)

This value is not changed when the date cheat is used, which caused issues with changing properties based on service date.

Co-authored-by: Peter Nelson <peter1138@openttd.org>
This commit is contained in:
Tyler Trahan
2023-08-06 12:57:10 -04:00
committed by GitHub
parent 77c00dfe98
commit 9a602ff304
11 changed files with 24 additions and 3 deletions

View File

@@ -170,6 +170,7 @@ void VehicleServiceInDepot(Vehicle *v)
do {
v->date_of_last_service = TimerGameCalendar::date;
v->date_of_last_service_newgrf = TimerGameCalendar::date;
v->breakdowns_since_last_service = 0;
v->reliability = v->GetEngine()->reliability;
/* Prevent vehicles from breaking down directly after exiting the depot. */
@@ -761,6 +762,8 @@ uint32_t Vehicle::GetGRFID() const
void Vehicle::ShiftDates(int interval)
{
this->date_of_last_service = std::max(this->date_of_last_service + interval, 0);
/* date_of_last_service_newgrf is not updated here as it must stay stable
* for vehicles outside of a depot. */
}
/**