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

Function AddDateIntroducedRoadTypes

src/road.cpp:177–202  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

175 * introduced road types are taken into account as well.
176 */
177RoadTypes AddDateIntroducedRoadTypes(RoadTypes current, TimerGameCalendar::Date date)
178{
179 RoadTypes rts = current;
180
181 for (RoadType rt = ROADTYPE_BEGIN; rt != ROADTYPE_END; rt++) {
182 const RoadTypeInfo *rti = GetRoadTypeInfo(rt);
183 /* Unused road type. */
184 if (rti->label == 0) continue;
185
186 /* Not date introduced. */
187 if (!IsInsideMM(rti->introduction_date, 0, CalendarTime::MAX_DATE.base())) continue;
188
189 /* Not yet introduced at this date. */
190 if (rti->introduction_date > date) continue;
191
192 /* Have we introduced all required roadtypes? */
193 RoadTypes required = rti->introduction_required_roadtypes;
194 if (!rts.All(required)) continue;
195
196 rts.Set(rti->introduces_roadtypes);
197 }
198
199 /* When we added roadtypes we need to run this method again; the added
200 * roadtypes might enable more rail types to become introduced. */
201 return rts == current ? rts : AddDateIntroducedRoadTypes(rts, date);
202}
203
204/**
205 * Get the road types the given company can build.

Callers 5

GetCompanyRoadTypesFunction · 0.85
GetRoadTypesFunction · 0.85
engine.cppFile · 0.85
NewVehicleAvailableFunction · 0.85

Calls 5

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

Tested by

no test coverage detected