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