2005-07-24 16:12:37 +02:00
|
|
|
/* $Id$ */
|
|
|
|
|
2008-05-06 17:11:33 +02:00
|
|
|
/** @file depot.cpp Handling of depots. */
|
2007-02-23 19:55:07 +01:00
|
|
|
|
2005-02-06 11:18:47 +01:00
|
|
|
#include "stdafx.h"
|
2008-04-17 21:10:30 +02:00
|
|
|
#include "depot_base.h"
|
2009-05-26 23:59:49 +02:00
|
|
|
#include "company_type.h"
|
2008-03-31 01:24:18 +02:00
|
|
|
#include "order_func.h"
|
2007-12-25 12:26:07 +01:00
|
|
|
#include "window_func.h"
|
2009-02-22 01:30:36 +01:00
|
|
|
#include "core/bitmath_func.hpp"
|
|
|
|
#include "tile_map.h"
|
|
|
|
#include "water_map.h"
|
2009-05-22 17:13:50 +02:00
|
|
|
#include "core/pool_func.hpp"
|
2005-02-06 11:18:47 +01:00
|
|
|
|
2009-05-22 17:13:50 +02:00
|
|
|
DepotPool _depot_pool("Depot");
|
|
|
|
INSTANTIATE_POOL_METHODS(Depot)
|
2005-02-06 11:18:47 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets a depot from a tile
|
2009-06-24 21:26:41 +02:00
|
|
|
* @param tile tile with depot
|
2005-02-06 11:18:47 +01:00
|
|
|
* @return Returns the depot if the tile had a depot, else it returns NULL
|
|
|
|
*/
|
2009-06-24 21:26:41 +02:00
|
|
|
/* static */ Depot *Depot::GetByTile(TileIndex tile)
|
2005-02-06 11:18:47 +01:00
|
|
|
{
|
2009-02-22 01:30:36 +01:00
|
|
|
/* A ship depot is multiple tiles. The north most tile is
|
|
|
|
* always the ->xy tile, so make sure we always look for
|
|
|
|
* the nothern tile and not the southern one. */
|
|
|
|
if (IsShipDepotTile(tile)) {
|
|
|
|
tile = min(tile, GetOtherShipDepotTile(tile));
|
|
|
|
}
|
|
|
|
|
2005-02-06 11:18:47 +01:00
|
|
|
Depot *depot;
|
|
|
|
|
|
|
|
FOR_ALL_DEPOTS(depot) {
|
2006-06-27 23:25:53 +02:00
|
|
|
if (depot->xy == tile) return depot;
|
2005-02-06 11:18:47 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2006-08-26 16:44:55 +02:00
|
|
|
* Clean up a depot
|
2005-02-06 11:18:47 +01:00
|
|
|
*/
|
2007-08-03 00:33:53 +02:00
|
|
|
Depot::~Depot()
|
2005-02-06 11:18:47 +01:00
|
|
|
{
|
2007-08-05 23:20:55 +02:00
|
|
|
if (CleaningPool()) return;
|
|
|
|
|
2005-02-06 11:18:47 +01:00
|
|
|
/* Clear the depot from all order-lists */
|
2007-08-03 00:33:53 +02:00
|
|
|
RemoveOrderFromAllVehicles(OT_GOTO_DEPOT, this->index);
|
2005-02-06 11:18:47 +01:00
|
|
|
|
|
|
|
/* Delete the depot-window */
|
2007-08-03 00:33:53 +02:00
|
|
|
DeleteWindowById(WC_VEHICLE_DEPOT, this->xy);
|
2005-02-06 11:18:47 +01:00
|
|
|
}
|
|
|
|
|
2007-03-07 12:47:46 +01:00
|
|
|
void InitializeDepots()
|
2005-02-06 11:18:47 +01:00
|
|
|
{
|
2009-05-22 17:13:50 +02:00
|
|
|
_depot_pool.CleanPool();
|
2005-02-06 11:18:47 +01:00
|
|
|
}
|