00001 /* $Id$ */ 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 #include "road_map.h" 00021 #include "rail_map.h" 00022 #include "water_map.h" 00023 #include "station_map.h" 00024 #include "depot_map.h" 00025 00027 DepotPool _depot_pool("Depot"); 00028 INSTANTIATE_POOL_METHODS(Depot) 00029 00030 00033 DiagDirection GetDepotDirection(TileIndex tile, TransportType type) 00034 { 00035 assert(IsDepotTypeTile(tile, type)); 00036 00037 switch (type) { 00038 case TRANSPORT_RAIL: return GetRailDepotDirection(tile); 00039 case TRANSPORT_ROAD: return GetRoadDepotDirection(tile); 00040 case TRANSPORT_WATER: return GetShipDepotDirection(tile); 00041 default: return INVALID_DIAGDIR; /* Not reached */ 00042 } 00043 } 00044 00048 Depot::~Depot() 00049 { 00050 if (CleaningPool()) return; 00051 00052 if (!IsDepotTile(this->xy) || GetDepotIndex(this->xy) != this->index) { 00053 /* It can happen there is no depot here anymore (TTO/TTD savegames) */ 00054 return; 00055 } 00056 00057 /* Clear the order backup. */ 00058 OrderBackup::Reset(this->xy, false); 00059 00060 /* Clear the depot from all order-lists */ 00061 RemoveOrderFromAllVehicles(OT_GOTO_DEPOT, this->index); 00062 00063 /* Delete the depot-window */ 00064 DeleteWindowById(WC_VEHICLE_DEPOT, this->xy); 00065 00066 /* Delete the depot list */ 00067 VehicleType vt; 00068 switch (GetTileType(this->xy)) { 00069 default: NOT_REACHED(); 00070 case MP_RAILWAY: vt = VEH_TRAIN; break; 00071 case MP_ROAD: vt = VEH_ROAD; break; 00072 case MP_WATER: vt = VEH_SHIP; break; 00073 } 00074 DeleteWindowById(GetWindowClassForVehicleType(vt), VehicleListIdentifier(VL_DEPOT_LIST, vt, GetTileOwner(this->xy), this->index).Pack()); 00075 }