From 28bcf5bb46ca14161d746494da788b49b318dafb Mon Sep 17 00:00:00 2001 From: rubidium Date: Sat, 20 Oct 2007 20:15:34 +0000 Subject: [PATCH] (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 | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/roadveh_cmd.cpp b/src/roadveh_cmd.cpp index 7f7799bfbc..f24a990e6b 100644 --- a/src/roadveh_cmd.cpp +++ b/src/roadveh_cmd.cpp @@ -367,6 +367,8 @@ CommandCost CmdSellRoadVeh(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) 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 @@ CommandCost CmdSellRoadVeh(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) delete v; } - return CommandCost(-v->value); + return ret; } struct RoadFindDepotData {