Core/RBAC: Add .reload rbac command and prevent possible crash if rbac_permissions has wrong data

This commit is contained in:
Spp
2013-02-27 03:30:53 +01:00
parent 4ea31ce886
commit 480c6cf4dd
13 changed files with 255 additions and 29 deletions
+17 -3
View File
@@ -1175,11 +1175,13 @@ void WorldSession::LoadPermissions()
{
uint32 id = GetAccountId();
std::string name;
int32 realmId = ConfigMgr::GetIntDefault("RealmID", 0);
AccountMgr::GetName(id, name);
_RBACData = new RBACData(id, name, realmId);
_RBACData = new RBACData(id, name, realmID);
_RBACData->LoadFromDB();
sLog->outDebug(LOG_FILTER_RBAC, "WorldSession::LoadPermissions [AccountId: %u, Name: %s, realmId: %d]",
id, name.c_str(), realmID);
}
RBACData* WorldSession::GetRBACData()
@@ -1192,5 +1194,17 @@ bool WorldSession::HasPermission(uint32 permission)
if (!_RBACData)
LoadPermissions();
return _RBACData->HasPermission(permission);
bool hasPermission = _RBACData->HasPermission(permission);
sLog->outDebug(LOG_FILTER_RBAC, "WorldSession::HasPermission [AccountId: %u, Name: %s, realmId: %d]",
_RBACData->GetId(), _RBACData->GetName().c_str(), realmID);
return hasPermission;
}
void WorldSession::InvalidateRBACData()
{
sLog->outDebug(LOG_FILTER_RBAC, "WorldSession::InvalidateRBACData [AccountId: %u, Name: %s, realmId: %d]",
_RBACData->GetId(), _RBACData->GetName().c_str(), realmID);
delete _RBACData;
_RBACData = NULL;
}