Conversation
…the lobby owner returns to the lobby
WalkthroughA guard flag Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes Poem
🚥 Pre-merge checks | ✅ 1 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (1 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 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.
🧹 Nitpick comments (2)
src/UI/MpPerPlayerUI.cpp (2)
172-175: Use an RAII guard instead of manualtrue/falsetoggling.The current pattern is fragile and easy to break in future edits. A scoped guard makes reset automatic and keeps these sections safe.
♻️ Proposed refactor (scoped guard)
namespace MultiplayerCore::UI { - // Setting toggle triggers setters, guard every set_Value with this to prevent unwanted state resets - bool skipUpdateHandler = false; + // Setting toggle triggers setters, guard every set_Value with this to prevent unwanted state resets + bool skipUpdateHandler = false; + + struct ScopedUpdateHandlerSkip { + bool& flag; + explicit ScopedUpdateHandlerSkip(bool& f) : flag(f) { flag = true; } + ~ScopedUpdateHandlerSkip() { flag = false; } + };- skipUpdateHandler = true; // set_Value triggers on update + ScopedUpdateHandlerSkip guard(skipUpdateHandler); // set_Value triggers on update ppdt->set_Value(false); ppmt->set_Value(false); - skipUpdateHandler = false;- skipUpdateHandler = true; + ScopedUpdateHandlerSkip guard(skipUpdateHandler); ppdt->set_Value(packet->PPDEnabled); ppmt->set_Value(packet->PPMEnabled); - skipUpdateHandler = false;Also applies to: 233-236
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/UI/MpPerPlayerUI.cpp` around lines 172 - 175, Replace the manual toggling of skipUpdateHandler around the two set_Value calls with a scoped RAII guard that sets skipUpdateHandler = true on construction and resets it to false on destruction (e.g., implement a small guard class like SkipUpdateGuard). Update the code around ppdt->set_Value(false) and ppmt->set_Value(false) (and the identical block at the other location) to instantiate that guard at the start of the scope so the flag is automatically restored even on early returns/exceptions.
49-50: Scope the update guard to theMpPerPlayerUIinstance, not namespace state.Using a namespace-level mutable flag risks cross-instance interference if more than one
MpPerPlayerUIexists/re-initializes. This guard should be instance-owned (this->_skipUpdateHandler) to keep behavior isolated per UI controller.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/UI/MpPerPlayerUI.cpp` around lines 49 - 50, The namespace-level flag skipUpdateHandler should be converted to an instance member on MpPerPlayerUI to avoid cross-instance interference: add a private bool _skipUpdateHandler (initialized in MpPerPlayerUI constructor), remove the namespace variable, and update all guarded sites (where set_Value and other setters check skipUpdateHandler) to use this->_skipUpdateHandler instead; ensure any code that toggles the guard (set to true/false) is updated to operate on the instance member so each MpPerPlayerUI controls its own update guard.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@src/UI/MpPerPlayerUI.cpp`:
- Around line 172-175: Replace the manual toggling of skipUpdateHandler around
the two set_Value calls with a scoped RAII guard that sets skipUpdateHandler =
true on construction and resets it to false on destruction (e.g., implement a
small guard class like SkipUpdateGuard). Update the code around
ppdt->set_Value(false) and ppmt->set_Value(false) (and the identical block at
the other location) to instantiate that guard at the start of the scope so the
flag is automatically restored even on early returns/exceptions.
- Around line 49-50: The namespace-level flag skipUpdateHandler should be
converted to an instance member on MpPerPlayerUI to avoid cross-instance
interference: add a private bool _skipUpdateHandler (initialized in
MpPerPlayerUI constructor), remove the namespace variable, and update all
guarded sites (where set_Value and other setters check skipUpdateHandler) to use
this->_skipUpdateHandler instead; ensure any code that toggles the guard (set to
true/false) is updated to operate on the instance member so each MpPerPlayerUI
controls its own update guard.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 9aeee1c5-7fe0-483b-9963-b28db58e7cd4
📒 Files selected for processing (1)
src/UI/MpPerPlayerUI.cpp
Summary by CodeRabbit