depot.h

Go to the documentation of this file.
00001 /* $Id: depot.h 12141 2008-02-14 15:59:16Z frosch $ */
00002 
00005 #ifndef DEPOT_H
00006 #define DEPOT_H
00007 
00008 #include "direction_type.h"
00009 #include "oldpool.h"
00010 #include "road_map.h"
00011 #include "rail_map.h"
00012 #include "water_map.h"
00013 #include "station_map.h"
00014 
00015 struct Depot;
00016 DECLARE_OLD_POOL(Depot, Depot, 3, 8000)
00017 
00018 struct Depot : PoolItem<Depot, DepotID, &_Depot_pool> {
00019   TileIndex xy;
00020   TownID town_index;
00021 
00022   Depot(TileIndex xy = 0) : xy(xy) {}
00023   ~Depot();
00024 
00025   inline bool IsValid() const { return this->xy != 0; }
00026 };
00027 
00028 static inline bool IsValidDepotID(DepotID index)
00029 {
00030   return index < GetDepotPoolSize() && GetDepot(index)->IsValid();
00031 }
00032 
00033 void ShowDepotWindow(TileIndex tile, VehicleType type);
00034 
00035 #define FOR_ALL_DEPOTS_FROM(d, start) for (d = GetDepot(start); d != NULL; d = (d->index + 1U < GetDepotPoolSize()) ? GetDepot(d->index + 1U) : NULL) if (d->IsValid())
00036 #define FOR_ALL_DEPOTS(d) FOR_ALL_DEPOTS_FROM(d, 0)
00037 
00041 static inline bool IsTileDepotType(TileIndex tile, TransportType type)
00042 {
00043   switch (type) {
00044     case TRANSPORT_RAIL:
00045       return IsTileType(tile, MP_RAILWAY) && GetRailTileType(tile)  == RAIL_TILE_DEPOT;
00046 
00047     case TRANSPORT_ROAD:
00048       return IsRoadDepotTile(tile);
00049 
00050     case TRANSPORT_WATER:
00051       return IsTileType(tile, MP_WATER)   && GetWaterTileType(tile) == WATER_TILE_DEPOT;
00052 
00053     default:
00054       NOT_REACHED();
00055       return false;
00056   }
00057 }
00058 
00064 static inline bool IsDepotTile(TileIndex tile)
00065 {
00066   switch (GetTileType(tile)) {
00067     case MP_ROAD:    return IsRoadDepot(tile);
00068     case MP_WATER:   return GetWaterTileType(tile) == WATER_TILE_DEPOT;
00069     case MP_RAILWAY: return GetRailTileType(tile)  == RAIL_TILE_DEPOT;
00070     case MP_STATION: return IsHangar(tile);
00071     default:         return false;
00072   }
00073 }
00074 
00090 static inline bool CanBuildDepotByTileh(DiagDirection direction, Slope tileh)
00091 {
00092   return ((0x4C >> direction) & tileh) != 0;
00093 }
00094 
00095 Depot *GetDepotByTile(TileIndex tile);
00096 void InitializeDepots();
00097 
00098 void DeleteDepotHighlightOfVehicle(const Vehicle *v);
00099 
00100 #endif /* DEPOT_H */

Generated on Wed Oct 1 17:03:20 2008 for openttd by  doxygen 1.5.6