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:
+2
-2
@@ -129,7 +129,7 @@ RailTypes GetCompanyRailTypes(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 RailVehicleInfo *rvi = &e->u.rail;
|
||||
const RailVehicleInfo *rvi = &e->VehInfo<RailVehicleInfo>();
|
||||
|
||||
if (rvi->railveh_type != RAILVEH_WAGON) {
|
||||
assert(rvi->railtypes.Any());
|
||||
@@ -159,7 +159,7 @@ RailTypes GetRailTypes(bool introduces)
|
||||
const EngineInfo *ei = &e->info;
|
||||
if (!ei->climates.Test(_settings_game.game_creation.landscape)) continue;
|
||||
|
||||
const RailVehicleInfo *rvi = &e->u.rail;
|
||||
const RailVehicleInfo *rvi = &e->VehInfo<RailVehicleInfo>();
|
||||
if (rvi->railveh_type != RAILVEH_WAGON) {
|
||||
assert(rvi->railtypes.Any());
|
||||
if (introduces) {
|
||||
|
||||
Reference in New Issue
Block a user