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

Function AddDateIntroducedRailTypes

src/rail.cpp:102–127  ·  view source on GitHub ↗

* Add the rail types that are to be introduced at the given date. * @param current The currently available railtypes. * @param date The date for the introduction comparisons. * @return The rail types that should be available when date * introduced rail types are taken into account as well. */

Source from the content-addressed store, hash-verified

100 * introduced rail types are taken into account as well.
101 */
102RailTypes AddDateIntroducedRailTypes(RailTypes current, TimerGameCalendar::Date date)
103{
104 RailTypes rts = current;
105
106 for (RailType rt = RAILTYPE_BEGIN; rt != RAILTYPE_END; rt++) {
107 const RailTypeInfo *rti = GetRailTypeInfo(rt);
108 /* Unused rail type. */
109 if (rti->label == 0) continue;
110
111 /* Not date introduced. */
112 if (!IsInsideMM(rti->introduction_date, 0, CalendarTime::MAX_DATE.base())) continue;
113
114 /* Not yet introduced at this date. */
115 if (rti->introduction_date > date) continue;
116
117 /* Have we introduced all required railtypes? */
118 RailTypes required = rti->introduction_required_railtypes;
119 if (!rts.All(required)) continue;
120
121 rts.Set(rti->introduces_railtypes);
122 }
123
124 /* When we added railtypes we need to run this method again; the added
125 * railtypes might enable more rail types to become introduced. */
126 return rts == current ? rts : AddDateIntroducedRailTypes(rts, date);
127}
128
129/**
130 * Get the rail types the given company can build.

Callers 4

GetCompanyRailTypesFunction · 0.85
GetRailTypesFunction · 0.85
engine.cppFile · 0.85
NewVehicleAvailableFunction · 0.85

Calls 5

GetRailTypeInfoFunction · 0.85
IsInsideMMFunction · 0.85
AllMethod · 0.80
baseMethod · 0.45
SetMethod · 0.45

Tested by

no test coverage detected