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

Function GetCompanyRailTypes

src/rail.cpp:135–159  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

133 * @return the rail types.
134 */
135RailTypes GetCompanyRailTypes(CompanyID company, bool introduces)
136{
137 RailTypes rts{};
138
139 for (const Engine *e : Engine::IterateType(VEH_TRAIN)) {
140 const EngineInfo *ei = &e->info;
141
142 if (ei->climates.Test(_settings_game.game_creation.landscape) &&
143 (e->company_avail.Test(company) || TimerGameCalendar::date >= e->intro_date + CalendarTime::DAYS_IN_YEAR)) {
144 const RailVehicleInfo *rvi = &e->VehInfo<RailVehicleInfo>();
145
146 if (rvi->railveh_type != RAILVEH_WAGON) {
147 assert(rvi->railtypes.Any());
148 if (introduces) {
149 rts.Set(GetAllIntroducesRailTypes(rvi->railtypes));
150 } else {
151 rts.Set(rvi->railtypes);
152 }
153 }
154 }
155 }
156
157 if (introduces) return AddDateIntroducedRailTypes(rts, TimerGameCalendar::date);
158 return rts;
159}
160
161/**
162 * Get list of rail types, regardless of company availability.

Callers 7

GetRailTypeDropDownListFunction · 0.85
DoStartupNewCompanyFunction · 0.85
StartupEnginesFunction · 0.85
EnableEngineForCompanyFunction · 0.85
DisableEngineForCompanyFunction · 0.85
AfterLoadGameFunction · 0.85

Calls 5

TestMethod · 0.80
AnyMethod · 0.80
SetMethod · 0.45

Tested by

no test coverage detected