Add NewGRFClass helper method for whether class ID is valid (for iteration)

This commit is contained in:
Jonathan G Rennison
2023-01-03 03:51:40 +00:00
parent 417416d19b
commit 6a7cad1b47
7 changed files with 19 additions and 8 deletions

View File

@@ -501,7 +501,7 @@ void TriggerRoadStopRandomisation(Station *st, TileIndex tile, RoadStopRandomTri
bool GetIfNewStopsByType(RoadStopType rs, RoadType roadtype)
{
if (!(RoadStopClass::GetClassCount() > 1 || RoadStopClass::Get(ROADSTOP_CLASS_DFLT)->GetSpecCount() > 1)) return false;
for (uint i = 0; i < RoadStopClass::GetClassCount(); i++) {
for (uint i = 0; RoadStopClass::IsClassIDValid((RoadStopClassID)i); i++) {
// We don't want to check the default or waypoint classes. These classes are always available.
if (i == ROADSTOP_CLASS_DFLT || i == ROADSTOP_CLASS_WAYP) continue;
RoadStopClass *roadstopclass = RoadStopClass::Get((RoadStopClassID)i);