nwnxee / unified

Binaries available under the Releases tab on Github
https://nwnxee.github.io/unified
GNU General Public License v3.0
129 stars 92 forks source link

Tweaks: Fix server crash in `NWNX_TWEAKS_FIX_RESOLVE_SPECIAL_ATTACK_DAMAGE` #1643

Closed summonFox closed 1 year ago

summonFox commented 1 year ago

Fixes a server crash in NWNX_TWEAKS_FIX_RESOLVE_SPECIAL_ATTACK_DAMAGE when a ranged special attack was avoided with epic dodge.

This fix is not perfect. Once epic dodge has been triggered, any further special attacks in the current round against the target will again consume damage reduction/etc effects on misses. I couldn't figure out a better way to fix this, and needed to throw something in quickly as we were getting a few frequent crashes from it.

Daztek commented 1 year ago

Do you have a stacktrace? This tweak is moving to the basegame in the future so I'd like to avoid any crashes it might introduce

summonFox commented 1 year ago

Do you have a stacktrace? This tweak is moving to the basegame in the future so I'd like to avoid any crashes it might introduce

Here we go:

 NWNX Signal Handler:
==============================================================
 NWNX 8193.35-37 (84d0d1ac97) has crashed. Fatal error: Floating point exception (8).
 Please file a bug at https://github.com/nwnxee/unified/issues
==============================================================

  Backtrace:
    /home/summonfox/35dev/unified/Binaries/NWNX_Core.so(_ZN7NWNXLib8Platform13GetStackTraceB5cxx11Eh+0x64) [0x7ff6b7ffd444]
    /home/summonfox/35dev/unified/Binaries/NWNX_Core.so(nwnx_signal_handler+0xd7) [0x7ff6b7facfc7]
    /lib/x86_64-linux-gnu/libc.so.6(+0x46210) [0x7ff6b7a06210]
    ./nwserver-linux(_ZN12CNWSCreature17ResolveRangedMissEP10CNWSObject+0xcc4) [0x7ff6b857aa34]
    ./nwserver-linux(_ZN12CNWSCreature26ResolveRangedSpecialAttackEP10CNWSObjecti+0x88) [0x7ff6b8586898]
    /home/summonfox/35dev/unified/Binaries/NWNX_Tweaks.so(+0x21199) [0x7ff6a626e199]
    ./nwserver-linux(_ZN12CNWSCreature19ResolveRangedAttackEP10CNWSObjectii+0xfb) [0x7ff6b8586f0b]
    ./nwserver-linux(_ZN12CNWSCreature20AIActionAttackObjectEP20CNWSObjectActionNode+0x5af) [0x7ff6b8588d2f]
    ./nwserver-linux(_ZN10CNWSObject10RunActionsEjjm+0xafe) [0x7ff6b86141be]
    ./nwserver-linux(_ZN12CNWSCreature8AIUpdateEv+0x15e) [0x7ff6b855310e]
    ./nwserver-linux(_ZN15CServerAIMaster11UpdateStateEv+0x54c) [0x7ff6b866e2ec]
    ./nwserver-linux(_ZN21CServerExoAppInternal8MainLoopEv+0x7dc) [0x7ff6b868360c]
    ./nwserver-linux(main+0x13a5) [0x7ff6b83ed535]
    /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf3) [0x7ff6b79e70b3]
    ./nwserver-linux(_start+0x2a) [0x7ff6b83f188a]

I didn't have time to create a repro module, but can tomorrow if you'd like one. Otherwise, the steps are:

1) Create a target NPC with epic dodge. 2) Put the target NPC into combat with another object (such as a plot flagged placeable) so that they're in combat and can trigger epic dodge. 3) Give yourself a bow and called shot. 4) Use called shot on the target NPC. Once you miss, you should crash.

Daztek commented 1 year ago

Basegame fix didn't crash so I'm going to chalk it up to some weird nwnx gremlin-ness, going to merge a PR that just fully implements CNWSCreature::ResolveRangedSpecialAttack which appears to fix the issue. Closing this one!