diff options
author | frosch <frosch@openttd.org> | 2011-03-08 19:41:58 +0000 |
---|---|---|
committer | frosch <frosch@openttd.org> | 2011-03-08 19:41:58 +0000 |
commit | 9cf92e2bd250a0ff4fc3fa167057f1e79891d9ef (patch) | |
tree | 1bac62f70b166a9ad3d22353ccf08186f9c1925b /src | |
parent | 31f46c078615df78eefca7166d58e53dccdbf7b2 (diff) | |
download | openttd-9cf92e2bd250a0ff4fc3fa167057f1e79891d9ef.tar.xz |
(svn r22226) -Codechange: When autoreplace invalidates vehicle windows because the Vehicle index changed, use a better eye-catcher-'data' than 0 to identify them.
Diffstat (limited to 'src')
-rw-r--r-- | src/order_gui.cpp | 3 | ||||
-rw-r--r-- | src/timetable_gui.cpp | 3 | ||||
-rw-r--r-- | src/vehicle_gui.cpp | 24 |
3 files changed, 27 insertions, 3 deletions
diff --git a/src/order_gui.cpp b/src/order_gui.cpp index 6c40f9852..c4f4b7d9c 100644 --- a/src/order_gui.cpp +++ b/src/order_gui.cpp @@ -811,9 +811,10 @@ public: VehicleOrderID to = GB(data, 8, 8); switch (data) { - case 0: + case -666: /* Autoreplace replaced the vehicle */ this->vehicle = Vehicle::Get(this->window_number); + /* This case is _not_ called asynchronously. Get out directly, rest can be done later */ break; case -1: diff --git a/src/timetable_gui.cpp b/src/timetable_gui.cpp index dc807fe77..4f991323b 100644 --- a/src/timetable_gui.cpp +++ b/src/timetable_gui.cpp @@ -246,9 +246,10 @@ struct TimetableWindow : Window { virtual void OnInvalidateData(int data) { switch (data) { - case 0: + case -666: /* Autoreplace replaced the vehicle */ this->vehicle = Vehicle::Get(this->window_number); + /* This case is _not_ called asynchronously. Get out directly, rest can be done later */ break; case -1: diff --git a/src/vehicle_gui.cpp b/src/vehicle_gui.cpp index 6efbecf53..d8a69c04e 100644 --- a/src/vehicle_gui.cpp +++ b/src/vehicle_gui.cpp @@ -686,6 +686,12 @@ struct RefitWindow : public Window { virtual void OnInvalidateData(int data) { switch (data) { + case -666: + /* Autoreplace replaced the vehicle. + * Nothing to do though for this window. + * This case is _not_ called asynchronously. Get out directly, rest can be done later */ + break; + case 0: { // The consist has changed; rebuild the entire list. /* Clear the selection. */ Vehicle *v = Vehicle::Get(this->window_number); @@ -1121,7 +1127,7 @@ static inline void ChangeVehicleWindow(WindowClass window_class, VehicleID from_ } /* Notify the window immediately, without scheduling. */ - w->InvalidateData(); + w->InvalidateData(-666); } } @@ -1780,6 +1786,12 @@ struct VehicleDetailsWindow : Window { virtual void OnInvalidateData(int data) { + if (data == -666) { + /* Autoreplace replaced the vehicle. + * Nothing to do for this window though. + * This case is _not_ called asynchronously. Get out directly, rest can be done later */ + return; + } const Vehicle *v = Vehicle::Get(this->window_number); if (v->type == VEH_ROAD) { const NWidgetBase *nwid_info = this->GetWidget<NWidgetBase>(VLD_WIDGET_MIDDLE_DETAILS); @@ -2581,6 +2593,16 @@ public: } } + virtual void OnInvalidateData(int data) + { + if (data == -666) { + /* Autoreplace replaced the vehicle. + * Nothing to do for this window though. + * This case is _not_ called asynchronously. Get out directly, rest can be done later */ + return; + } + } + virtual bool IsNewGRFInspectable() const { return ::IsNewGRFInspectable(GetGrfSpecFeature(Vehicle::Get(this->window_number)->type), this->window_number); |