Change: Let AI developers edit non-editable AI/Game Script Parameters (#8895)
[openttd-github.git] / src / depot.cpp
blob13317e8a35dadbd402d29c595a0f796c0f3e8284
1 /*
2 * This file is part of OpenTTD.
3 * 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.
4 * 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.
5 * 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/>.
6 */
8 /** @file depot.cpp Handling of depots. */
10 #include "stdafx.h"
11 #include "depot_base.h"
12 #include "order_backup.h"
13 #include "order_func.h"
14 #include "window_func.h"
15 #include "core/pool_func.hpp"
16 #include "vehicle_gui.h"
17 #include "vehiclelist.h"
19 #include "safeguards.h"
21 /** All our depots tucked away in a pool. */
22 DepotPool _depot_pool("Depot");
23 INSTANTIATE_POOL_METHODS(Depot)
25 /**
26 * Clean up a depot
28 Depot::~Depot()
30 if (CleaningPool()) return;
32 if (!IsDepotTile(this->xy) || GetDepotIndex(this->xy) != this->index) {
33 /* It can happen there is no depot here anymore (TTO/TTD savegames) */
34 return;
37 /* Clear the order backup. */
38 OrderBackup::Reset(this->xy, false);
40 /* Clear the depot from all order-lists */
41 RemoveOrderFromAllVehicles(OT_GOTO_DEPOT, this->index);
43 /* Delete the depot-window */
44 CloseWindowById(WC_VEHICLE_DEPOT, this->xy);
46 /* Delete the depot list */
47 VehicleType vt = GetDepotVehicleType(this->xy);
48 CloseWindowById(GetWindowClassForVehicleType(vt), VehicleListIdentifier(VL_DEPOT_LIST, vt, GetTileOwner(this->xy), this->index).Pack());