OpenTTD: src/depot.cpp Source File

OpenTTD

- Main Page
- Related Pages
- Modules
- Namespaces
- Data Structures
- Files

- File List
- Globals

depot.cpp
Go to the documentation of this file.
1 /* $Id: depot.cpp 26482 2014-04-23 20:13:33Z rubidium $ */
2
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 */
9
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
21 #include "safeguards.h"
22
24 DepotPool _depot_pool("Depot");
25 INSTANTIATE_POOL_METHODS(Depot)
26
27
30 Depot::~Depot()
31 {
32 if (CleaningPool()) return;
33
34 if (!IsDepotTile(this->xy) || GetDepotIndex(this->xy) != this->index) {
35 /* It can happen there is no depot here anymore (TTO/TTD savegames) */
36 return;
37 }
38
39 /* Clear the order backup. */
40 OrderBackup::Reset(this->xy, false);
41
42 /* Clear the depot from all order-lists */
43 RemoveOrderFromAllVehicles(OT_GOTO_DEPOT, this->index);
44
45 /* Delete the depot-window */
46 DeleteWindowById(WC_VEHICLE_DEPOT, this->xy);
47
48 /* Delete the depot list */
49 VehicleType vt = GetDepotVehicleType(this->xy);
50 DeleteWindowById(GetWindowClassForVehicleType(vt), VehicleListIdentifier(VL_DEPOT_LIST, vt, GetTileOwner(this->xy), this->index).Pack());
51 }