summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbjarni <bjarni@openttd.org>2006-10-05 08:27:40 +0000
committerbjarni <bjarni@openttd.org>2006-10-05 08:27:40 +0000
commitb39aefba4fa141cc555aa714c9e2b8a77e91c2cd (patch)
tree226a76bc9c6a0a5fdfa3a29b63adf1e5672217e8
parentb0cc6f40225838bbb1663635e85416a830343e70 (diff)
downloadopenttd-b39aefba4fa141cc555aa714c9e2b8a77e91c2cd.tar.xz
(svn r6647) -Fix: [vehicle list windows] Lists of shared orders are now no longer closed by a window event if the list is empty
The window is now closed when the order is deleted. This is because removing windows from a window event is asking for problems
-rw-r--r--order_cmd.c16
-rw-r--r--vehicle_gui.c7
2 files changed, 18 insertions, 5 deletions
diff --git a/order_cmd.c b/order_cmd.c
index b87fb6879..c0bcc343b 100644
--- a/order_cmd.c
+++ b/order_cmd.c
@@ -1124,7 +1124,21 @@ void DeleteVehicleOrders(Vehicle *v)
v->orders = NULL;
v->num_orders = 0;
- while (cur != NULL) {
+ if (cur != NULL) {
+ /* Delete the vehicle list of shared orders, if any */
+ int window_type = 0;
+
+ switch (v->type) {
+ case VEH_Train: window_type = WC_TRAINS_LIST; break;
+ case VEH_Road: window_type = WC_ROADVEH_LIST; break;
+ case VEH_Ship: window_type = WC_SHIPS_LIST; break;
+ case VEH_Aircraft: window_type = WC_AIRCRAFT_LIST; break;
+ default: NOT_REACHED();
+ }
+ DeleteWindowById(window_type, (cur->index << 16) | (v->type << 11) | VLW_SHARED_ORDERS | v->owner);
+ }
+
+ while (cur != NULL) {
next = cur->next;
DeleteOrder(cur);
cur = next;
diff --git a/vehicle_gui.c b/vehicle_gui.c
index 0af603411..d7d1992c8 100644
--- a/vehicle_gui.c
+++ b/vehicle_gui.c
@@ -1553,10 +1553,9 @@ static void DrawVehicleListWindow(Window *w)
switch (window_type) {
case VLW_SHARED_ORDERS: /* Shared Orders */
if (vl->l.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 */
- DeleteWindow(w);
- return;
+ /* We can't open this window without vehicles using this order
+ * and we should close the window when deleting the order */
+ NOT_REACHED();
}
SetDParam(0, w->vscroll.count);
break;