FWGS / hlsdk-portable

Portable Half-Life SDK. GoldSource and Xash3D. Crossplatform.
https://xash.su
Other
272 stars 125 forks source link

server: func_tank: prevent domain error on barrel adjust #328

Closed a1batross closed 2 years ago

a1batross commented 2 years ago

When target is too close to the tank origin, d2 - r2 expression may become negative causing domain error on square root, and poisoning other fields and even other entities with NaN

This can be easily tested by jumping on a tank head on c2a5b.

I'm not sure if we should take absolute value or zero in this case.

a1batross commented 2 years ago

Nah, this is not correct.

With fabs() tank head begins to turning by few degress, like it's in panic. :)

Will update this branch with another solution

a1batross commented 2 years ago

Feels a bit more stable with just doing nothing if target is too close. It's still twitching but less.

FreeSlave commented 2 years ago

Funny, you can be teleported to the world origin if standing on a certain spot on top of Bradley on c2a5b. It doesn't happen with this fix.

nekonomicon commented 2 years ago

What if just do nothing for negative value?

a1batross commented 2 years ago

@nekonomicon yeah, in last version I don't change any angles.

nekonomicon commented 2 years ago

Where? I see fabs.

nekonomicon commented 2 years ago

@a1batross all good? https://github.com/FWGS/hlsdk-portable/compare/35cd765a775204bf8bbb68b292e0133d20589306..17281f80af3522318f43c8d83ed404aee3fd8d73

a1batross commented 2 years ago

@nekonomicon no, it's not... I force-pushed fabs-less changes. But haven't verified them, and these were old changes. O_o

Well, should be OK now.