Update readme and changelog for v1.26.0
[openttd-joker.git] / src / depot.cpp
blob1890faa87d9955520159a339f21cdebf6ade4285
1 /* $Id$ */
3 /*
4 * This file is part of OpenTTD.
5 * 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.
6 * 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.
7 * 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/>.
8 */
10 /** @file depot.cpp Handling of depots. */
12 #include "stdafx.h"
13 #include "depot_base.h"
14 #include "order_backup.h"
15 #include "order_func.h"
16 #include "window_func.h"
17 #include "core/pool_func.hpp"
18 #include "vehicle_gui.h"
19 #include "vehiclelist.h"
20 #include "tracerestrict.h"
22 #include "safeguards.h"
24 /** All our depots tucked away in a pool. */
25 DepotPool _depot_pool("Depot");
26 INSTANTIATE_POOL_METHODS(Depot)
28 /**
29 * Clean up a depot
31 Depot::~Depot()
33 if (CleaningPool()) return;
35 if (!IsDepotTile(this->xy) || GetDepotIndex(this->xy) != this->index) {
36 /* It can happen there is no depot here anymore (TTO/TTD savegames) */
37 return;
40 /* Clear the order backup. */
41 OrderBackup::Reset(this->xy, false);
43 /* Clear the depot from all order-lists */
44 RemoveOrderFromAllVehicles(OT_GOTO_DEPOT, this->index);
46 TraceRestrictRemoveDestinationID(TROCAF_DEPOT, this->index);
48 /* Delete the depot-window */
49 DeleteWindowById(WC_VEHICLE_DEPOT, this->xy);
51 /* Delete the depot list */
52 VehicleType vt = GetDepotVehicleType(this->xy);
53 DeleteWindowById(GetWindowClassForVehicleType(vt), VehicleListIdentifier(VL_DEPOT_LIST, vt, GetTileOwner(this->xy), this->index).Pack());