(svn r6228) -Fix: redrawing an empty list of shared vehicles will now close the window
authorbjarni
Tue, 29 Aug 2006 22:47:38 +0000
changeset 4450 e5f39a854269
parent 4449 820974aaa4a6
child 4451 2e86da0081b5
(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
vehicle_gui.c
--- a/vehicle_gui.c	Tue Aug 29 21:36:39 2006 +0000
+++ b/vehicle_gui.c	Tue Aug 29 22:47:38 2006 +0000
@@ -1244,6 +1244,18 @@
 			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;