depot.h
changeset 1330 8a67d04016ce
parent 1313 bba6afb8a995
child 1650 12a20779af79
equal deleted inserted replaced
1329:a8a0d60b0a8e 1330:8a67d04016ce
     1 #ifndef DEPOT_H
     1 #ifndef DEPOT_H
     2 #define DEPOT_H
     2 #define DEPOT_H
     3 
     3 
     4 #include "pool.h"
     4 #include "pool.h"
       
     5 #include "tile.h"
     5 
     6 
     6 struct Depot {
     7 struct Depot {
     7 	TileIndex xy;
     8 	TileIndex xy;
     8 	uint16 town_index;
     9 	uint16 town_index;
     9 	uint16 index;
    10 	uint16 index;
    38 VARDEF TileIndex _last_built_train_depot_tile;
    39 VARDEF TileIndex _last_built_train_depot_tile;
    39 VARDEF TileIndex _last_built_road_depot_tile;
    40 VARDEF TileIndex _last_built_road_depot_tile;
    40 VARDEF TileIndex _last_built_aircraft_depot_tile;
    41 VARDEF TileIndex _last_built_aircraft_depot_tile;
    41 VARDEF TileIndex _last_built_ship_depot_tile;
    42 VARDEF TileIndex _last_built_ship_depot_tile;
    42 
    43 
    43 bool IsTrainDepotTile(TileIndex tile);
    44 /**
    44 bool IsRoadDepotTile(TileIndex tile);
    45  * Check if a depot really exists.
       
    46  */
       
    47 static inline bool IsValidDepot(Depot* depot)
       
    48 {
       
    49 	return depot->xy != 0; /* XXX: Replace by INVALID_TILE someday */
       
    50 }
       
    51 
       
    52 /**
       
    53  * Check if a tile is a depot of the given type.
       
    54  */
       
    55 static inline bool IsTileDepotType(TileIndex tile, TransportType type)
       
    56 {
       
    57 	switch(type)
       
    58 	{
       
    59 		case TRANSPORT_RAIL:
       
    60 			return IsTileType(tile, MP_RAILWAY) && (_map5[tile] & 0xFC) == 0xC0;
       
    61 			break;
       
    62 		case TRANSPORT_ROAD:
       
    63 			return IsTileType(tile, MP_STREET) && (_map5[tile] & 0xF0) == 0x20;
       
    64 			break;
       
    65 		case TRANSPORT_WATER:
       
    66 			return IsTileType(tile, MP_WATER) && (_map5[tile] & ~3) == 0x80;
       
    67 			break;
       
    68 		default:
       
    69 			assert(0);
       
    70 			return false;
       
    71 	}
       
    72 }
       
    73 
    45 Depot *GetDepotByTile(uint tile);
    74 Depot *GetDepotByTile(uint tile);
    46 void InitializeDepot(void);
    75 void InitializeDepot(void);
    47 Depot *AllocateDepot(void);
    76 Depot *AllocateDepot(void);
    48 bool IsShipDepotTile(TileIndex tile);
       
    49 void DoDeleteDepot(uint tile);
    77 void DoDeleteDepot(uint tile);
    50 
    78 
    51 #endif /* DEPOT_H */
    79 #endif /* DEPOT_H */