2009-08-21 20:21:05 +00:00
|
|
|
/*
|
|
|
|
* This file is part of OpenTTD.
|
|
|
|
* 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.
|
|
|
|
* 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.
|
|
|
|
* 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/>.
|
|
|
|
*/
|
|
|
|
|
2008-05-06 15:11:33 +00:00
|
|
|
/** @file depot.cpp Handling of depots. */
|
2007-02-23 18:55:07 +00:00
|
|
|
|
2005-02-06 10:18:47 +00:00
|
|
|
#include "stdafx.h"
|
2008-04-17 19:10:30 +00:00
|
|
|
#include "depot_base.h"
|
2010-08-18 18:52:16 +00:00
|
|
|
#include "order_backup.h"
|
2008-03-30 23:24:18 +00:00
|
|
|
#include "order_func.h"
|
2007-12-25 11:26:07 +00:00
|
|
|
#include "window_func.h"
|
2009-05-22 15:13:50 +00:00
|
|
|
#include "core/pool_func.hpp"
|
2009-09-07 08:05:35 +00:00
|
|
|
#include "vehicle_gui.h"
|
2010-09-08 21:37:13 +00:00
|
|
|
#include "vehiclelist.h"
|
2015-07-24 00:21:31 +00:00
|
|
|
#include "tracerestrict.h"
|
2005-02-06 10:18:47 +00:00
|
|
|
|
2014-04-23 20:13:33 +00:00
|
|
|
#include "safeguards.h"
|
|
|
|
|
2011-05-02 17:42:12 +00:00
|
|
|
/** All our depots tucked away in a pool. */
|
2009-05-22 15:13:50 +00:00
|
|
|
DepotPool _depot_pool("Depot");
|
|
|
|
INSTANTIATE_POOL_METHODS(Depot)
|
2005-02-06 10:18:47 +00:00
|
|
|
|
|
|
|
/**
|
2006-08-26 14:44:55 +00:00
|
|
|
* Clean up a depot
|
2005-02-06 10:18:47 +00:00
|
|
|
*/
|
2007-08-02 22:33:53 +00:00
|
|
|
Depot::~Depot()
|
2005-02-06 10:18:47 +00:00
|
|
|
{
|
2007-08-05 21:20:55 +00:00
|
|
|
if (CleaningPool()) return;
|
|
|
|
|
2011-02-02 14:50:57 +00:00
|
|
|
if (!IsDepotTile(this->xy) || GetDepotIndex(this->xy) != this->index) {
|
|
|
|
/* It can happen there is no depot here anymore (TTO/TTD savegames) */
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2010-08-18 20:48:38 +00:00
|
|
|
/* Clear the order backup. */
|
|
|
|
OrderBackup::Reset(this->xy, false);
|
|
|
|
|
2005-02-06 10:18:47 +00:00
|
|
|
/* Clear the depot from all order-lists */
|
2007-08-02 22:33:53 +00:00
|
|
|
RemoveOrderFromAllVehicles(OT_GOTO_DEPOT, this->index);
|
2005-02-06 10:18:47 +00:00
|
|
|
|
2015-07-24 00:21:31 +00:00
|
|
|
TraceRestrictRemoveDestinationID(TROCAF_DEPOT, this->index);
|
|
|
|
|
2005-02-06 10:18:47 +00:00
|
|
|
/* Delete the depot-window */
|
2007-08-02 22:33:53 +00:00
|
|
|
DeleteWindowById(WC_VEHICLE_DEPOT, this->xy);
|
2009-09-07 08:05:35 +00:00
|
|
|
|
|
|
|
/* Delete the depot list */
|
2013-10-13 20:11:05 +00:00
|
|
|
VehicleType vt = GetDepotVehicleType(this->xy);
|
2010-09-08 21:37:13 +00:00
|
|
|
DeleteWindowById(GetWindowClassForVehicleType(vt), VehicleListIdentifier(VL_DEPOT_LIST, vt, GetTileOwner(this->xy), this->index).Pack());
|
2005-02-06 10:18:47 +00:00
|
|
|
}
|