Fix 3ac1a2f1e4: Game crash due to invalid vehicle type information. (#14628)
Use std::variant instead of union for vehicle info. RailVehicleInfo is now non-POD so using in a union causes undefined behaviour.
This commit is contained in:
@@ -204,7 +204,7 @@ RoadTypes GetCompanyRoadTypes(CompanyID company, bool introduces)
|
||||
|
||||
if (ei->climates.Test(_settings_game.game_creation.landscape) &&
|
||||
(e->company_avail.Test(company) || TimerGameCalendar::date >= e->intro_date + CalendarTime::DAYS_IN_YEAR)) {
|
||||
const RoadVehicleInfo *rvi = &e->u.road;
|
||||
const RoadVehicleInfo *rvi = &e->VehInfo<RoadVehicleInfo>();
|
||||
assert(rvi->roadtype < ROADTYPE_END);
|
||||
if (introduces) {
|
||||
rts.Set(GetRoadTypeInfo(rvi->roadtype)->introduces_roadtypes);
|
||||
@@ -231,7 +231,7 @@ RoadTypes GetRoadTypes(bool introduces)
|
||||
const EngineInfo *ei = &e->info;
|
||||
if (!ei->climates.Test(_settings_game.game_creation.landscape)) continue;
|
||||
|
||||
const RoadVehicleInfo *rvi = &e->u.road;
|
||||
const RoadVehicleInfo *rvi = &e->VehInfo<RoadVehicleInfo>();
|
||||
assert(rvi->roadtype < ROADTYPE_END);
|
||||
if (introduces) {
|
||||
rts.Set(GetRoadTypeInfo(rvi->roadtype)->introduces_roadtypes);
|
||||
|
||||
Reference in New Issue
Block a user