mirror of https://github.com/OpenTTD/OpenTTD
Fix: [Timetable] Use days as precision in day mode for accurate timetable syncing (#12683)
Co-authored-by: flowprint <61750128+flowprint@users.noreply.github.com>pull/13116/head
parent
6d3adc6169
commit
67a0fccfad
|
@ -4747,6 +4747,7 @@ STR_TIMETABLE_AND_TRAVEL_FOR_ESTIMATED :(travel for {ST
|
|||
STR_TIMETABLE_STAY_FOR :and stay for {STRING1}
|
||||
STR_TIMETABLE_AND_TRAVEL_FOR :and travel for {STRING1}
|
||||
|
||||
STR_TIMETABLE_APPROX_TIME :{BLACK}This timetable will take approximately {STRING1} to complete
|
||||
STR_TIMETABLE_TOTAL_TIME :{BLACK}This timetable will take {STRING1} to complete
|
||||
STR_TIMETABLE_TOTAL_TIME_INCOMPLETE :{BLACK}This timetable will take at least {STRING1} to complete (not all timetabled)
|
||||
|
||||
|
|
|
@ -519,7 +519,8 @@ void UpdateVehicleTimetable(Vehicle *v, bool travelling)
|
|||
/* Before modifying waiting times, check whether we want to preserve bigger ones. */
|
||||
if (!real_current_order->IsType(OT_CONDITIONAL) &&
|
||||
(travelling || time_taken > real_current_order->GetWaitTime() || remeasure_wait_time)) {
|
||||
/* Round up to the smallest unit of time commonly shown in the GUI (seconds) to avoid confusion.
|
||||
/* Round up to the unit currently shown in the GUI for days and seconds.
|
||||
* Round up to seconds if currently used display style is ticks.
|
||||
* Players timetabling in Ticks can adjust later.
|
||||
* For trains/aircraft multiple movement cycles are done in one
|
||||
* tick. This makes it possible to leave the station and process
|
||||
|
@ -527,7 +528,8 @@ void UpdateVehicleTimetable(Vehicle *v, bool travelling)
|
|||
* the timetable entry like is done for road vehicles/ships.
|
||||
* Thus always make sure at least one tick is used between the
|
||||
* processing of different orders when filling the timetable. */
|
||||
uint time_to_set = CeilDiv(std::max(time_taken, 1), Ticks::TICKS_PER_SECOND) * Ticks::TICKS_PER_SECOND;
|
||||
uint factor = _settings_client.gui.timetable_mode == TimetableMode::Days ? Ticks::DAY_TICKS : Ticks::TICKS_PER_SECOND;
|
||||
uint time_to_set = CeilDiv(std::max(time_taken, 1), factor) * factor;
|
||||
|
||||
if (travelling && (autofilling || !real_current_order->IsTravelTimetabled())) {
|
||||
ChangeTimetable(v, v->cur_real_order_index, time_to_set, MTF_TRAVEL_TIME, autofilling);
|
||||
|
|
|
@ -565,7 +565,13 @@ struct TimetableWindow : Window {
|
|||
TimerGameTick::Ticks total_time = v->orders != nullptr ? v->orders->GetTimetableDurationIncomplete() : 0;
|
||||
if (total_time != 0) {
|
||||
SetTimetableParams(0, 1, total_time);
|
||||
DrawString(tr, v->orders->IsCompleteTimetable() ? STR_TIMETABLE_TOTAL_TIME : STR_TIMETABLE_TOTAL_TIME_INCOMPLETE);
|
||||
if (!v->orders->IsCompleteTimetable()) {
|
||||
DrawString(tr, STR_TIMETABLE_TOTAL_TIME_INCOMPLETE);
|
||||
} else if (total_time % TicksPerTimetableUnit() == 0) {
|
||||
DrawString(tr, STR_TIMETABLE_TOTAL_TIME);
|
||||
} else {
|
||||
DrawString(tr, STR_TIMETABLE_APPROX_TIME);
|
||||
}
|
||||
}
|
||||
tr.top += GetCharacterHeight(FS_NORMAL);
|
||||
|
||||
|
|
Loading…
Reference in New Issue