Loading

Paste #pwwa4fqnb

  1. diff --git a/src/road.cpp b/src/road.cpp
  2. index 399971c..281cfd9 100644
  3. --- a/src/road.cpp
  4. +++ b/src/road.cpp
  5. @@ -247,3 +247,44 @@ 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 c the company ID to check the roadtype against
  14. + * @param any_date whether to return only currently introduced roadtypes or also future ones
  15. + * @returns the existing RoadSubTypes
  16. + */
  17. +RoadSubTypes ExistingRoadSubTypesForRoadType(RoadType rt, CompanyID c, bool any_date = true)
  18. +{
  19. +   if (c != INVALID_COMPANY) {
  20. +       const Company *company = Company::GetIfValid(c);
  21. +
  22. +       return company->avail_roadtypes[rt];
  23. +   }
  24. +
  25. +   RoadSubTypes known_roadsubtypes = ROADSUBTYPES_NONE;
  26. +
  27. +   /* Road is always visible and available. */
  28. +   if (rt == ROADTYPE_ROAD) known_roadsubtypes |= ROADSUBTYPES_NORMAL; // TODO
  29. +
  30. +   /* Find used roadtypes */
  31. +   Engine *e;
  32. +   FOR_ALL_ENGINES_OF_TYPE(e, VEH_ROAD) {
  33. +       /* Check if the subtype can be used in the current climate */
  34. +       if (!HasBit(e->info.climates,  _settings_game.game_creation.landscape)) continue;
  35. +
  36. +       /* Check whether available for all potential companies */
  37. +       if (e->company_avail != (CompanyMask)-1) continue;
  38. +
  39. +       RoadTypeIdentifier rtid = e->GetRoadType();
  40. +       if (rtid.basetype != rt) continue;
  41. +
  42. +       known_roadsubtypes |= GetRoadTypeInfo(rtid)->introduces_roadtypes;
  43. +   }
  44. +
  45. +   /* Get the date introduced roadtypes as well. */
  46. +   known_roadsubtypes = AddDateIntroducedRoadTypes(rt, known_roadsubtypes, any_date ? MAX_DAY : _date);
  47. +
  48. +   return known_roadsubtypes;
  49. +}

Version history

Revision # Author Created at
pn1c10m0z Anonymous 18 Feb 2017, 17:05:45 UTC Diff
p84xottja Anonymous 18 Feb 2017, 15:49:52 UTC Diff

Comments