OpenTTD

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 }
VehicleListIdentifier
The information about a vehicle list.
Definition: vehiclelist.h:31
vehiclelist.h
Functions and type for generating vehicle lists.
WC_VEHICLE_DEPOT
Depot view; Window numbers:
Definition: window_type.h:346
depot_base.h
Base for all depots (except hangars)
order_func.h
Functions related to orders.
vehicle_gui.h
Functions related to the vehicle&#39;s GUIs.
pool_func.hpp
Some methods of Pool are placed here in order to reduce compilation time and binary size...
RemoveOrderFromAllVehicles
void RemoveOrderFromAllVehicles(OrderType type, DestinationID destination)
Removes an order from all vehicles.
Definition: order_cmd.cpp:1837
VehicleType
VehicleType
Available vehicle types.
Definition: vehicle_type.h:21
GetTileOwner
static Owner GetTileOwner(TileIndex tile)
Returns the owner of a tile.
Definition: tile_map.h:171
stdafx.h
Definition of base types and functions in a cross-platform compatible way.
safeguards.h
A number of safeguards to prevent using unsafe methods.
order_backup.h
Functions related to order backups.
GetDepotVehicleType
static VehicleType GetDepotVehicleType(TileIndex t)
Get the type of vehicles that can use a depot.
Definition: depot_map.h:67
GetDepotIndex
static DepotID GetDepotIndex(TileIndex t)
Get the index of which depot is attached to the tile.
Definition: depot_map.h:54
Pool
Base class for all pools.
Definition: pool_type.hpp:83
OrderBackup::Reset
static void Reset(TileIndex tile=INVALID_TILE, bool from_gui=true)
Reset the OrderBackups from GUI/game logic.
Definition: order_backup.cpp:190
INSTANTIATE_POOL_METHODS
#define INSTANTIATE_POOL_METHODS(name)
Force instantiation of pool methods so we don&#39;t get linker errors.
Definition: pool_func.hpp:224
DeleteWindowById
void DeleteWindowById(WindowClass cls, WindowNumber number, bool force)
Delete a window by its class and window number (if it is open).
Definition: window.cpp:1137
_depot_pool
DepotPool _depot_pool("Depot")
All our depots tucked away in a pool.
GetWindowClassForVehicleType
static WindowClass GetWindowClassForVehicleType(VehicleType vt)
Get WindowClass for vehicle list of given vehicle type.
Definition: vehicle_gui.h:85
window_func.h
Window functions not directly related to making/drawing windows.
IsDepotTile
static bool IsDepotTile(TileIndex tile)
Is the given tile a tile with a depot on it?
Definition: depot_map.h:43
Depot
Definition: depot_base.h:21