Mercurial > hg > openttd
changeset 17471:910342383bab draft
(svn r22226) -Codechange: When autoreplace invalidates vehicle windows because the Vehicle index changed, use a better eye-catcher-'data' than 0 to identify them.
author | frosch <frosch@openttd.org> |
---|---|
date | Tue, 08 Mar 2011 19:41:58 +0000 |
parents | e0bd49d166d1 |
children | 09afab037438 |
files | src/order_gui.cpp src/timetable_gui.cpp src/vehicle_gui.cpp |
diffstat | 3 files changed, 27 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/src/order_gui.cpp +++ b/src/order_gui.cpp @@ -811,9 +811,10 @@ 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:
--- a/src/timetable_gui.cpp +++ b/src/timetable_gui.cpp @@ -246,9 +246,10 @@ 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:
--- a/src/vehicle_gui.cpp +++ b/src/vehicle_gui.cpp @@ -686,6 +686,12 @@ 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 @@ } /* Notify the window immediately, without scheduling. */ - w->InvalidateData(); + w->InvalidateData(-666); } } @@ -1780,6 +1786,12 @@ 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 @@ } } + 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);