refactor(Core/Account): Move account flag logic from AccountMgr to WorldSession#22558
Merged
Conversation
Replaces direct database queries for account flags with an in-memory AccountFlagsContainer, improving performance and consistency. Updates flag modification logic to update both the in-memory store and the database asynchronously. Adjusts related function signatures and usage to reflect the new approach.
12 tasks
12 tasks
Contributor
|
It is not thread safe to be accessing or modifying a global container in the socket (network threads) |
Member
Author
|
Aight, how would I go about making it threadsafe? |
Member
Author
|
Would a mutex suffice for that? |
Account flag management functions and storage have been removed from AccountMgr and implemented as member functions in WorldSession. WorldSession now stores account flags per session, and related logic is updated accordingly. This change improves encapsulation and reduces global state.
12 tasks
Moved HasAccountFlag implementation to header as an inline method and added GetAccountFlags accessor. This improves code clarity and provides direct access to account flags.
Member
Author
|
Right, now it is stored per session and not globally. Thanks :) |
Member
Author
sudlud
approved these changes
Jul 26, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Replaces direct database queries for account flags with an in-memory AccountFlagsContainer, improving performance and consistency. Updates flag modification logic to update both the in-memory store and the database asynchronously. Adjusts related function signatures and usage to reflect the new approach.
Changes Proposed:
This PR proposes changes to:
This pull request refactors the handling of account flags in the login and session management system. The changes consolidate account flag management logic, improve code organization, and streamline database interactions. The most important updates include replacing redundant database statements, removing unused methods, and introducing new methods in the
WorldSessionclass for flag validation and updates.Database Changes:
LOGIN_UPD_ADD_ACCOUNT_FLAGandLOGIN_UPD_REMOVE_ACCOUNT_FLAGwith a singleLOGIN_UPD_SET_ACCOUNT_FLAGstatement for updating account flags in the database (src/server/database/Database/Implementation/LoginDatabase.cpp,src/server/database/Database/Implementation/LoginDatabase.h). [1] [2]Codebase Simplification:
HasAccountFlag,UpdateAccountFlag, andValidateAccountFlagsmethods fromAccountMgras they are no longer needed (src/server/game/Accounts/AccountMgr.cpp,src/server/game/Accounts/AccountMgr.h). [1] [2]AccountMgr::ValidateAccountFlagsinWorldSocket::HandleAuthSessionCallbackand replaced it with a call to the newWorldSession::ValidateAccountFlagsmethod (src/server/game/Server/WorldSocket.cpp). [1] [2]New Functionality in
WorldSession:_accountFlagsas a member ofWorldSessionto store account flags in memory (src/server/game/Server/WorldSession.h).GetAccountFlags,HasAccountFlag,UpdateAccountFlag, andValidateAccountFlagsmethods inWorldSessionto manage and validate account flags directly (src/server/game/Server/WorldSession.h,src/server/game/Server/WorldSession.cpp). [1] [2]Constructor Updates:
WorldSessionconstructor to acceptaccountFlagsas a parameter and initialize the_accountFlagsmember (src/server/game/Server/WorldSession.cpp,src/server/game/Server/WorldSession.h). [1] [2] [3]Issues Addressed:
SOURCE:
The changes have been validated through:
Tests Performed:
This PR has been:
How to Test the Changes:
Known Issues and TODO List:
How to Test AzerothCore PRs
When a PR is ready to be tested, it will be marked as [WAITING TO BE TESTED].
You can help by testing PRs and writing your feedback here on the PR's page on GitHub. Follow the instructions here:
http://www.azerothcore.org/wiki/How-to-test-a-PR
REMEMBER: when testing a PR that changes something generic (i.e. a part of code that handles more than one specific thing), the tester should not only check that the PR does its job (e.g. fixing spell XXX) but especially check that the PR does not cause any regression (i.e. introducing new bugs).
For example: if a PR fixes spell X by changing a part of code that handles spells X, Y, and Z, we should not only test X, but we should test Y and Z as well.