diff --git a/src/timetable_cmd.cpp b/src/timetable_cmd.cpp index 5c2849bc24..7e35a71455 100644 --- a/src/timetable_cmd.cpp +++ b/src/timetable_cmd.cpp @@ -314,6 +314,9 @@ CommandCost CmdSetTimetableStart(TileIndex tile, DoCommandFlag flags, uint32 p1, ClrBit(w->vehicle_flags, VF_TIMETABLE_STARTED); /* Do multiplication, then division to reduce rounding errors. */ w->timetable_start = start_date + idx * total_duration / num_vehs / DAY_TICKS; + if (w->timetable_start < _date && idx < 0) { + w->timetable_start += (total_duration / DAY_TICKS); + } SetWindowDirty(WC_VEHICLE_TIMETABLE, w->index); } @@ -693,14 +696,16 @@ void UpdateVehicleTimetable(Vehicle *v, bool travelling) } if (new_time < 1) new_time = 1; - if (new_time != (int32)timetabled) + if (new_time != (int32)timetabled) { ChangeTimetable(v, v->cur_real_order_index, new_time, travelling ? MTF_TRAVEL_TIME : MTF_WAIT_TIME, true); + } } else if (timetabled == 0 && HasBit(v->vehicle_flags, VF_AUTOMATE_TIMETABLE)) { /* Add times for orders that are not yet timetabled, even while not autofilling */ - if (travelling) - ChangeTimetable(v, v->cur_real_order_index, time_taken, travelling ? MTF_TRAVEL_TIME : MTF_WAIT_TIME, true); - else - ChangeTimetable(v, v->cur_real_order_index, time_loading, travelling ? MTF_TRAVEL_TIME : MTF_WAIT_TIME, true); + if (travelling) { + ChangeTimetable(v, v->cur_real_order_index, time_taken, MTF_TRAVEL_TIME, true); + } else { + ChangeTimetable(v, v->cur_real_order_index, time_loading, MTF_WAIT_TIME, true); + } } /* Vehicles will wait at stations if they arrive early even if they are not