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:
Peter Nelson
2025-09-24 22:44:41 +01:00
committed by dP
parent 88d3faa050
commit 3bb1b847d3
27 changed files with 209 additions and 199 deletions

View File

@@ -1138,7 +1138,7 @@ static void GetRotorOverrideSprite(EngineID engine, const struct Aircraft *v, En
/* Only valid for helicopters */
assert(e->type == VEH_AIRCRAFT);
assert(!(e->u.air.subtype & AIR_CTOL));
assert(!(e->VehInfo<AircraftVehicleInfo>().subtype & AIR_CTOL));
/* We differ from TTDPatch by resolving the sprite using the primary vehicle 'v', and not using the rotor vehicle 'v->Next()->Next()'.
* TTDPatch copies some variables between the vehicles each time, to somehow synchronize the rotor vehicle with the primary vehicle.