2005-07-24 14:12:37 +00:00
|
|
|
/* $Id$ */
|
|
|
|
|
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"
|
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"
|
2005-02-06 10:18:47 +00:00
|
|
|
|
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;
|
|
|
|
|
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
|
|
|
|
|
|
|
/* 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 */
|
|
|
|
WindowNumber wno = (this->index << 16) | VLW_DEPOT_LIST | GetTileOwner(this->xy);
|
|
|
|
switch (GetTileType(this->xy)) {
|
2009-09-07 12:08:43 +00:00
|
|
|
default: break; // It can happen there is no depot here anymore (TTO/TTD savegames)
|
2009-09-07 08:05:35 +00:00
|
|
|
case MP_RAILWAY: DeleteWindowById(WC_TRAINS_LIST, wno | (VEH_TRAIN << 11)); break;
|
|
|
|
case MP_ROAD: DeleteWindowById(WC_ROADVEH_LIST, wno | (VEH_ROAD << 11)); break;
|
|
|
|
case MP_WATER: DeleteWindowById(WC_SHIPS_LIST, wno | (VEH_SHIP << 11)); break;
|
|
|
|
}
|
2005-02-06 10:18:47 +00:00
|
|
|
}
|
|
|
|
|
2007-03-07 11:47:46 +00:00
|
|
|
void InitializeDepots()
|
2005-02-06 10:18:47 +00:00
|
|
|
{
|
2009-05-22 15:13:50 +00:00
|
|
|
_depot_pool.CleanPool();
|
2005-02-06 10:18:47 +00:00
|
|
|
}
|