# depot.cpp

Go to the documentation of this file.

    00001 /* $Id: depot.cpp 15551 2009-02-22 00:30:36Z rubidium $ */
    00002
    00005 #include "stdafx.h"
    00006 #include "depot_base.h"
    00007 #include "order_func.h"
    00008 #include "window_func.h"
    00009 #include "oldpool_func.h"
    00010 #include "core/bitmath_func.hpp"
    00011 #include "tile_map.h"
    00012 #include "water_map.h"
    00013
    00014 DEFINE_OLD_POOL_GENERIC(Depot, Depot)
    00015
    00016
    00021 Depot *GetDepotByTile(TileIndex tile)
    00022 {
    00023   /* A ship depot is multiple tiles. The north most tile is
    00024    * always the ->xy tile, so make sure we always look for
    00025    * the nothern tile and not the southern one. */
    00026   if (IsShipDepotTile(tile)) {
    00027     tile = min(tile, GetOtherShipDepotTile(tile));
    00028   }
    00029
    00030   Depot *depot;
    00031
    00032   FOR_ALL_DEPOTS(depot) {
    00033     if (depot->xy == tile) return depot;
    00034   }
    00035
    00036   return NULL;
    00037 }
    00038
    00042 Depot::~Depot()
    00043 {
    00044   if (CleaningPool()) return;
    00045
    00046   /* Clear the depot from all order-lists */
    00047   RemoveOrderFromAllVehicles(OT_GOTO_DEPOT, this->index);
    00048
    00049   /* Delete the depot-window */
    00050   DeleteWindowById(WC_VEHICLE_DEPOT, this->xy);
    00051   this->xy = INVALID_TILE;
    00052 }
    00053
    00054 void InitializeDepots()
    00055 {
    00056   _Depot_pool.CleanPool();
    00057   _Depot_pool.AddBlockToPool();
    00058 }