(svn r11317) -Fix [FS#1355]: don't read a variable of a destroyed vehicle as the value will be reset to 0.
authorrubidium
Sat, 20 Oct 2007 20:15:34 +0000
changeset 7768 0ba14389a50e
parent 7767 9866e9700e62
child 7769 f072d6bb8b99
(svn r11317) -Fix [FS#1355]: don't read a variable of a destroyed vehicle as the value will be reset to 0.
src/roadveh_cmd.cpp
--- a/src/roadveh_cmd.cpp	Sat Oct 20 20:06:55 2007 +0000
+++ b/src/roadveh_cmd.cpp	Sat Oct 20 20:15:34 2007 +0000
@@ -367,6 +367,8 @@
 		return_cmd_error(STR_9013_MUST_BE_STOPPED_INSIDE);
 	}
 
+	CommandCost ret(-v->value);
+
 	if (flags & DC_EXEC) {
 		// Invalidate depot
 		InvalidateWindow(WC_VEHICLE_DEPOT, v->tile);
@@ -377,7 +379,7 @@
 		delete v;
 	}
 
-	return CommandCost(-v->value);
+	return ret;
 }
 
 struct RoadFindDepotData {