OpenTTD Source: src/depot.cpp Source File

OpenTTD Source 13.2.1

depot.cpp
Go to the documentation of this file.
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 */
7
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"
18
19 #include "safeguards.h"
20
22 DepotPool _depot_pool("Depot");
23 INSTANTIATE_POOL_METHODS(Depot)
24
25
28 Depot::~Depot()
29 {
30 if (CleaningPool()) return;
31
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;
35 }
36
37 /* Clear the order backup. */
38 OrderBackup::Reset(this->xy, false);
39
40 /* Clear the depot from all order-lists */
41 RemoveOrderFromAllVehicles(OT_GOTO_DEPOT, this->index);
42
43 /* Delete the depot-window */
44 CloseWindowById(WC_VEHICLE_DEPOT, this->xy);
45
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());
49 }
vehicle_gui.h
VehicleListIdentifier
The information about a vehicle list.
Definition: vehiclelist.h:29
vehiclelist.h
IsDepotTile
static bool IsDepotTile(TileIndex tile)
Is the given tile a tile with a depot on it?
Definition: depot_map.h:41
depot_base.h
safeguards.h
stdafx.h
VehicleType
VehicleType
Available vehicle types.
Definition: vehicle_type.h:21
OrderBackup::Reset
static void Reset(TileIndex tile=INVALID_TILE, bool from_gui=true)
Reset the OrderBackups from GUI/game logic.
Definition: order_backup.cpp:187
GetTileOwner
static Owner GetTileOwner(TileIndex tile)
Returns the owner of a tile.
Definition: tile_map.h:178
GetWindowClassForVehicleType
static WindowClass GetWindowClassForVehicleType(VehicleType vt)
Get WindowClass for vehicle list of given vehicle type.
Definition: vehicle_gui.h:96
Pool
Base class for all pools.
Definition: pool_type.hpp:81
RemoveOrderFromAllVehicles
void RemoveOrderFromAllVehicles(OrderType type, DestinationID destination, bool hangar)
Removes an order from all vehicles.
Definition: order_cmd.cpp:1765
WC_VEHICLE_DEPOT
@ WC_VEHICLE_DEPOT
Depot view; Window numbers:
Definition: window_type.h:344
_depot_pool
DepotPool _depot_pool("Depot")
All our depots tucked away in a pool.
INSTANTIATE_POOL_METHODS
#define INSTANTIATE_POOL_METHODS(name)
Force instantiation of pool methods so we don't get linker errors.
Definition: pool_func.hpp:224
window_func.h
Depot
Definition: depot_base.h:19
CloseWindowById
void CloseWindowById(WindowClass cls, WindowNumber number, bool force)
Close a window by its class and window number (if it is open).
Definition: window.cpp:1191
pool_func.hpp
order_backup.h
GetDepotIndex
static DepotID GetDepotIndex(TileIndex t)
Get the index of which depot is attached to the tile.
Definition: depot_map.h:52
order_func.h
GetDepotVehicleType
static VehicleType GetDepotVehicleType(TileIndex t)
Get the type of vehicles that can use a depot.
Definition: depot_map.h:65