summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2009-09-07 08:05:35 +0000
committerrubidium <rubidium@openttd.org>2009-09-07 08:05:35 +0000
commit6593e4490a4175e3b533e6686a4d1e4131668b9e (patch)
treec65860d8d29dc86d645e7c917689f8cd561ea3f2
parentad70d2463425695418d90dec3888b306e2fab930 (diff)
downloadopenttd-6593e4490a4175e3b533e6686a4d1e4131668b9e.tar.xz
(svn r17442) -Fix [FS#3180]: destruction of depots didn't remove any vehicle lists related to the depot, causing windows pointing to deleted depots and (thus) crashes
-rw-r--r--src/depot.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/depot.cpp b/src/depot.cpp
index fe8635586..8bfe52a3e 100644
--- a/src/depot.cpp
+++ b/src/depot.cpp
@@ -18,6 +18,7 @@
#include "tile_map.h"
#include "water_map.h"
#include "core/pool_func.hpp"
+#include "vehicle_gui.h"
DepotPool _depot_pool("Depot");
INSTANTIATE_POOL_METHODS(Depot)
@@ -57,6 +58,15 @@ Depot::~Depot()
/* Delete the depot-window */
DeleteWindowById(WC_VEHICLE_DEPOT, this->xy);
+
+ /* Delete the depot list */
+ WindowNumber wno = (this->index << 16) | VLW_DEPOT_LIST | GetTileOwner(this->xy);
+ switch (GetTileType(this->xy)) {
+ default: NOT_REACHED();
+ case MP_RAILWAY: DeleteWindowById(WC_TRAINS_LIST, wno | (VEH_TRAIN << 11)); break;
+ case MP_ROAD: DeleteWindowById(WC_ROADVEH_LIST, wno | (VEH_ROAD << 11)); break;
+ case MP_WATER: DeleteWindowById(WC_SHIPS_LIST, wno | (VEH_SHIP << 11)); break;
+ }
}
void InitializeDepots()