diff options
Diffstat (limited to 'depot.h')
-rw-r--r-- | depot.h | 34 |
1 files changed, 31 insertions, 3 deletions
@@ -2,6 +2,7 @@ #define DEPOT_H #include "pool.h" +#include "tile.h" struct Depot { TileIndex xy; @@ -40,12 +41,39 @@ VARDEF TileIndex _last_built_road_depot_tile; VARDEF TileIndex _last_built_aircraft_depot_tile; VARDEF TileIndex _last_built_ship_depot_tile; -bool IsTrainDepotTile(TileIndex tile); -bool IsRoadDepotTile(TileIndex tile); +/** + * Check if a depot really exists. + */ +static inline bool IsValidDepot(Depot* depot) +{ + return depot->xy != 0; /* XXX: Replace by INVALID_TILE someday */ +} + +/** + * Check if a tile is a depot of the given type. + */ +static inline bool IsTileDepotType(TileIndex tile, TransportType type) +{ + switch(type) + { + case TRANSPORT_RAIL: + return IsTileType(tile, MP_RAILWAY) && (_map5[tile] & 0xFC) == 0xC0; + break; + case TRANSPORT_ROAD: + return IsTileType(tile, MP_STREET) && (_map5[tile] & 0xF0) == 0x20; + break; + case TRANSPORT_WATER: + return IsTileType(tile, MP_WATER) && (_map5[tile] & ~3) == 0x80; + break; + default: + assert(0); + return false; + } +} + Depot *GetDepotByTile(uint tile); void InitializeDepot(void); Depot *AllocateDepot(void); -bool IsShipDepotTile(TileIndex tile); void DoDeleteDepot(uint tile); #endif /* DEPOT_H */ |