Fix date cheat/scenario load not adjusting vehicle date of last service
This commit is contained in:
@@ -29,6 +29,7 @@
|
|||||||
#include "error.h"
|
#include "error.h"
|
||||||
#include "network/network.h"
|
#include "network/network.h"
|
||||||
#include "order_base.h"
|
#include "order_base.h"
|
||||||
|
#include "vehicle_base.h"
|
||||||
#include "currency.h"
|
#include "currency.h"
|
||||||
|
|
||||||
#include "widgets/cheat_widget.h"
|
#include "widgets/cheat_widget.h"
|
||||||
@@ -111,6 +112,7 @@ static int32 ClickChangeDateCheat(int32 p1, int32 p2)
|
|||||||
Date new_date = ConvertYMDToDate(p1, ymd.month, ymd.day);
|
Date new_date = ConvertYMDToDate(p1, ymd.month, ymd.day);
|
||||||
LinkGraphSchedule::instance.ShiftDates(new_date - _date);
|
LinkGraphSchedule::instance.ShiftDates(new_date - _date);
|
||||||
ShiftOrderDates(new_date - _date);
|
ShiftOrderDates(new_date - _date);
|
||||||
|
ShiftVehicleDates(new_date - _date);
|
||||||
SetDate(new_date, _date_fract);
|
SetDate(new_date, _date_fract);
|
||||||
EnginesMonthlyLoop();
|
EnginesMonthlyLoop();
|
||||||
InvalidateWindowClassesData(WC_BUILD_STATION, 0);
|
InvalidateWindowClassesData(WC_BUILD_STATION, 0);
|
||||||
|
@@ -228,9 +228,9 @@ static void OnNewYear()
|
|||||||
_cur_date_ymd.year--;
|
_cur_date_ymd.year--;
|
||||||
days_this_year = IsLeapYear(_cur_date_ymd.year) ? DAYS_IN_LEAP_YEAR : DAYS_IN_YEAR;
|
days_this_year = IsLeapYear(_cur_date_ymd.year) ? DAYS_IN_LEAP_YEAR : DAYS_IN_YEAR;
|
||||||
_date -= days_this_year;
|
_date -= days_this_year;
|
||||||
for (Vehicle *v : Vehicle::Iterate()) v->date_of_last_service -= days_this_year;
|
|
||||||
for (LinkGraph *lg : LinkGraph::Iterate()) lg->ShiftDates(-days_this_year);
|
for (LinkGraph *lg : LinkGraph::Iterate()) lg->ShiftDates(-days_this_year);
|
||||||
ShiftOrderDates(-days_this_year);
|
ShiftOrderDates(-days_this_year);
|
||||||
|
ShiftVehicleDates(-days_this_year);
|
||||||
|
|
||||||
/* Because the _date wraps here, and text-messages expire by game-days, we have to clean out
|
/* Because the _date wraps here, and text-messages expire by game-days, we have to clean out
|
||||||
* all of them if the date is set back, else those messages will hang for ever */
|
* all of them if the date is set back, else those messages will hang for ever */
|
||||||
|
@@ -1131,6 +1131,7 @@ void SetStartingYear(Year year)
|
|||||||
/* If you open a savegame as scenario there may already be link graphs.*/
|
/* If you open a savegame as scenario there may already be link graphs.*/
|
||||||
LinkGraphSchedule::instance.ShiftDates(new_date - _date);
|
LinkGraphSchedule::instance.ShiftDates(new_date - _date);
|
||||||
ShiftOrderDates(new_date - _date);
|
ShiftOrderDates(new_date - _date);
|
||||||
|
ShiftVehicleDates(new_date - _date);
|
||||||
SetDate(new_date, 0);
|
SetDate(new_date, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -4204,3 +4204,10 @@ void DumpVehicleStats(char *buffer, const char *last)
|
|||||||
buffer += seprintf(buffer, last, "\n");
|
buffer += seprintf(buffer, last, "\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ShiftVehicleDates(int interval)
|
||||||
|
{
|
||||||
|
for (Vehicle *v : Vehicle::Iterate()) {
|
||||||
|
v->date_of_last_service += interval;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@@ -1427,4 +1427,6 @@ void ClearVehicleTickCaches();
|
|||||||
void RemoveFromOtherVehicleTickCache(const Vehicle *v);
|
void RemoveFromOtherVehicleTickCache(const Vehicle *v);
|
||||||
void UpdateAllVehiclesIsDrawn();
|
void UpdateAllVehiclesIsDrawn();
|
||||||
|
|
||||||
|
void ShiftVehicleDates(int interval);
|
||||||
|
|
||||||
#endif /* VEHICLE_BASE_H */
|
#endif /* VEHICLE_BASE_H */
|
||||||
|
Reference in New Issue
Block a user