00001 /* $Id: depot.cpp 22411 2011-05-02 17:42:12Z rubidium $ */ 00002 00003 /* 00004 * This file is part of OpenTTD. 00005 * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2. 00006 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 00007 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>. 00008 */ 00009 00012 #include "stdafx.h" 00013 #include "depot_base.h" 00014 #include "order_backup.h" 00015 #include "order_func.h" 00016 #include "window_func.h" 00017 #include "core/pool_func.hpp" 00018 #include "vehicle_gui.h" 00019 #include "vehiclelist.h" 00020 00022 DepotPool _depot_pool("Depot"); 00023 INSTANTIATE_POOL_METHODS(Depot) 00024 00025 00028 Depot::~Depot() 00029 { 00030 if (CleaningPool()) return; 00031 00032 if (!IsDepotTile(this->xy) || GetDepotIndex(this->xy) != this->index) { 00033 /* It can happen there is no depot here anymore (TTO/TTD savegames) */ 00034 return; 00035 } 00036 00037 /* Clear the order backup. */ 00038 OrderBackup::Reset(this->xy, false); 00039 00040 /* Clear the depot from all order-lists */ 00041 RemoveOrderFromAllVehicles(OT_GOTO_DEPOT, this->index); 00042 00043 /* Delete the depot-window */ 00044 DeleteWindowById(WC_VEHICLE_DEPOT, this->xy); 00045 00046 /* Delete the depot list */ 00047 VehicleType vt; 00048 switch (GetTileType(this->xy)) { 00049 default: NOT_REACHED(); 00050 case MP_RAILWAY: vt = VEH_TRAIN; break; 00051 case MP_ROAD: vt = VEH_ROAD; break; 00052 case MP_WATER: vt = VEH_SHIP; break; 00053 } 00054 DeleteWindowById(GetWindowClassForVehicleType(vt), VehicleListIdentifier(VL_DEPOT_LIST, vt, GetTileOwner(this->xy), this->index).Pack()); 00055 }