OpenTTD Source: src/depot.cpp Source File

OpenTTD Source 15.0-RC2

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 <https://www.gnu.org/licenses/old-licenses/gpl-2.0>.
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).ToWindowNumber());
49}
_depot_pool
DepotPool _depot_pool("Depot")
All our depots tucked away in a pool.
depot_base.h
Base for all depots (except hangars)
GetDepotIndex
DepotID GetDepotIndex(Tile t)
Get the index of which depot is attached to the tile.
Definition depot_map.h:53
IsDepotTile
bool IsDepotTile(Tile tile)
Is the given tile a tile with a depot on it?
Definition depot_map.h:42
GetDepotVehicleType
VehicleType GetDepotVehicleType(Tile t)
Get the type of vehicles that can use a depot.
Definition depot_map.h:78
order_backup.h
Functions related to order backups.
RemoveOrderFromAllVehicles
void RemoveOrderFromAllVehicles(OrderType type, DestinationID destination, bool hangar)
Removes an order from all vehicles.
Definition order_cmd.cpp:1753
order_func.h
Functions related to orders.
pool_func.hpp
Some methods of Pool are placed here in order to reduce compilation time and binary size.
INSTANTIATE_POOL_METHODS
#define INSTANTIATE_POOL_METHODS(name)
Force instantiation of pool methods so we don't get linker errors.
Definition pool_func.hpp:210
safeguards.h
A number of safeguards to prevent using unsafe methods.
stdafx.h
Definition of base types and functions in a cross-platform compatible way.
Depot
Definition depot_base.h:20
OrderBackup::Reset
static void Reset(TileIndex tile=INVALID_TILE, bool from_gui=true)
Reset the OrderBackups from GUI/game logic.
Definition order_backup.cpp:165
Pool
Base class for all pools.
Definition pool_type.hpp:133
VehicleListIdentifier
The information about a vehicle list.
Definition vehiclelist.h:32
GetTileOwner
Owner GetTileOwner(Tile tile)
Returns the owner of a tile.
Definition tile_map.h:178
vehicle_gui.h
Functions related to the vehicle's GUIs.
GetWindowClassForVehicleType
WindowClass GetWindowClassForVehicleType(VehicleType vt)
Get WindowClass for vehicle list of given vehicle type.
Definition vehicle_gui.h:97
VehicleType
VehicleType
Available vehicle types.
Definition vehicle_type.h:22
vehiclelist.h
Functions and type for generating vehicle lists.
VL_DEPOT_LIST
@ VL_DEPOT_LIST
Index is the destination (station for hangar of aircraft, depot for others)
Definition vehiclelist.h:26
CloseWindowById
void CloseWindowById(WindowClass cls, WindowNumber number, bool force, int data)
Close a window by its class and window number (if it is open).
Definition window.cpp:1193
window_func.h
Window functions not directly related to making/drawing windows.
WC_VEHICLE_DEPOT
@ WC_VEHICLE_DEPOT
Depot view; Window numbers:
Definition window_type.h:356