depot.h
changeset 4973 c671d5dd04bb
parent 4638 05955c6cb536
child 5081 fe3a6da19d9f
equal deleted inserted replaced
4972:c7f92c6b74e4 4973:c671d5dd04bb
    15 	TileIndex xy;
    15 	TileIndex xy;
    16 	TownID town_index;
    16 	TownID town_index;
    17 	DepotID index;
    17 	DepotID index;
    18 };
    18 };
    19 
    19 
    20 extern MemoryPool _depot_pool;
    20 DECLARE_POOL(Depot, Depot, 3, 8000);
    21 
       
    22 /**
       
    23  * Get the pointer to the depot with index 'index'
       
    24  */
       
    25 static inline Depot *GetDepot(DepotID index)
       
    26 {
       
    27 	return (Depot*)GetItemFromPool(&_depot_pool, index);
       
    28 }
       
    29 
       
    30 /**
       
    31  * Get the current size of the DepotPool
       
    32  */
       
    33 static inline uint16 GetDepotPoolSize(void)
       
    34 {
       
    35 	return _depot_pool.total_items;
       
    36 }
       
    37 
    21 
    38 /**
    22 /**
    39  * Check if a depot really exists.
    23  * Check if a depot really exists.
    40  */
    24  */
    41 static inline bool IsValidDepot(const Depot *depot)
    25 static inline bool IsValidDepot(const Depot *depot)
    56 	depot->xy = 0;
    40 	depot->xy = 0;
    57 }
    41 }
    58 
    42 
    59 void ShowDepotWindow(TileIndex tile, byte type);
    43 void ShowDepotWindow(TileIndex tile, byte type);
    60 
    44 
    61 #define FOR_ALL_DEPOTS_FROM(d, start) for (d = GetDepot(start); d != NULL; d = (d->index + 1 < GetDepotPoolSize()) ? GetDepot(d->index + 1) : NULL) if (IsValidDepot(d))
    45 #define FOR_ALL_DEPOTS_FROM(d, start) for (d = GetDepot(start); d != NULL; d = (d->index + 1U < GetDepotPoolSize()) ? GetDepot(d->index + 1U) : NULL) if (IsValidDepot(d))
    62 #define FOR_ALL_DEPOTS(d) FOR_ALL_DEPOTS_FROM(d, 0)
    46 #define FOR_ALL_DEPOTS(d) FOR_ALL_DEPOTS_FROM(d, 0)
    63 
    47 
    64 #define MIN_SERVINT_PERCENT  5
    48 #define MIN_SERVINT_PERCENT  5
    65 #define MAX_SERVINT_PERCENT 90
    49 #define MAX_SERVINT_PERCENT 90
    66 #define MIN_SERVINT_DAYS    30
    50 #define MIN_SERVINT_DAYS    30