summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbjarni <bjarni@openttd.org>2006-08-29 22:47:38 +0000
committerbjarni <bjarni@openttd.org>2006-08-29 22:47:38 +0000
commitb85a5d8cc87187345707cbe3c47dbb5a4ef8de27 (patch)
tree39e44fc3961b5ef8b8f6afac2de940cd4b02de2c
parenta73b07561e30e45ba94504d6e7c47cf157ab07c8 (diff)
downloadopenttd-b85a5d8cc87187345707cbe3c47dbb5a4ef8de27.tar.xz
(svn r6228) -Fix: redrawing an empty list of shared vehicles will now close the window
Since the order is no more, the player will not need that particular window anymore this could happen if the player opened the window and then sold all the vehicles (or crashed them) A crash could happen if a new order gets the same (now freed) OrderID and the vehicle using it is not of the same type as the window expect
-rw-r--r--vehicle_gui.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/vehicle_gui.c b/vehicle_gui.c
index 1f5ee5b05..1d7cfcc2b 100644
--- a/vehicle_gui.c
+++ b/vehicle_gui.c
@@ -1244,6 +1244,18 @@ void PlayerVehWndProc(Window *w, WindowEvent *e)
switch (window_type) {
case VLW_SHARED_ORDERS:
/* Shared Orders */
+ if (vl->list_length == 0) {
+ /* The list is empty, so the last vehicle is sold or crashed */
+ /* Delete the window because the order is now not in use anymore */
+ switch (vehicle_type) {
+ case VEH_Train: DeleteWindowById(WC_TRAINS_LIST, w->window_number); break;
+ case VEH_Road: DeleteWindowById(WC_ROADVEH_LIST, w->window_number); break;
+ case VEH_Ship: DeleteWindowById(WC_SHIPS_LIST, w->window_number); break;
+ case VEH_Aircraft: DeleteWindowById(WC_AIRCRAFT_LIST, w->window_number); break;
+ default: NOT_REACHED(); break;
+ }
+ return;
+ }
SetDParam(0, w->vscroll.count);
w->widget[1].unkA = STR_VEH_WITH_SHARED_ORDERS_LIST;
w->widget[9].unkA = STR_EMPTY;