MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / GetTownRoadType

Function GetTownRoadType

src/town_cmd.cpp:965–989  ·  view source on GitHub ↗

* Get the road type that towns should build at this current moment. * They may have built a different type in the past. */

Source from the content-addressed store, hash-verified

963 * They may have built a different type in the past.
964 */
965RoadType GetTownRoadType()
966{
967 RoadType best_rt = ROADTYPE_ROAD;
968 const RoadTypeInfo *best = nullptr;
969 const uint16_t assume_max_speed = 50;
970
971 for (RoadType rt : GetMaskForRoadTramType(RTT_ROAD)) {
972 const RoadTypeInfo *rti = GetRoadTypeInfo(rt);
973
974 /* Can town build this road. */
975 if (!rti->flags.Test(RoadTypeFlag::TownBuild)) continue;
976
977 /* Not yet introduced at this date. */
978 if (IsInsideMM(rti->introduction_date, 0, CalendarTime::MAX_DATE.base()) && rti->introduction_date > TimerGameCalendar::date) continue;
979
980 if (best != nullptr) {
981 if ((rti->max_speed == 0 ? assume_max_speed : rti->max_speed) < (best->max_speed == 0 ? assume_max_speed : best->max_speed)) continue;
982 }
983
984 best_rt = rt;
985 best = rti;
986 }
987
988 return best_rt;
989}
990
991/**
992 * Get the calendar date of the earliest town-buildable road type.

Callers 8

IsRoadAllowedHereFunction · 0.85
GrowTownWithRoadFunction · 0.85
GrowTownWithBridgeFunction · 0.85
GrowTownWithTunnelFunction · 0.85
TownCanGrowRoadFunction · 0.85
GrowTownFunction · 0.85
TileLoop_RoadFunction · 0.85

Calls 5

GetMaskForRoadTramTypeFunction · 0.85
GetRoadTypeInfoFunction · 0.85
IsInsideMMFunction · 0.85
TestMethod · 0.80
baseMethod · 0.45

Tested by

no test coverage detected