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

Function GetCompanyRoadTypes

src/road.cpp:210–231  ·  view source on GitHub ↗

* Get the road types the given company can build. * @param company the company to get the road types for. * @param introduces If true, include road types introduced by other road types * @return the road types. */

Source from the content-addressed store, hash-verified

208 * @return the road types.
209 */
210RoadTypes GetCompanyRoadTypes(CompanyID company, bool introduces)
211{
212 RoadTypes rts{};
213
214 for (const Engine *e : Engine::IterateType(VEH_ROAD)) {
215 const EngineInfo *ei = &e->info;
216
217 if (ei->climates.Test(_settings_game.game_creation.landscape) &&
218 (e->company_avail.Test(company) || TimerGameCalendar::date >= e->intro_date + CalendarTime::DAYS_IN_YEAR)) {
219 const RoadVehicleInfo *rvi = &e->VehInfo<RoadVehicleInfo>();
220 assert(rvi->roadtype < ROADTYPE_END);
221 if (introduces) {
222 rts.Set(GetRoadTypeInfo(rvi->roadtype)->introduces_roadtypes);
223 } else {
224 rts.Set(rvi->roadtype);
225 }
226 }
227 }
228
229 if (introduces) return AddDateIntroducedRoadTypes(rts, TimerGameCalendar::date);
230 return rts;
231}
232
233/**
234 * Get list of road types, regardless of company availability.

Callers 6

DoStartupNewCompanyFunction · 0.85
StartupEnginesFunction · 0.85
EnableEngineForCompanyFunction · 0.85
DisableEngineForCompanyFunction · 0.85
GetRoadTypeDropDownListFunction · 0.85
AfterLoadGameFunction · 0.85

Calls 4

GetRoadTypeInfoFunction · 0.85
TestMethod · 0.80
SetMethod · 0.45

Tested by

no test coverage detected