Skip to content

Commit

Permalink
Fixes bug where attack hook was recursively called if a character was…
Browse files Browse the repository at this point in the history
… moved by the hook

When a character is ready to swing, it will attack after being moved. Moving the character from within the attack hook could thus cause an infinite recursion.
  • Loading branch information
frozenblit committed Aug 30, 2021
1 parent cccf84d commit 21cd6fa
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
7 changes: 6 additions & 1 deletion docs/docs.polserver.com/pol100/corechanges.xml
Expand Up @@ -2,9 +2,14 @@
<ESCRIPT>
<header>
<topic>Latest Core Changes</topic>
<datemodified>08-13-2021</datemodified>
<datemodified>08-30-2021</datemodified>
</header>
<version name="POL100.1.0">
<entry>
<date>08-30-2021</date>
<author>Nando:</author>
<change type="Fixed">Possible infinite recursion of the attack hook if a character was moved by the attack hook</change>
</entry>
<entry>
<date>08-14-2021</date>
<author>Kevin:</author>
Expand Down
2 changes: 2 additions & 0 deletions pol-core/doc/core-changes.txt
@@ -1,4 +1,6 @@
-- POL100.1.0 --
08-30-2021 Nando:
Fixed: Possible infinite recursion of the attack hook if a character was moved by the attack hook
08-14-2021 Kevin:
Fixed: The remaining drop errors (too far away; location blocked) can now be disabled via the ShowWarningItem option.
08-11-2021 Kevin:
Expand Down
2 changes: 2 additions & 0 deletions pol-core/pol/mobile/charactr.cpp
Expand Up @@ -3451,6 +3451,8 @@ void Character::check_attack_after_move()
FUNCTION_CHECKPOINT( check_attack_after_move, 4 );
if ( Core::settingsManager.combat_config.send_swing_packet && client != nullptr )
send_fight_occuring( client, opponent );

mob_flags_.remove( MOB_FLAGS::READY_TO_SWING ); // we don't want attack() to recursively cause new attacks
attack( opponent );
FUNCTION_CHECKPOINT( check_attack_after_move, 5 );
reset_swing_timer();
Expand Down

0 comments on commit 21cd6fa

Please sign in to comment.