fix: close the remaining dual-faction paths from #166 - #174
Conversation
📝 WalkthroughWalkthroughModifies CFBG faction consistency repair to resync faction for non-GM players with mismatched race factions, adds charm aura removal in ClearFakePlayer, introduces a new DropFakePlayerRecord method that erases fake player records without state restoration, and wires it into WG logout handling during war time. ChangesCFBG fake player and faction repair
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant Player
participant CFBG_Player
participant CFBG
Player->>CFBG_Player: OnPlayerLogout
alt WG battlefield not in war time
CFBG_Player->>CFBG: ClearFakePlayer(player)
CFBG-->>Player: restore real race/morph/faction
else WG battlefield in war time
CFBG_Player->>CFBG: DropFakePlayerRecord(player)
CFBG-->>Player: erase fake record only
end
Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/CFBG.cpp`:
- Around line 335-339: The faction repair in CFBG::SetFactionForRace should also
respect active charm state, not just Game Master or SPELL_AURA_MOD_FACTION.
Update the guard so that when player->IsCharmed() is true, this recovery path is
skipped and does not overwrite the faction currently controlled by the charm.
Keep the existing race/faction comparison logic intact, but add the charm check
alongside the existing IsGameMaster and aura condition near the
SetFactionForRace call site.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 7f90ff49-465f-46f2-bdea-7600ecf473e6
📒 Files selected for processing (3)
src/CFBG.cppsrc/CFBG.hsrc/CFBG_SC.cpp
| if (!player->IsGameMaster() && !player->HasAuraType(SPELL_AURA_MOD_FACTION)) | ||
| { | ||
| ChrRacesEntry const* raceEntry = sChrRacesStore.LookupEntry(player->getRace(true)); | ||
| if (raceEntry && player->GetFaction() != raceEntry->FactionID) | ||
| SetFactionForRace(player, player->getRace(true), player->GetTeamId(true)); |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
Treat active charm as a legitimate faction writer here.
ClearFakePlayer now documents charm as owning/restoring faction state, but this repair path only skips GM and SPELL_AURA_MOD_FACTION. If a native player is actively charmed, this can overwrite the charm-owned faction before the charm ends; skip this repair while player->IsCharmed().
Proposed fix
- if (!player->IsGameMaster() && !player->HasAuraType(SPELL_AURA_MOD_FACTION))
+ if (!player->IsGameMaster() && !player->IsCharmed() && !player->HasAuraType(SPELL_AURA_MOD_FACTION))📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| if (!player->IsGameMaster() && !player->HasAuraType(SPELL_AURA_MOD_FACTION)) | |
| { | |
| ChrRacesEntry const* raceEntry = sChrRacesStore.LookupEntry(player->getRace(true)); | |
| if (raceEntry && player->GetFaction() != raceEntry->FactionID) | |
| SetFactionForRace(player, player->getRace(true), player->GetTeamId(true)); | |
| if (!player->IsGameMaster() && !player->IsCharmed() && !player->HasAuraType(SPELL_AURA_MOD_FACTION)) | |
| { | |
| ChrRacesEntry const* raceEntry = sChrRacesStore.LookupEntry(player->getRace(true)); | |
| if (raceEntry && player->GetFaction() != raceEntry->FactionID) | |
| SetFactionForRace(player, player->getRace(true), player->GetTeamId(true)); |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@src/CFBG.cpp` around lines 335 - 339, The faction repair in
CFBG::SetFactionForRace should also respect active charm state, not just Game
Master or SPELL_AURA_MOD_FACTION. Update the guard so that when
player->IsCharmed() is true, this recovery path is skipped and does not
overwrite the faction currently controlled by the charm. Keep the existing
race/faction comparison logic intact, but add the charm check alongside the
existing IsGameMaster and aura condition near the SetFactionForRace call site.
Summary by CodeRabbit