depot.h
changeset 4346 66105d4f6e83
parent 4297 d0311b62255c
child 4347 38fc1b161e89
equal deleted inserted replaced
4345:1da147230c79 4346:66105d4f6e83
    38 static inline bool IsDepotIndex(uint index)
    38 static inline bool IsDepotIndex(uint index)
    39 {
    39 {
    40 	return index < GetDepotPoolSize();
    40 	return index < GetDepotPoolSize();
    41 }
    41 }
    42 
    42 
    43 #define FOR_ALL_DEPOTS_FROM(d, start) for (d = GetDepot(start); d != NULL; d = (d->index + 1 < GetDepotPoolSize()) ? GetDepot(d->index + 1) : NULL)
    43 /**
       
    44  * Check if a depot really exists.
       
    45  */
       
    46 static inline bool IsValidDepot(const Depot* depot)
       
    47 {
       
    48 	return depot->xy != 0;
       
    49 }
       
    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))
    44 #define FOR_ALL_DEPOTS(d) FOR_ALL_DEPOTS_FROM(d, 0)
    52 #define FOR_ALL_DEPOTS(d) FOR_ALL_DEPOTS_FROM(d, 0)
    45 
    53 
    46 #define MIN_SERVINT_PERCENT  5
    54 #define MIN_SERVINT_PERCENT  5
    47 #define MAX_SERVINT_PERCENT 90
    55 #define MAX_SERVINT_PERCENT 90
    48 #define MIN_SERVINT_DAYS    30
    56 #define MIN_SERVINT_DAYS    30
    54  * @param index proposed service interval
    62  * @param index proposed service interval
    55  */
    63  */
    56 static inline Date GetServiceIntervalClamped(uint index)
    64 static inline Date GetServiceIntervalClamped(uint index)
    57 {
    65 {
    58 	return (_patches.servint_ispercent) ? clamp(index, MIN_SERVINT_PERCENT, MAX_SERVINT_PERCENT) : clamp(index, MIN_SERVINT_DAYS, MAX_SERVINT_DAYS);
    66 	return (_patches.servint_ispercent) ? clamp(index, MIN_SERVINT_PERCENT, MAX_SERVINT_PERCENT) : clamp(index, MIN_SERVINT_DAYS, MAX_SERVINT_DAYS);
    59 }
       
    60 
       
    61 
       
    62 /**
       
    63  * Check if a depot really exists.
       
    64  */
       
    65 static inline bool IsValidDepot(const Depot* depot)
       
    66 {
       
    67 	return depot->xy != 0; /* XXX: Replace by INVALID_TILE someday */
       
    68 }
    67 }
    69 
    68 
    70 /**
    69 /**
    71  * Check if a tile is a depot of the given type.
    70  * Check if a tile is a depot of the given type.
    72  */
    71  */