Core: Define helper functions to know if an account is Player, Moderator, GM, Admin or Console
This commit is contained in:
@@ -73,6 +73,7 @@
|
||||
#include "CharacterDatabaseCleaner.h"
|
||||
#include "InstanceScript.h"
|
||||
#include <cmath>
|
||||
#include "AccountMgr.h"
|
||||
|
||||
#define ZONE_UPDATE_INTERVAL (1*IN_MILLISECONDS)
|
||||
|
||||
@@ -654,7 +655,7 @@ Player::Player (WorldSession *session): Unit(), m_achievementMgr(this), m_reputa
|
||||
//m_pad = 0;
|
||||
|
||||
// players always accept
|
||||
if (GetSession()->GetSecurity() == SEC_PLAYER)
|
||||
if (AccountMgr::IsPlayerAccount(GetSession()->GetSecurity()))
|
||||
SetAcceptWhispers(true);
|
||||
|
||||
m_curSelection = 0;
|
||||
@@ -996,7 +997,7 @@ bool Player::Create(uint32 guidlow, CharacterCreateInfo* createInfo)
|
||||
? sWorld->getIntConfig(CONFIG_START_PLAYER_LEVEL)
|
||||
: sWorld->getIntConfig(CONFIG_START_HEROIC_PLAYER_LEVEL);
|
||||
|
||||
if (GetSession()->GetSecurity() >= SEC_MODERATOR)
|
||||
if (!AccountMgr::IsPlayerAccount(GetSession()->GetSecurity()))
|
||||
{
|
||||
uint32 gm_level = sWorld->getIntConfig(CONFIG_START_GM_LEVEL);
|
||||
if (gm_level > start_level)
|
||||
@@ -2085,7 +2086,7 @@ bool Player::TeleportTo(uint32 mapid, float x, float y, float z, float orientati
|
||||
return false;
|
||||
}
|
||||
|
||||
if ((GetSession()->GetSecurity() < SEC_GAMEMASTER) && sDisableMgr->IsDisabledFor(DISABLE_TYPE_MAP, mapid, this))
|
||||
if (AccountMgr::IsPlayerAccount(GetSession()->GetSecurity()) && sDisableMgr->IsDisabledFor(DISABLE_TYPE_MAP, mapid, this))
|
||||
{
|
||||
sLog->outError("Player (GUID: %u, name: %s) tried to enter a forbidden map %u", GetGUIDLow(), GetName(), mapid);
|
||||
SendTransferAborted(mapid, TRANSFER_ABORT_MAP_NOT_ALLOWED);
|
||||
@@ -3116,7 +3117,7 @@ void Player::InitTalentForLevel()
|
||||
// if used more that have then reset
|
||||
if (m_usedTalentCount > talentPointsForLevel)
|
||||
{
|
||||
if (GetSession()->GetSecurity() < SEC_ADMINISTRATOR)
|
||||
if (!AccountMgr::IsAdminAccount(GetSession()->GetSecurity()))
|
||||
resetTalents(true);
|
||||
else
|
||||
SetFreeTalentPoints(0);
|
||||
@@ -16510,7 +16511,7 @@ bool Player::LoadFromDB(uint32 guid, SQLQueryHolder *holder)
|
||||
|
||||
// check name limitations
|
||||
if (ObjectMgr::CheckPlayerName(m_name) != CHAR_NAME_SUCCESS ||
|
||||
(GetSession()->GetSecurity() == SEC_PLAYER && sObjectMgr->IsReservedName(m_name)))
|
||||
(AccountMgr::IsPlayerAccount(GetSession()->GetSecurity()) && sObjectMgr->IsReservedName(m_name)))
|
||||
{
|
||||
CharacterDatabase.PExecute("UPDATE characters SET at_login = at_login | '%u' WHERE guid ='%u'", uint32(AT_LOGIN_RENAME), guid);
|
||||
return false;
|
||||
@@ -17038,7 +17039,7 @@ bool Player::LoadFromDB(uint32 guid, SQLQueryHolder *holder)
|
||||
outDebugValues();
|
||||
|
||||
// GM state
|
||||
if (GetSession()->GetSecurity() > SEC_PLAYER)
|
||||
if (!AccountMgr::IsPlayerAccount(GetSession()->GetSecurity()))
|
||||
{
|
||||
switch (sWorld->getIntConfig(CONFIG_GM_LOGIN_STATE))
|
||||
{
|
||||
@@ -18940,7 +18941,7 @@ void Player::outDebugValues() const
|
||||
void Player::UpdateSpeakTime()
|
||||
{
|
||||
// ignore chat spam protection for GMs in any mode
|
||||
if (GetSession()->GetSecurity() > SEC_PLAYER)
|
||||
if (!AccountMgr::IsPlayerAccount(GetSession()->GetSecurity()))
|
||||
return;
|
||||
|
||||
time_t current = time (NULL);
|
||||
@@ -21118,7 +21119,7 @@ bool Player::IsVisibleGloballyFor(Player* u) const
|
||||
return true;
|
||||
|
||||
// GMs are visible for higher gms (or players are visible for gms)
|
||||
if (u->GetSession()->GetSecurity() > SEC_PLAYER)
|
||||
if (!AccountMgr::IsPlayerAccount(u->GetSession()->GetSecurity()))
|
||||
return GetSession()->GetSecurity() <= u->GetSession()->GetSecurity();
|
||||
|
||||
// non faction visibility non-breakable for non-GMs
|
||||
|
||||
Reference in New Issue
Block a user