* 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. */
| 208 | * @return the road types. |
| 209 | */ |
| 210 | RoadTypes 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. |
no test coverage detected