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

Function GetRailTypes

src/rail.cpp:166–187  ·  view source on GitHub ↗

* Get list of rail types, regardless of company availability. * @param introduces If true, include rail types introduced by other rail types * @return the rail types. */

Source from the content-addressed store, hash-verified

164 * @return the rail types.
165 */
166RailTypes GetRailTypes(bool introduces)
167{
168 RailTypes rts{};
169
170 for (const Engine *e : Engine::IterateType(VEH_TRAIN)) {
171 const EngineInfo *ei = &e->info;
172 if (!ei->climates.Test(_settings_game.game_creation.landscape)) continue;
173
174 const RailVehicleInfo *rvi = &e->VehInfo<RailVehicleInfo>();
175 if (rvi->railveh_type != RAILVEH_WAGON) {
176 assert(rvi->railtypes.Any());
177 if (introduces) {
178 rts.Set(GetAllIntroducesRailTypes(rvi->railtypes));
179 } else {
180 rts.Set(rvi->railtypes);
181 }
182 }
183 }
184
185 if (introduces) return AddDateIntroducedRailTypes(rts, CalendarTime::MAX_DATE);
186 return rts;
187}
188
189/**
190 * Get the rail type for a given label.

Callers 1

GetRailTypeDropDownListFunction · 0.85

Calls 5

TestMethod · 0.80
AnyMethod · 0.80
SetMethod · 0.45

Tested by

no test coverage detected