Load with the new configuration - #171
Conversation
📝 WalkthroughWalkthrough
ChangesCFBG Config-Cache Refactor
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 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 109-119: The early return check on line 109 prevents the
LoadWGSkipClasses call on line 118 from executing when the system is disabled,
causing the _wgSkipClasses cache to retain stale values during a reload
transition from enabled to disabled. To fix this, ensure the skip-class cache is
cleared even when the system is disabled by either calling
sCFBG->LoadWGSkipClasses before the early return statement, or by adding a cache
clearing call in the early return path to reset _wgSkipClasses when the system
is disabled.
In `@src/CFBG.h`:
- Line 153: The LoadConfig() method signature in CFBG.h has been updated to
require a bool reload parameter, but the call to LoadConfig() in src/CFBG_SC.cpp
at line 406 (likely within the OnAfterConfigLoad function) was not updated and
still uses the old zero-argument syntax. Update this LoadConfig() call to pass
the bool reload parameter, using the Reload parameter available in the
OnAfterConfigLoad context.
- Around line 155-172: In all the getter methods between IsEnableSystem() and
RandomizeRaces() (18 methods total), replace the enum name
CrossFactionBGOutConfig with CFBGOutConfig. The _OutConfigData member is typed
as ConfigValueCache<CFBGOutConfig>, so all GetConfigValue template calls must
reference the correct enum CFBGOutConfig instead of the undefined
CrossFactionBGOutConfig. Update each inline method to use CFBGOutConfig:: as the
prefix for the configuration keys.
🪄 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: f5ba9957-15eb-44d0-b63c-49f9c6959837
📒 Files selected for processing (2)
src/CFBG.cppsrc/CFBG.h
|
✅ Action performedReview finished.
|
|
@coderabbitai review |
✅ Action performedReview finished.
|
| { | ||
| SetConfigValue<bool>(CFBGOutConfig::_IsEnableSystem, "CFBG.Enable", false); | ||
| if (!sCFBG->IsEnableSystem()) | ||
| return; |
There was a problem hiding this comment.
this early return could crash the worldserver at startup when CFBG.Enable = 0:
because Initialize() calls VerifyAllConfigsLoaded() after BuildConfigCache() and it asserts on any config slot that was never set.
Running with the module compiled but disabled is a normal setup, so we should load all values unconditionally and keep the enable check at the call sites, like WorldConfig::BuildConfigCache does in the core.
| _balanceClassMaxLevel = sConfigMgr->GetOption<uint8>("CFBG.BalancedTeams.Class.MaxLevel", 19); | ||
| _balanceClassLevelDiff = sConfigMgr->GetOption<uint8>("CFBG.BalancedTeams.Class.LevelDiff", 2); | ||
| _randomizeRaces = sConfigMgr->GetOption<bool>("CFBG.RandomRaceSelection", true); | ||
| SetConfigValue<bool>(CFBGOutConfig::_IsEnableWGSystem, "CFBG.Battlefield.Enable", false); |
There was a problem hiding this comment.
the old default for CFBG.Battlefield.Enable was true, with false here anyone without the key in their conf silently loses the Wintergrasp integration
| sCFBG->LoadWGSkipClasses(sCFBG->IsEnableWGSkipClasses()); | ||
|
|
||
| SetConfigValue<bool>(CFBGOutConfig::_IsEnableBalancedTeams, "CFBG.BalancedTeams", false); | ||
| SetConfigValue<bool>(CFBGOutConfig::_IsEnableBalanceClassLowLevel, "CFBG.BalancedTeams.Class.LowLevel", false); |
There was a problem hiding this comment.
same here, the old default for CFBG.BalancedTeams.Class.LowLevel was true.
| SetConfigValue<bool>(CFBGOutConfig::_IsEnableWGReapplyOnResurrect, "CFBG.Battlefield.ReapplyOnResurrect.Enable", true); | ||
|
|
||
| SetConfigValue<std::string>(CFBGOutConfig::_IsEnableWGSkipClasses, "CFBG.Battlefield.SkipClasses", ""); | ||
| sCFBG->LoadWGSkipClasses(sCFBG->IsEnableWGSkipClasses()); |
There was a problem hiding this comment.
this getter returns the skip class list rather than a flag, maybe GetWGSkipClasses would read better than IsEnableWGSkipClasses
azerothcore/azerothcore-wotlk#21647
Summary by CodeRabbit
Summary by CodeRabbit
Refactor
Behavioral Updates