aboutsummaryrefslogtreecommitdiff
path: root/src/server/game/Accounts/AccountMgr.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/server/game/Accounts/AccountMgr.cpp')
-rw-r--r--src/server/game/Accounts/AccountMgr.cpp16
1 files changed, 9 insertions, 7 deletions
diff --git a/src/server/game/Accounts/AccountMgr.cpp b/src/server/game/Accounts/AccountMgr.cpp
index 310c0c19289..36c2e7955cb 100644
--- a/src/server/game/Accounts/AccountMgr.cpp
+++ b/src/server/game/Accounts/AccountMgr.cpp
@@ -283,23 +283,25 @@ uint32 AccountMgr::GetId(std::string const& username)
return (result) ? (*result)[0].GetUInt32() : 0;
}
-uint32 AccountMgr::GetSecurity(uint32 accountId)
+uint32 AccountMgr::GetSecurity(uint32 accountId, int32 realmId)
{
- LoginDatabasePreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_GET_ACCOUNT_ACCESS_GMLEVEL);
+ LoginDatabasePreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_GET_GMLEVEL_BY_REALMID);
stmt->setUInt32(0, accountId);
+ stmt->setInt32(1, realmId);
PreparedQueryResult result = LoginDatabase.Query(stmt);
return (result) ? (*result)[0].GetUInt8() : uint32(SEC_PLAYER);
}
-uint32 AccountMgr::GetSecurity(uint32 accountId, int32 realmId)
+QueryCallback AccountMgr::GetSecurityAsync(uint32 accountId, int32 realmId, std::function<void(uint32)> callback)
{
LoginDatabasePreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_GET_GMLEVEL_BY_REALMID);
stmt->setUInt32(0, accountId);
stmt->setInt32(1, realmId);
- PreparedQueryResult result = LoginDatabase.Query(stmt);
-
- return (result) ? (*result)[0].GetUInt8() : uint32(SEC_PLAYER);
+ return LoginDatabase.AsyncQuery(stmt).WithPreparedCallback([callback = std::move(callback)](PreparedQueryResult result)
+ {
+ callback(result ? uint32((*result)[0].GetUInt8()) : uint32(SEC_PLAYER));
+ });
}
bool AccountMgr::GetName(uint32 accountId, std::string& name)
@@ -548,7 +550,7 @@ bool AccountMgr::HasPermission(uint32 accountId, uint32 permissionId, uint32 rea
return false;
}
- rbac::RBACData rbac(accountId, "", realmId, GetSecurity(accountId));
+ rbac::RBACData rbac(accountId, "", realmId, GetSecurity(accountId, realmId));
rbac.LoadFromDB();
bool hasPermission = rbac.HasPermission(permissionId);