diff --git a/src/server/game/Battlefield/Battlefield.cpp b/src/server/game/Battlefield/Battlefield.cpp index 9381fd1284..afd9f6824c 100644 --- a/src/server/game/Battlefield/Battlefield.cpp +++ b/src/server/game/Battlefield/Battlefield.cpp @@ -404,8 +404,11 @@ void Battlefield::EndBattle(bool endByTimer) else DoPlaySoundToAll(BF_HORDE_WINS); - OnBattleEnd(endByTimer); + // Hook runs BEFORE OnBattleEnd so subscribers can read PlayersInWar + // while it is still populated (OnBattleEnd hands out rewards and then + // clears the set). sScriptMgr->OnBattlefieldWarEnd(this, endByTimer); + OnBattleEnd(endByTimer); for (uint8 team = 0; team < PVP_TEAMS_COUNT; ++team) { diff --git a/src/server/game/Scripting/ScriptDefines/BattlefieldScript.h b/src/server/game/Scripting/ScriptDefines/BattlefieldScript.h index 512cbc9f37..f61d10dedf 100644 --- a/src/server/game/Scripting/ScriptDefines/BattlefieldScript.h +++ b/src/server/game/Scripting/ScriptDefines/BattlefieldScript.h @@ -28,7 +28,7 @@ enum BattlefieldHook BATTLEFIELDHOOK_ON_PLAYER_JOIN_WAR, // 2 - fires after player is added to the active war BATTLEFIELDHOOK_ON_PLAYER_LEAVE_WAR, // 3 - fires after player is removed from the active war BATTLEFIELDHOOK_BEFORE_INVITE_PLAYER_TO_WAR, // 4 - fires in InvitePlayerToWar before InvitedPlayers insert - BATTLEFIELDHOOK_ON_WAR_END, // 5 - fires in EndBattle after OnBattleEnd(), before timer reset + BATTLEFIELDHOOK_ON_WAR_END, // 5 - fires in EndBattle before OnBattleEnd(), while PlayersInWar is still populated BATTLEFIELDHOOK_ON_PLAYER_KILL, // 6 - fires in HandleKill for every player-kills-player event BATTLEFIELDHOOK_END };