Skip to content

Commit

Permalink
Fix infinite loop for OnDuelEnd hook
Browse files Browse the repository at this point in the history
  • Loading branch information
Niam5 committed Jan 1, 2025
1 parent 9654142 commit 95552f7
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions src/game/Entities/Player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7332,11 +7332,7 @@ void Player::DuelComplete(DuelCompleteType type)
data << GetName();
SendMessageToSet(data, true);
}
#ifdef BUILD_ELUNA
// used by eluna
if (Eluna* e = GetEluna())
e->OnDuelEnd(duel->opponent, this, type);
#endif

// Remove Duel Flag object
if (GameObject* obj = GetMap()->GetGameObject(GetGuidValue(PLAYER_DUEL_ARBITER)))
duel->initiator->RemoveGameObject(obj, true);
Expand Down Expand Up @@ -7382,10 +7378,20 @@ void Player::DuelComplete(DuelCompleteType type)
duel->opponent->SetGuidValue(PLAYER_DUEL_ARBITER, ObjectGuid());
duel->opponent->SetUInt32Value(PLAYER_DUEL_TEAM, 0);

#ifdef BUILD_ELUNA
Player* duelOpponent = duel->opponent;
#endif

delete duel->opponent->duel;
duel->opponent->duel = nullptr;
delete duel;
duel = nullptr;

#ifdef BUILD_ELUNA
// used by eluna
if (Eluna* e = GetEluna())
e->OnDuelEnd(duelOpponent, this, type);
#endif
}

//---------------------------------------------------------//
Expand Down

0 comments on commit 95552f7

Please sign in to comment.