equal
deleted
inserted
replaced
159 static inline uint16 GetStationPoolSize(void) |
159 static inline uint16 GetStationPoolSize(void) |
160 { |
160 { |
161 return _station_pool.total_items; |
161 return _station_pool.total_items; |
162 } |
162 } |
163 |
163 |
164 static inline bool IsStationIndex(StationID index) |
|
165 { |
|
166 return index < GetStationPoolSize(); |
|
167 } |
|
168 |
|
169 /** |
164 /** |
170 * Check if a station really exists. |
165 * Check if a station really exists. |
171 */ |
166 */ |
172 static inline bool IsValidStation(const Station *st) |
167 static inline bool IsValidStation(const Station *st) |
173 { |
168 { |
174 return st->xy != 0; |
169 return st->xy != 0; |
|
170 } |
|
171 |
|
172 static inline bool IsValidStationID(StationID index) |
|
173 { |
|
174 return index < GetStationPoolSize() && IsValidStation(GetStation(index)); |
175 } |
175 } |
176 |
176 |
177 #define FOR_ALL_STATIONS_FROM(st, start) for (st = GetStation(start); st != NULL; st = (st->index + 1 < GetStationPoolSize()) ? GetStation(st->index + 1) : NULL) if (IsValidStation(st)) |
177 #define FOR_ALL_STATIONS_FROM(st, start) for (st = GetStation(start); st != NULL; st = (st->index + 1 < GetStationPoolSize()) ? GetStation(st->index + 1) : NULL) if (IsValidStation(st)) |
178 #define FOR_ALL_STATIONS(st) FOR_ALL_STATIONS_FROM(st, 0) |
178 #define FOR_ALL_STATIONS(st) FOR_ALL_STATIONS_FROM(st, 0) |
179 |
179 |