Skip to content

Commit 10482f8

Browse files
committed
Fix railgun coordinate hook causing UB with compiler optimizations
1 parent 7287692 commit 10482f8

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

src/Ext/Techno/Hooks.WeaponEffects.cpp

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -114,17 +114,13 @@ DEFINE_HOOK(0x62D685, ParticleSystemClass_Fire_Coords, 0x5)
114114
DEFINE_HOOK(0x70C6B5, TechnoClass_Railgun_TargetCoords, 0x5)
115115
{
116116
GET(AbstractClass*, pTarget, EBX);
117-
118-
CoordStruct coords;
117+
GET(CoordStruct*, pCoords, EAX);
119118

120119
if (const auto pBuilding = abstract_cast<BuildingClass*, true>(pTarget))
121-
coords = pBuilding->GetTargetCoords();
120+
*pCoords = pBuilding->GetTargetCoords();
122121
else if (const auto pCell = abstract_cast<CellClass*, true>(pTarget))
123-
coords = pCell->GetCoordsWithBridge();
124-
else
125-
coords = pTarget->GetCenterCoords();
122+
*pCoords = pCell->GetCoordsWithBridge();
126123

127-
R->EAX(&coords);
128124
return 0;
129125
}
130126

0 commit comments

Comments
 (0)