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

Function GetTownRoadTypeFirstIntroductionDate

src/town_cmd.cpp:995–1009  ·  view source on GitHub ↗

* Get the calendar date of the earliest town-buildable road type. * @return introduction date of earliest road type, or INT32_MAX if none available. */

Source from the content-addressed store, hash-verified

993 * @return introduction date of earliest road type, or INT32_MAX if none available.
994 */
995static TimerGameCalendar::Date GetTownRoadTypeFirstIntroductionDate()
996{
997 const RoadTypeInfo *best = nullptr;
998 for (RoadType rt : GetMaskForRoadTramType(RTT_ROAD)) {
999 const RoadTypeInfo *rti = GetRoadTypeInfo(rt);
1000
1001 if (!rti->flags.Test(RoadTypeFlag::TownBuild)) continue; // Town can't build this road type.
1002
1003 if (best != nullptr && rti->introduction_date >= best->introduction_date) continue;
1004 best = rti;
1005 }
1006
1007 if (best == nullptr) return TimerGameCalendar::Date(INT32_MAX);
1008 return best->introduction_date;
1009}
1010
1011/**
1012 * Check if towns are able to build road.

Callers 1

CheckTownRoadTypesFunction · 0.85

Calls 4

GetMaskForRoadTramTypeFunction · 0.85
GetRoadTypeInfoFunction · 0.85
DateEnum · 0.85
TestMethod · 0.80

Tested by

no test coverage detected