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
|
||||
|
||||
@@ -1138,7 +1138,7 @@ class Player : public Unit, public GridObject<Player>
|
||||
void SetAcceptWhispers(bool on) { if (on) m_ExtraFlags |= PLAYER_EXTRA_ACCEPT_WHISPERS; else m_ExtraFlags &= ~PLAYER_EXTRA_ACCEPT_WHISPERS; }
|
||||
bool isGameMaster() const { return m_ExtraFlags & PLAYER_EXTRA_GM_ON; }
|
||||
void SetGameMaster(bool on);
|
||||
bool isGMChat() const { return GetSession()->GetSecurity() >= SEC_MODERATOR && (m_ExtraFlags & PLAYER_EXTRA_GM_CHAT); }
|
||||
bool isGMChat() const { return m_ExtraFlags & PLAYER_EXTRA_GM_CHAT; }
|
||||
void SetGMChat(bool on) { if (on) m_ExtraFlags |= PLAYER_EXTRA_GM_CHAT; else m_ExtraFlags &= ~PLAYER_EXTRA_GM_CHAT; }
|
||||
bool isTaxiCheater() const { return m_ExtraFlags & PLAYER_EXTRA_TAXICHEAT; }
|
||||
void SetTaxiCheater(bool on) { if (on) m_ExtraFlags |= PLAYER_EXTRA_TAXICHEAT; else m_ExtraFlags &= ~PLAYER_EXTRA_TAXICHEAT; }
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
#include "ObjectMgr.h"
|
||||
#include "World.h"
|
||||
#include "Util.h"
|
||||
#include "AccountMgr.h"
|
||||
|
||||
PlayerSocial::PlayerSocial()
|
||||
{
|
||||
@@ -197,7 +198,7 @@ void SocialMgr::GetFriendInfo(Player* player, uint32 friendGUID, FriendInfo &fri
|
||||
// PLAYER see his team only and PLAYER can't see MODERATOR, GAME MASTER, ADMINISTRATOR characters
|
||||
// MODERATOR, GAME MASTER, ADMINISTRATOR can see all
|
||||
if (pFriend && pFriend->GetName() &&
|
||||
(security > SEC_PLAYER ||
|
||||
(!AccountMgr::IsPlayerAccount(security) ||
|
||||
((pFriend->GetTeam() == team || allowTwoSideWhoList) && (pFriend->GetSession()->GetSecurity() <= gmLevelInWhoList))) &&
|
||||
pFriend->IsVisibleGloballyFor(player))
|
||||
{
|
||||
@@ -276,7 +277,7 @@ void SocialMgr::BroadcastToFriendListers(Player* player, WorldPacket* packet)
|
||||
// PLAYER see his team only and PLAYER can't see MODERATOR, GAME MASTER, ADMINISTRATOR characters
|
||||
// MODERATOR, GAME MASTER, ADMINISTRATOR can see all
|
||||
if (pFriend && pFriend->IsInWorld() &&
|
||||
(pFriend->GetSession()->GetSecurity() > SEC_PLAYER ||
|
||||
(!AccountMgr::IsPlayerAccount(pFriend->GetSession()->GetSecurity()) ||
|
||||
((pFriend->GetTeam() == team || allowTwoSideWhoList) && security <= gmLevelInWhoList)) &&
|
||||
player->IsVisibleGloballyFor(pFriend))
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user