From c23ffb3a5cc91343a1b178f408625030542fa41d Mon Sep 17 00:00:00 2001 From: Jonathan G Rennison Date: Sat, 30 Jan 2016 15:19:46 +0000 Subject: [PATCH 1/3] Bump savegame version so that it is > trunk version. --- src/saveload/saveload.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/saveload/saveload.h b/src/saveload/saveload.h index 5df45f888f..349571a937 100644 --- a/src/saveload/saveload.h +++ b/src/saveload/saveload.h @@ -547,7 +547,7 @@ void NORETURN SlErrorCorrupt(const char *msg); bool SaveloadCrashWithMissingNewGRFs(); /* Hack to change savegame version in only one place. Rmv and correct if trunk. */ -const int TIMESEP_SV = 190; +const int TIMESEP_SV = 428; extern char _savegame_format[8]; extern bool _do_autosave; From 7c8b4b9d6d4f1fb3168fb98258e573387d686116 Mon Sep 17 00:00:00 2001 From: Jonathan G Rennison Date: Sat, 30 Jan 2016 15:07:33 +0000 Subject: [PATCH 2/3] Remove duplicated timetable fields from vehicle struct. --- src/vehicle_base.h | 7 ------- 1 file changed, 7 deletions(-) diff --git a/src/vehicle_base.h b/src/vehicle_base.h index 0b291be2d6..d6055e5610 100644 --- a/src/vehicle_base.h +++ b/src/vehicle_base.h @@ -188,12 +188,8 @@ public: CargoPayment *cargo_payment; ///< The cargo payment we're currently in - /* Used for timetabling. */ - uint32 current_order_time; ///< How many ticks have passed since this order started. uint32 current_loading_time; ///< How long loading took. Less than current_order_time if vehicle is early. - int32 lateness_counter; ///< How many ticks late (or early if negative) this vehicle is. - Date timetable_start; ///< When the vehicle is supposed to start the timetable. Rect coord; ///< NOSAVE: Graphical bounding box of the vehicle, i.e. what to redraw on moves. @@ -705,10 +701,7 @@ public: this->profit_this_year = src->profit_this_year; this->profit_last_year = src->profit_last_year; - this->current_order_time = src->current_order_time; this->current_loading_time = src->current_loading_time; - this->lateness_counter = src->lateness_counter; - this->timetable_start = src->timetable_start; if (HasBit(src->vehicle_flags, VF_TIMETABLE_STARTED)) SetBit(this->vehicle_flags, VF_TIMETABLE_STARTED); if (HasBit(src->vehicle_flags, VF_AUTOFILL_TIMETABLE)) SetBit(this->vehicle_flags, VF_AUTOFILL_TIMETABLE); From c877e1027296c1b02a99a7e2d95e666afb4e9983 Mon Sep 17 00:00:00 2001 From: Jonathan G Rennison Date: Sat, 30 Jan 2016 15:16:35 +0000 Subject: [PATCH 3/3] Avoid set distributed timetable start setting start dates in the past. Adjust start dates for vehicles before the base one forward by one timetable duration if they would start before the present date. Whitespace/format fixes. --- src/timetable_cmd.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) 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