(svn r7385) -Fix: FS#418 Deleting Train in depot with autoreplace failes
authorbjarni
Tue, 05 Dec 2006 22:40:42 +0000
changeset 5255 b8445fda3fe2
parent 5254 0cf8d2dcc848
child 5256 90226d8da8fb
(svn r7385) -Fix: FS#418 Deleting Train in depot with autoreplace failes
This turned out to be due to continue to drag the old vehicle, that autoreplace sold
This could also be triggered if more than one player used the same company
Now deleting a vehicle will remove all depot highlights of that vehicle
depot.h
depot_gui.c
vehicle.c
--- a/depot.h	Tue Dec 05 22:35:25 2006 +0000
+++ b/depot.h	Tue Dec 05 22:40:42 2006 +0000
@@ -107,4 +107,6 @@
 void InitializeDepots(void);
 Depot *AllocateDepot(void);
 
+void DeleteDepotHighlightOfVehicle(const Vehicle *v);
+
 #endif /* DEPOT_H */
--- a/depot_gui.c	Tue Dec 05 22:35:25 2006 +0000
+++ b/depot_gui.c	Tue Dec 05 22:40:42 2006 +0000
@@ -1033,3 +1033,21 @@
 		ResizeDepotButtons(w);
 	}
 }
+
+/** Removes the highlight of a vehicle in a depot window
+ * @param *v Vehicle to remove all highlights from
+ */
+void DeleteDepotHighlightOfVehicle(const Vehicle *v)
+{
+	Window* const *wz;
+
+	FOR_ALL_WINDOWS(wz) {
+		const Window *w = *wz;
+		if (w->window_class != WC_VEHICLE_DEPOT) continue;
+		if (w->window_number != v->tile) continue;
+		if (WP(w, depot_d).sel == v->index) {
+			WP(w, depot_d).sel = INVALID_VEHICLE;
+			ResetObjectToPlace();
+		}
+	}
+}
--- a/vehicle.c	Tue Dec 05 22:35:25 2006 +0000
+++ b/vehicle.c	Tue Dec 05 22:40:42 2006 +0000
@@ -566,6 +566,8 @@
 		InvalidateWindowData(WC_VEHICLE_DEPOT, v->tile);
 	}
 
+	DeleteDepotHighlightOfVehicle(v);
+
 	UpdateVehiclePosHash(v, INVALID_COORD, 0);
 	v->next_hash = INVALID_VEHICLE;
 	if (v->orders != NULL) DeleteVehicleOrders(v);