Handle predictable conditional orders in timetable window

This commit is contained in:
Jonathan G Rennison
2022-01-15 15:57:09 +00:00
parent 91ed26415e
commit b23d394f0b
5 changed files with 93 additions and 7 deletions

View File

@@ -1759,6 +1759,37 @@ int GetTraceRestrictTimeDateValue(TraceRestrictTimeDateValueField type)
}
}
int GetTraceRestrictTimeDateValueFromDate(TraceRestrictTimeDateValueField type, DateTicksScaled scaled_date_ticks)
{
Minutes minutes = (scaled_date_ticks / _settings_game.game_time.ticks_per_minute) + _settings_game.game_time.clock_offset;
switch (type) {
case TRTDVF_MINUTE:
return MINUTES_MINUTE(minutes);
case TRTDVF_HOUR:
return MINUTES_HOUR(minutes);
case TRTDVF_HOUR_MINUTE:
return (MINUTES_HOUR(minutes) * 100) + MINUTES_MINUTE(minutes);
case TRTDVF_DAY: {
YearMonthDay ymd;
ConvertDateToYMD(scaled_date_ticks / (DAY_TICKS * _settings_game.economy.day_length_factor), &ymd);
return ymd.day;
}
case TRTDVF_MONTH: {
YearMonthDay ymd;
ConvertDateToYMD(scaled_date_ticks / (DAY_TICKS * _settings_game.economy.day_length_factor), &ymd);
return ymd.month + 1;
}
default:
return 0;
}
}
/**
* This is called when a station, waypoint or depot is about to be deleted
* Scan program pool and change any references to it to the invalid station ID, to avoid dangling references