depot.h
changeset 4352 6703cd8d39e0
parent 4347 38fc1b161e89
child 4388 c8a66d26e146
equal deleted inserted replaced
4351:c9799dd53eec 4352:6703cd8d39e0
    33 static inline uint16 GetDepotPoolSize(void)
    33 static inline uint16 GetDepotPoolSize(void)
    34 {
    34 {
    35 	return _depot_pool.total_items;
    35 	return _depot_pool.total_items;
    36 }
    36 }
    37 
    37 
    38 static inline bool IsDepotIndex(uint index)
       
    39 {
       
    40 	return index < GetDepotPoolSize();
       
    41 }
       
    42 
       
    43 /**
    38 /**
    44  * Check if a depot really exists.
    39  * Check if a depot really exists.
    45  */
    40  */
    46 static inline bool IsValidDepot(const Depot* depot)
    41 static inline bool IsValidDepot(const Depot* depot)
    47 {
    42 {
    48 	return depot->xy != 0;
    43 	return depot->xy != 0;
       
    44 }
       
    45 
       
    46 static inline bool IsValidDepotID(uint index)
       
    47 {
       
    48 	return index < GetDepotPoolSize() && IsValidDepot(GetDepot(index));
    49 }
    49 }
    50 
    50 
    51 #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))
    51 #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))
    52 #define FOR_ALL_DEPOTS(d) FOR_ALL_DEPOTS_FROM(d, 0)
    52 #define FOR_ALL_DEPOTS(d) FOR_ALL_DEPOTS_FROM(d, 0)
    53 
    53