refactor(Core/Account): Move account flag logic from AccountMgr to WorldSession (#22558)
This commit is contained in:
@@ -299,39 +299,6 @@ namespace AccountMgr
|
||||
return false;
|
||||
}
|
||||
|
||||
bool HasAccountFlag(uint32 accountId, uint32 flag)
|
||||
{
|
||||
LoginDatabasePreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_SEL_ACCOUNT_FLAG);
|
||||
stmt->SetData(0, accountId);
|
||||
if (PreparedQueryResult result = LoginDatabase.Query(stmt))
|
||||
{
|
||||
uint32 flags = (*result)[0].Get<uint32>();
|
||||
return (flags & flag) != 0;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void UpdateAccountFlag(uint32 accountId, uint32 flag, bool remove /*= false*/)
|
||||
{
|
||||
LoginDatabasePreparedStatement* stmt = LoginDatabase.GetPreparedStatement(
|
||||
remove ? LOGIN_UPD_REMOVE_ACCOUNT_FLAG : LOGIN_UPD_ADD_ACCOUNT_FLAG
|
||||
);
|
||||
stmt->SetData(0, flag);
|
||||
stmt->SetData(1, accountId);
|
||||
LoginDatabase.Execute(stmt);
|
||||
}
|
||||
|
||||
void ValidateAccountFlags(uint32 accountId, uint32 flags, uint32 security)
|
||||
{
|
||||
bool hasGMFlag = (flags & ACCOUNT_FLAG_GM) != 0;
|
||||
|
||||
if (IsGMAccount(security) && !hasGMFlag)
|
||||
UpdateAccountFlag(accountId, ACCOUNT_FLAG_GM);
|
||||
else if (hasGMFlag && !IsGMAccount(security))
|
||||
UpdateAccountFlag(accountId, ACCOUNT_FLAG_GM, true);
|
||||
}
|
||||
|
||||
uint32 GetCharactersCount(uint32 accountId)
|
||||
{
|
||||
// check character count
|
||||
|
||||
@@ -56,10 +56,6 @@ namespace AccountMgr
|
||||
bool IsGMAccount(uint32 gmlevel);
|
||||
bool IsAdminAccount(uint32 gmlevel);
|
||||
bool IsConsoleAccount(uint32 gmlevel);
|
||||
|
||||
bool HasAccountFlag(uint32 accountId, uint32 flag);
|
||||
void UpdateAccountFlag(uint32 accountId, uint32 flag, bool remove = false);
|
||||
void ValidateAccountFlags(uint32 accountId, uint32 flags, uint32 security);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user