Skip to content

Commit 919eefe

Browse files
Nyeriahclaude
andauthored
refactor(Core/Battlefield): fire OnBattlefieldWarEnd before OnBattleEnd (azerothcore#26030)
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 2b932e5 commit 919eefe

2 files changed

Lines changed: 5 additions & 2 deletions

File tree

src/server/game/Battlefield/Battlefield.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -404,8 +404,11 @@ void Battlefield::EndBattle(bool endByTimer)
404404
else
405405
DoPlaySoundToAll(BF_HORDE_WINS);
406406

407-
OnBattleEnd(endByTimer);
407+
// Hook runs BEFORE OnBattleEnd so subscribers can read PlayersInWar
408+
// while it is still populated (OnBattleEnd hands out rewards and then
409+
// clears the set).
408410
sScriptMgr->OnBattlefieldWarEnd(this, endByTimer);
411+
OnBattleEnd(endByTimer);
409412

410413
for (uint8 team = 0; team < PVP_TEAMS_COUNT; ++team)
411414
{

src/server/game/Scripting/ScriptDefines/BattlefieldScript.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ enum BattlefieldHook
2828
BATTLEFIELDHOOK_ON_PLAYER_JOIN_WAR, // 2 - fires after player is added to the active war
2929
BATTLEFIELDHOOK_ON_PLAYER_LEAVE_WAR, // 3 - fires after player is removed from the active war
3030
BATTLEFIELDHOOK_BEFORE_INVITE_PLAYER_TO_WAR, // 4 - fires in InvitePlayerToWar before InvitedPlayers insert
31-
BATTLEFIELDHOOK_ON_WAR_END, // 5 - fires in EndBattle after OnBattleEnd(), before timer reset
31+
BATTLEFIELDHOOK_ON_WAR_END, // 5 - fires in EndBattle before OnBattleEnd(), while PlayersInWar is still populated
3232
BATTLEFIELDHOOK_ON_PLAYER_KILL, // 6 - fires in HandleKill for every player-kills-player event
3333
BATTLEFIELDHOOK_END
3434
};

0 commit comments

Comments
 (0)