Loading

Paste #p84xottja

  1. diff --git a/src/road.cpp b/src/road.cpp
  2. index 399971c..7205bc1 100644
  3. --- a/src/road.cpp
  4. +++ b/src/road.cpp
  5. @@ -247,3 +247,33 @@ bool RoadTypeIdentifier::UnpackIfValid(uint32 data)
  6.     assert(ret);
  7.     return result;
  8.  }
  9. +
  10. +/**
  11. + * Returns the available RoadSubTypes for the provided RoadType
  12. + * @param rt the RoadType to filter
  13. + * @param only_existing whether to return only currently introduced vehicles or also future ones
  14. + * @returns the existing RoadSubTypes
  15. + */
  16. +RoadSubTypes ExistingRoadSubTypesForRoadType(RoadType rt, bool only_existing = false)
  17. +{
  18. +   RoadSubTypes used_roadsubtypes = ROADSUBTYPES_NONE;
  19. +
  20. +   /* Find used roadtypes */
  21. +   Engine *e;
  22. +   FOR_ALL_ENGINES_OF_TYPE(e, VEH_ROAD) {
  23. +       /* Check if the subtype can be used in the current climate */
  24. +       if (!HasBit(e->info.climates,  _settings_game.game_creation.landscape)) continue;
  25. +
  26. +       RoadTypeIdentifier rtid = e->GetRoadType();
  27. +       if (rtid.basetype != rt) continue;
  28. +
  29. +       used_roadsubtypes |= GetRoadTypeInfo(rtid)->introduces_roadtypes;
  30. +   }
  31. +
  32. +   if (!only_existing) {
  33. +       /* Get the date introduced roadtypes as well. */
  34. +       used_roadsubtypes = AddDateIntroducedRoadTypes(rt, used_roadsubtypes, MAX_DAY);
  35. +   }
  36. +
  37. +   return used_roadsubtypes;
  38. +}

Comments