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:
+1
-1
@@ -582,7 +582,7 @@ void UpdateDisableElrailSettingState(bool disable, bool update_vehicles)
|
||||
{
|
||||
/* walk through all train engines */
|
||||
for (Engine *e : Engine::IterateType(VEH_TRAIN)) {
|
||||
RailVehicleInfo *rv_info = &e->u.rail;
|
||||
RailVehicleInfo *rv_info = &e->VehInfo<RailVehicleInfo>();
|
||||
/* update railtype of engines intended to use elrail */
|
||||
if (rv_info->intended_railtypes.Test(RAILTYPE_ELECTRIC)) {
|
||||
rv_info->railtypes.Set(RAILTYPE_ELECTRIC, !disable);
|
||||
|
||||
Reference in New Issue
Block a user