mirror of https://github.com/OpenTTD/OpenTTD
Cleanup: Fix and add comments to date cheat callback (#10699)
parent
e9f6bbada2
commit
7c6bf977e0
|
@ -98,22 +98,27 @@ extern void EnginesMonthlyLoop();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handle changing of the current year.
|
* Handle changing of the current year.
|
||||||
* @param new_value Unused.
|
* @param new_value The chosen year to change to.
|
||||||
* @param change_direction +1 (increase) or -1 (decrease).
|
* @param change_direction +1 (increase) or -1 (decrease).
|
||||||
* @return New year.
|
* @return New year.
|
||||||
*/
|
*/
|
||||||
static int32 ClickChangeDateCheat(int32 new_value, int32 change_direction)
|
static int32 ClickChangeDateCheat(int32 new_value, int32 change_direction)
|
||||||
{
|
{
|
||||||
YearMonthDay ymd;
|
/* Don't allow changing to an invalid year, or the current year. */
|
||||||
ConvertDateToYMD(_date, &ymd);
|
|
||||||
|
|
||||||
new_value = Clamp(new_value, MIN_YEAR, MAX_YEAR);
|
new_value = Clamp(new_value, MIN_YEAR, MAX_YEAR);
|
||||||
if (new_value == _cur_year) return _cur_year;
|
if (new_value == _cur_year) return _cur_year;
|
||||||
|
|
||||||
|
YearMonthDay ymd;
|
||||||
|
ConvertDateToYMD(_date, &ymd);
|
||||||
Date new_date = ConvertYMDToDate(new_value, ymd.month, ymd.day);
|
Date new_date = ConvertYMDToDate(new_value, ymd.month, ymd.day);
|
||||||
|
|
||||||
|
/* Change the date. */
|
||||||
|
SetDate(new_date, _date_fract);
|
||||||
|
|
||||||
|
/* Shift cached dates. */
|
||||||
for (auto v : Vehicle::Iterate()) v->ShiftDates(new_date - _date);
|
for (auto v : Vehicle::Iterate()) v->ShiftDates(new_date - _date);
|
||||||
LinkGraphSchedule::instance.ShiftDates(new_date - _date);
|
LinkGraphSchedule::instance.ShiftDates(new_date - _date);
|
||||||
SetDate(new_date, _date_fract);
|
|
||||||
EnginesMonthlyLoop();
|
EnginesMonthlyLoop();
|
||||||
SetWindowDirty(WC_STATUS_BAR, 0);
|
SetWindowDirty(WC_STATUS_BAR, 0);
|
||||||
InvalidateWindowClassesData(WC_BUILD_STATION, 0);
|
InvalidateWindowClassesData(WC_BUILD_STATION, 0);
|
||||||
|
|
Loading…
Reference in New Issue