* 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. */
| 133 | * @return the rail types. |
| 134 | */ |
| 135 | RailTypes 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. |
no test coverage detected