OpenTTD Source 20241224-master-gf74b0cf984
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
24
25
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 */
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}
DepotPool _depot_pool("Depot")
All our depots tucked away in a pool.
Base for all depots (except hangars)
DepotID GetDepotIndex(Tile t)
Get the index of which depot is attached to the tile.
Definition depot_map.h:52
bool IsDepotTile(Tile tile)
Is the given tile a tile with a depot on it?
Definition depot_map.h:41
VehicleType GetDepotVehicleType(Tile t)
Get the type of vehicles that can use a depot.
Definition depot_map.h:65
Functions related to order backups.
void RemoveOrderFromAllVehicles(OrderType type, DestinationID destination, bool hangar)
Removes an order from all vehicles.
Functions related to orders.
Some methods of Pool are placed here in order to reduce compilation time and binary size.
#define INSTANTIATE_POOL_METHODS(name)
Force instantiation of pool methods so we don't get linker errors.
A number of safeguards to prevent using unsafe methods.
Definition of base types and functions in a cross-platform compatible way.
static void Reset(TileIndex tile=INVALID_TILE, bool from_gui=true)
Reset the OrderBackups from GUI/game logic.
Base class for all pools.
Definition pool_type.hpp:80
The information about a vehicle list.
Definition vehiclelist.h:28
Owner GetTileOwner(Tile tile)
Returns the owner of a tile.
Definition tile_map.h:178
Functions related to the vehicle's GUIs.
WindowClass GetWindowClassForVehicleType(VehicleType vt)
Get WindowClass for vehicle list of given vehicle type.
Definition vehicle_gui.h:97
VehicleType
Available vehicle types.
Functions and type for generating vehicle lists.
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:1140
Window functions not directly related to making/drawing windows.
@ WC_VEHICLE_DEPOT
Depot view; Window numbers: