Avoid downcasting station/vehicle subtypes before checking the type field.
This is because it generates a lot of spam warnings when running with UndefinedBehaviourSantizer et al.
This commit is contained in:
@@ -250,6 +250,8 @@ struct SpecializedStation : public BaseStation {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
#define FOR_ALL_BASE_STATIONS_OF_TYPE(name, var) FOR_ALL_ITEMS_FROM(name, station_index, var, 0) if (name::IsExpected(var))
|
#define FOR_ALL_BASE_STATIONS_OF_TYPE(name, var) \
|
||||||
|
for (size_t station_index = 0; var = NULL, station_index < name::GetPoolSize(); station_index++) \
|
||||||
|
if ((var = name::GetIfValid(station_index)) != NULL)
|
||||||
|
|
||||||
#endif /* BASE_STATION_BASE_H */
|
#endif /* BASE_STATION_BASE_H */
|
||||||
|
|||||||
@@ -1170,7 +1170,9 @@ struct SpecializedVehicle : public Vehicle {
|
|||||||
* @param name The type of vehicle to iterate over.
|
* @param name The type of vehicle to iterate over.
|
||||||
* @param var The variable used to iterate over.
|
* @param var The variable used to iterate over.
|
||||||
*/
|
*/
|
||||||
#define FOR_ALL_VEHICLES_OF_TYPE(name, var) FOR_ALL_ITEMS_FROM(name, vehicle_index, var, 0) if (var->type == name::EXPECTED_TYPE)
|
#define FOR_ALL_VEHICLES_OF_TYPE(name, var) \
|
||||||
|
for (size_t vehicle_index = 0; var = NULL, vehicle_index < name::GetPoolSize(); vehicle_index++) \
|
||||||
|
if ((var = name::GetIfValid(vehicle_index)) != NULL)
|
||||||
|
|
||||||
/** Generates sequence of free UnitID numbers */
|
/** Generates sequence of free UnitID numbers */
|
||||||
struct FreeUnitIDGenerator {
|
struct FreeUnitIDGenerator {
|
||||||
|
|||||||
Reference in New Issue
Block a user