From 1529401e44250a63ca7d5d2bdb9f1224bd1731f9 Mon Sep 17 00:00:00 2001 From: Skjalf <47818697+Nyeriah@users.noreply.github.com> Date: Tue, 2 Jun 2026 23:06:04 -0300 Subject: [PATCH 1/2] fix(WG): re-apply crossfaction fake on resurrect A crossfaction WG player could lose their assigned faction/morph after the ghost->alive transition, reverting to their native race. Re-push the stored fake values on OnPlayerResurrect so the assigned faction and morph survive resurrection. Gated to WG fakes only (enabled system + WG system + player in a BATTLEFIELD_WG zone); battleground fakes remain owned by the BG hooks. SetFactionForRace also re-syncs any controlled pets/summons. Co-Authored-By: Claude Opus 4.8 --- src/CFBG.cpp | 14 ++++++++++++++ src/CFBG.h | 1 + src/CFBG_SC.cpp | 20 +++++++++++++++++++- 3 files changed, 34 insertions(+), 1 deletion(-) diff --git a/src/CFBG.cpp b/src/CFBG.cpp index 760c1e5..544a2db 100644 --- a/src/CFBG.cpp +++ b/src/CFBG.cpp @@ -594,6 +594,20 @@ void CFBG::ClearFakePlayer(Player* player) _fakePlayerStore.erase(player); } +void CFBG::ReapplyFakePlayer(Player* player) +{ + FakePlayer const* info = GetFakePlayer(player); + if (!info) + return; + + // Re-push the stored fake values after a resurrect so the assigned faction + // and morph survive the ghost->alive transition. + player->setRace(info->FakeRace); + SetFactionForRace(player, info->FakeRace, info->FakeTeamID); + player->SetDisplayId(info->FakeMorph); + player->SetNativeDisplayId(info->FakeMorph); +} + bool CFBG::IsPlayerFake(Player* player) { return _fakePlayerStore.contains(player); diff --git a/src/CFBG.h b/src/CFBG.h index f429059..90a2325 100644 --- a/src/CFBG.h +++ b/src/CFBG.h @@ -174,6 +174,7 @@ class CFBG void SetFakeRaceAndMorphForBF(Player* player, TeamId assignedTeam); void SetFactionForRace(Player* player, uint8 Race, TeamId teamId); void ClearFakePlayer(Player* player); + void ReapplyFakePlayer(Player* player); void DoForgetPlayersInList(Player* player); void FitPlayerInTeam(Player* player, bool action, Battleground* bg); void DoForgetPlayersInBG(Player* player, Battleground* bg); diff --git a/src/CFBG_SC.cpp b/src/CFBG_SC.cpp index 808aa8a..772d11d 100644 --- a/src/CFBG_SC.cpp +++ b/src/CFBG_SC.cpp @@ -108,7 +108,8 @@ class CFBG_Player : public PlayerScript PLAYERHOOK_CAN_JOIN_IN_BATTLEGROUND_QUEUE, PLAYERHOOK_ON_BEFORE_UPDATE, PLAYERHOOK_ON_BEFORE_SEND_CHAT_MESSAGE, - PLAYERHOOK_ON_REPUTATION_CHANGE + PLAYERHOOK_ON_REPUTATION_CHANGE, + PLAYERHOOK_ON_PLAYER_RESURRECT }) { } void OnPlayerLogin(Player* player) override @@ -215,6 +216,23 @@ class CFBG_Player : public PlayerScript lang = LANG_UNIVERSAL; } + void OnPlayerResurrect(Player* player, float /*restorePercent*/, bool& /*applySickness*/) override + { + if (!sCFBG->IsEnableSystem() || !sCFBG->IsEnableWGSystem()) + return; + + if (!sCFBG->IsPlayerFake(player)) + return; + + // Only re-apply for WG fakes. Battleground fakes are owned by the BG + // hooks and must not be touched here. + Battlefield* bf = sBattlefieldMgr->GetBattlefieldToZoneId(player->GetZoneId()); + if (!bf || bf->GetTypeId() != BATTLEFIELD_WG) + return; + + sCFBG->ReapplyFakePlayer(player); + } + bool OnPlayerReputationChange(Player* player, uint32 factionID, int32& standing, bool /*incremental*/) override { uint32 repGain = player->GetReputation(factionID); From 5ea7f7c5a398e8387171a549a6275a39f560d8e7 Mon Sep 17 00:00:00 2001 From: Skjalf <47818697+Nyeriah@users.noreply.github.com> Date: Tue, 2 Jun 2026 23:10:13 -0300 Subject: [PATCH 2/2] feat(WG): gate resurrect re-apply behind a config option Add CFBG.Battlefield.ReapplyOnResurrect.Enable (default 1) so the WG resurrect re-apply can be disabled. Wired through LoadConfig and checked in the OnPlayerResurrect hook alongside the existing WG gates. Co-Authored-By: Claude Opus 4.8 --- conf/CFBG.conf.dist | 9 +++++++++ src/CFBG.cpp | 1 + src/CFBG.h | 2 ++ src/CFBG_SC.cpp | 2 +- 4 files changed, 13 insertions(+), 1 deletion(-) diff --git a/conf/CFBG.conf.dist b/conf/CFBG.conf.dist index f7bb597..7b74cb0 100644 --- a/conf/CFBG.conf.dist +++ b/conf/CFBG.conf.dist @@ -32,6 +32,14 @@ # Default: 1 - (Enabled) # 0 - (Disabled) # +# CFBG.Battlefield.ReapplyOnResurrect.Enable +# Description: Re-apply a cross-faction player's assigned race/faction/morph +# when they resurrect inside Wintergrasp, so the ghost->alive +# transition does not revert them to their native faction. +# Requires CFBG.Battlefield.Enable = 1. +# Default: 1 - (Enabled) +# 0 - (Disabled) +# # CFBG.Include.Avg.Ilvl.Enable # Description: Enable check average item level for bg # Default: 0 @@ -90,6 +98,7 @@ CFBG.Enable = 1 CFBG.Battlefield.Enable = 1 CFBG.Battlefield.TeamLock.Enable = 1 +CFBG.Battlefield.ReapplyOnResurrect.Enable = 1 CFBG.BalancedTeams = 1 CFBG.BalancedTeams.Class.LowLevel = 0 CFBG.BalancedTeams.Class.MinLevel = 10 diff --git a/src/CFBG.cpp b/src/CFBG.cpp index 544a2db..75d165b 100644 --- a/src/CFBG.cpp +++ b/src/CFBG.cpp @@ -152,6 +152,7 @@ void CFBG::LoadConfig() _IsEnableWGSystem = sConfigMgr->GetOption("CFBG.Battlefield.Enable", true); _IsEnableWGTeamLock = sConfigMgr->GetOption("CFBG.Battlefield.TeamLock.Enable", true); + _IsEnableWGReapplyOnResurrect = sConfigMgr->GetOption("CFBG.Battlefield.ReapplyOnResurrect.Enable", true); _IsEnableAvgIlvl = sConfigMgr->GetOption("CFBG.Include.Avg.Ilvl.Enable", false); _IsEnableBalancedTeams = sConfigMgr->GetOption("CFBG.BalancedTeams", false); _IsEnableEvenTeams = sConfigMgr->GetOption("CFBG.EvenTeams.Enabled", false); diff --git a/src/CFBG.h b/src/CFBG.h index 90a2325..2610fc5 100644 --- a/src/CFBG.h +++ b/src/CFBG.h @@ -137,6 +137,7 @@ class CFBG inline bool IsEnableSystem() const { return _IsEnableSystem; } inline bool IsEnableWGSystem() const { return _IsEnableWGSystem; } inline bool IsEnableWGTeamLock() const { return _IsEnableWGTeamLock; } + inline bool IsEnableWGReapplyOnResurrect() const { return _IsEnableWGReapplyOnResurrect; } inline bool IsEnableAvgIlvl() const { return _IsEnableAvgIlvl; } inline bool IsEnableBalancedTeams() const { return _IsEnableBalancedTeams; } inline bool IsEnableBalanceClassLowLevel() const { return _IsEnableBalanceClassLowLevel; } @@ -224,6 +225,7 @@ class CFBG bool _IsEnableSystem; bool _IsEnableWGSystem; bool _IsEnableWGTeamLock; + bool _IsEnableWGReapplyOnResurrect; bool _IsEnableAvgIlvl; bool _IsEnableBalancedTeams; bool _IsEnableBalanceClassLowLevel; diff --git a/src/CFBG_SC.cpp b/src/CFBG_SC.cpp index 772d11d..6a0c0bd 100644 --- a/src/CFBG_SC.cpp +++ b/src/CFBG_SC.cpp @@ -218,7 +218,7 @@ class CFBG_Player : public PlayerScript void OnPlayerResurrect(Player* player, float /*restorePercent*/, bool& /*applySickness*/) override { - if (!sCFBG->IsEnableSystem() || !sCFBG->IsEnableWGSystem()) + if (!sCFBG->IsEnableSystem() || !sCFBG->IsEnableWGSystem() || !sCFBG->IsEnableWGReapplyOnResurrect()) return; if (!sCFBG->IsPlayerFake(player))