(svn r11314) -Fix [FS#1356]: stop following a vehicle when you sell/destroyed it.
authorrubidium
Sat, 20 Oct 2007 17:11:02 +0000
changeset 8261 ed2ea3ac3edc
parent 8260 c7d75cebe3f6
child 8262 b3865f8f7aba
(svn r11314) -Fix [FS#1356]: stop following a vehicle when you sell/destroyed it.
src/vehicle.cpp
--- a/src/vehicle.cpp	Sat Oct 20 16:50:48 2007 +0000
+++ b/src/vehicle.cpp	Sat Oct 20 17:11:02 2007 +0000
@@ -529,6 +529,14 @@
 	if ((this->type == VEH_TRAIN && EngineHasArticPart(this)) || (this->type == VEH_ROAD && RoadVehHasArticPart(this))) {
 		delete this->Next();
 	}
+
+	Window **wp;
+	FOR_ALL_WINDOWS(wp) {
+		Window *w = *wp;
+		if (w->viewport != NULL && WP(w, vp_d).follow_vehicle == this->index) {
+			WP(w, vp_d).follow_vehicle = INVALID_VEHICLE;
+		}
+	}
 }
 
 Vehicle::~Vehicle()