From 80db6904c0210cd72010af57a9ca03d1a8a0cdb8 Mon Sep 17 00:00:00 2001 From: Skjalf <47818697+Nyeriah@users.noreply.github.com> Date: Sun, 19 Jul 2026 19:43:02 -0300 Subject: [PATCH] fix(WG): credit Victory in Wintergrasp for crossfaction players Core's BattlefieldWG::OnBattleEnd credits the winners with a single quest id derived from the defending (winning) team: 13181 for Alliance, 13183 for Horde. A crossfaction player fighting as the opposite side still holds their own faction's copy of the quest, so that call does nothing for them and the turn-in stays unavailable. Grant the other faction's victory quest to everyone in the winning war set from OnBattlefieldWarEnd, which runs before OnBattleEnd while PlayersInWar is still populated. AreaExploredOrEventHappens is a no-op on a quest the player does not hold, so native players are unaffected and there is no double credit. Same approach as the PvP-kill credit fix in OnBattlefieldPlayerKill. Co-Authored-By: Claude Opus 4.8 --- src/CFBG_SC.cpp | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/src/CFBG_SC.cpp b/src/CFBG_SC.cpp index 769f7de..e4d600b 100644 --- a/src/CFBG_SC.cpp +++ b/src/CFBG_SC.cpp @@ -298,6 +298,8 @@ class CFBG_Player : public PlayerScript static constexpr uint32 WG_SPELL_LIEUTENANT = 55629; static constexpr uint32 WG_NPC_QUEST_PVP_KILL_ALLIANCE = 31086; static constexpr uint32 WG_NPC_QUEST_PVP_KILL_HORDE = 39019; +static constexpr uint32 WG_QUEST_VICTORY_ALLIANCE = 13181; +static constexpr uint32 WG_QUEST_VICTORY_HORDE = 13183; class CFBG_Battlefield : public BattlefieldScript { @@ -457,11 +459,32 @@ class CFBG_Battlefield : public BattlefieldScript // war set still reflects who was actively fighting. ClearFakePlayer // is a no-op for unfaked players, so iterating GUIDs that may or may // not be faked is safe. + + // "Victory in Wintergrasp": OnBattleEnd credits the winners with the + // quest of the defending (= winning) team only, which misses cross- + // faction players holding their native faction's copy. Grant the other + // one here -- AreaExploredOrEventHappens is a no-op on a quest the + // player does not hold, and core still grants its own right after. + uint32 const otherVictoryQuest = bf->GetDefenderTeam() == TEAM_ALLIANCE ? WG_QUEST_VICTORY_HORDE + : WG_QUEST_VICTORY_ALLIANCE; + for (uint8 team = 0; team < PVP_TEAMS_COUNT; ++team) + { + bool const isWinner = static_cast(team) == bf->GetDefenderTeam(); + for (ObjectGuid const& guid : bf->GetPlayersInWarSet(static_cast(team))) - if (Player* player = ObjectAccessor::FindPlayer(guid)) - if (sCFBG->IsPlayerFake(player)) - sCFBG->ClearFakePlayer(player); + { + Player* player = ObjectAccessor::FindPlayer(guid); + if (!player) + continue; + + if (isWinner) + player->AreaExploredOrEventHappens(otherVictoryQuest); + + if (sCFBG->IsPlayerFake(player)) + sCFBG->ClearFakePlayer(player); + } + } // Lock is per-war: drop assignments so the next war re-balances. sCFBG->ClearWGWarAssignments();