diff --git a/src/server/game/Accounts/AccountMgr.cpp b/src/server/game/Accounts/AccountMgr.cpp index 39847b6ae..852102d4b 100644 --- a/src/server/game/Accounts/AccountMgr.cpp +++ b/src/server/game/Accounts/AccountMgr.cpp @@ -278,11 +278,6 @@ namespace AccountMgr return gmlevel == SEC_PLAYER; } - bool IsGMAccount(uint32 gmlevel) - { - return gmlevel >= SEC_MODERATOR && gmlevel <= SEC_CONSOLE; - } - bool IsAdminAccount(uint32 gmlevel) { return gmlevel >= SEC_ADMINISTRATOR && gmlevel <= SEC_CONSOLE; diff --git a/src/server/game/Accounts/AccountMgr.h b/src/server/game/Accounts/AccountMgr.h index 96e06c1a2..2f203093f 100644 --- a/src/server/game/Accounts/AccountMgr.h +++ b/src/server/game/Accounts/AccountMgr.h @@ -49,7 +49,6 @@ namespace AccountMgr uint32 GetCharactersCount(uint32 accountId); bool IsPlayerAccount(uint32 gmlevel); - bool IsGMAccount(uint32 gmlevel); bool IsAdminAccount(uint32 gmlevel); bool IsConsoleAccount(uint32 gmlevel); }; diff --git a/src/server/game/Chat/Channels/Channel.cpp b/src/server/game/Chat/Channels/Channel.cpp index dbc8e9e9e..645e74d0c 100644 --- a/src/server/game/Chat/Channels/Channel.cpp +++ b/src/server/game/Chat/Channels/Channel.cpp @@ -221,7 +221,7 @@ void Channel::JoinChannel(Player* player, std::string const& pass) JoinNotify(player); - playersStore[guid].SetOwnerGM(AccountMgr::IsGMAccount(player->GetSession()->GetSecurity())); + playersStore[guid].SetOwnerGM(player->GetSession()->IsGMAccount()); // Custom channel handling if (!IsConstant()) @@ -299,7 +299,7 @@ void Channel::LeaveChannel(Player* player, bool send) for (Channel::PlayerContainer::const_iterator itr = playersStore.begin(); itr != playersStore.end(); ++itr) { newowner = itr->second.player; - if (AccountMgr::IsGMAccount(itr->second.plrPtr->GetSession()->GetSecurity())) + if (itr->second.plrPtr->GetSession()->IsGMAccount()) _isOwnerGM = true; else _isOwnerGM = false; @@ -317,7 +317,6 @@ void Channel::LeaveChannel(Player* player, bool send) void Channel::KickOrBan(Player const* player, std::string const& badname, bool ban) { - AccountTypes sec = player->GetSession()->GetSecurity(); ObjectGuid good = player->GetGUID(); if (!IsOn(good)) @@ -328,7 +327,7 @@ void Channel::KickOrBan(Player const* player, std::string const& badname, bool b return; } - if (!playersStore[good].IsModerator() && !AccountMgr::IsGMAccount(sec)) + if (!playersStore[good].IsModerator() && !player->GetSession()->IsGMAccount()) { WorldPacket data; MakeNotModerator(&data); @@ -341,19 +340,17 @@ void Channel::KickOrBan(Player const* player, std::string const& badname, bool b ObjectGuid victim; uint32 badAccId = 0; - uint32 badSecurity = 0; Player* bad = ObjectAccessor::FindPlayerByName(badname, false); if (bad) { victim = bad->GetGUID(); badAccId = bad->GetSession()->GetAccountId(); - badSecurity = bad->GetSession()->GetSecurity(); } bool isOnChannel = victim && IsOn(victim); if (!isOnChannel) { - if (ban && (AccountMgr::IsGMAccount(sec) || isGoodConstantModerator)) + if (ban && (player->GetSession()->IsGMAccount() || isGoodConstantModerator)) { if (ObjectGuid guid = sCharacterCache->GetCharacterGuidByName(badname)) { @@ -393,7 +390,7 @@ void Channel::KickOrBan(Player const* player, std::string const& badname, bool b bool changeowner = _ownerGUID == victim; bool isBadConstantModerator = _channelRights.moderators.find(badAccId) != _channelRights.moderators.end(); - if (!AccountMgr::IsGMAccount(sec) && !isGoodConstantModerator) + if (!player->GetSession()->IsGMAccount() && !isGoodConstantModerator) { if (changeowner && good != _ownerGUID) { @@ -411,7 +408,7 @@ void Channel::KickOrBan(Player const* player, std::string const& badname, bool b return; } - if (isBadConstantModerator || AccountMgr::IsGMAccount(badSecurity)) + if (isBadConstantModerator || bad->GetSession()->IsGMAccount()) { WorldPacket data; MakeNotModerator(&data); @@ -472,7 +469,6 @@ void Channel::KickOrBan(Player const* player, std::string const& badname, bool b void Channel::UnBan(Player const* player, std::string const& badname) { - uint32 sec = player->GetSession()->GetSecurity(); ObjectGuid good = player->GetGUID(); if (!IsOn(good)) @@ -483,7 +479,7 @@ void Channel::UnBan(Player const* player, std::string const& badname) return; } - if (!playersStore[good].IsModerator() && !AccountMgr::IsGMAccount(sec)) + if (!playersStore[good].IsModerator() && !player->GetSession()->IsGMAccount()) { WorldPacket data; MakeNotModerator(&data); @@ -506,7 +502,7 @@ void Channel::UnBan(Player const* player, std::string const& badname) } bool isConstantModerator = _channelRights.moderators.find(player->GetSession()->GetAccountId()) != _channelRights.moderators.end(); - if (!AccountMgr::IsGMAccount(sec) && !isConstantModerator) + if (!player->GetSession()->IsGMAccount() && !isConstantModerator) { if (_channelRights.flags & CHANNEL_RIGHT_CANT_BAN) { @@ -551,7 +547,7 @@ void Channel::Password(Player const* player, std::string const& pass) return; } - if (!playersStore[guid].IsModerator() && !AccountMgr::IsGMAccount(player->GetSession()->GetSecurity())) + if (!playersStore[guid].IsModerator() && !player->GetSession()->IsGMAccount()) { WorldPacket data; MakeNotModerator(&data); @@ -579,7 +575,6 @@ void Channel::Password(Player const* player, std::string const& pass) void Channel::SetMode(Player const* player, std::string const& p2n, bool mod, bool set) { ObjectGuid guid = player->GetGUID(); - uint32 sec = player->GetSession()->GetSecurity(); if (!IsOn(guid)) { @@ -589,7 +584,7 @@ void Channel::SetMode(Player const* player, std::string const& p2n, bool mod, bo return; } - if (!playersStore[guid].IsModerator() && !AccountMgr::IsGMAccount(sec)) + if (!playersStore[guid].IsModerator() && !player->GetSession()->IsGMAccount()) { WorldPacket data; MakeNotModerator(&data); @@ -606,7 +601,7 @@ void Channel::SetMode(Player const* player, std::string const& p2n, bool mod, bo if (!victim || !IsOn(victim) || // allow make moderator from another team only if both is GMs // at this moment this only way to show channel post for GM from another team - ((!AccountMgr::IsGMAccount(sec) || !AccountMgr::IsGMAccount(newp->GetSession()->GetSecurity())) && player->GetTeamId() != newp->GetTeamId() && + ((!player->GetSession()->IsGMAccount() || !newp->GetSession()->IsGMAccount()) && player->GetTeamId() != newp->GetTeamId() && !sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_CHANNEL))) { WorldPacket data; @@ -632,7 +627,7 @@ void Channel::SetMode(Player const* player, std::string const& p2n, bool mod, bo else { bool isGoodConstantModerator = _channelRights.moderators.find(player->GetSession()->GetAccountId()) != _channelRights.moderators.end(); - if (!AccountMgr::IsGMAccount(sec) && !isGoodConstantModerator) + if (!player->GetSession()->IsGMAccount() && !isGoodConstantModerator) { if (_channelRights.flags & CHANNEL_RIGHT_CANT_MUTE) { @@ -650,7 +645,6 @@ void Channel::SetMode(Player const* player, std::string const& p2n, bool mod, bo void Channel::SetOwner(Player const* player, std::string const& newname) { ObjectGuid guid = player->GetGUID(); - uint32 sec = player->GetSession()->GetSecurity(); if (!IsOn(guid)) { @@ -661,7 +655,7 @@ void Channel::SetOwner(Player const* player, std::string const& newname) } bool isGoodConstantModerator = _channelRights.moderators.find(player->GetSession()->GetAccountId()) != _channelRights.moderators.end(); - if (!AccountMgr::IsGMAccount(sec) && guid != _ownerGUID && !isGoodConstantModerator) + if (!player->GetSession()->IsGMAccount() && guid != _ownerGUID && !isGoodConstantModerator) { WorldPacket data; MakeNotOwner(&data); @@ -733,7 +727,6 @@ void Channel::List(Player const* player) void Channel::Announce(Player const* player) { ObjectGuid guid = player->GetGUID(); - uint32 sec = player->GetSession()->GetSecurity(); if (!IsOn(guid)) { @@ -743,7 +736,7 @@ void Channel::Announce(Player const* player) return; } - if (!playersStore[guid].IsModerator() && !AccountMgr::IsGMAccount(sec)) + if (!playersStore[guid].IsModerator() && !player->GetSession()->IsGMAccount()) { WorldPacket data; MakeNotModerator(&data); @@ -940,7 +933,7 @@ void Channel::SendToAllWatching(WorldPacket* data) bool Channel::ShouldAnnouncePlayer(Player const* player) const { - return !(AccountMgr::IsGMAccount(player->GetSession()->GetSecurity()) && sWorld->getBoolConfig(CONFIG_SILENTLY_GM_JOIN_TO_CHANNEL)); + return !(player->GetSession()->IsGMAccount() && sWorld->getBoolConfig(CONFIG_SILENTLY_GM_JOIN_TO_CHANNEL)); } void Channel::Voice(ObjectGuid /*guid1*/, ObjectGuid /*guid2*/) diff --git a/src/server/game/Entities/GameObject/GameObject.cpp b/src/server/game/Entities/GameObject/GameObject.cpp index aa164d4f7..5145bd97e 100644 --- a/src/server/game/Entities/GameObject/GameObject.cpp +++ b/src/server/game/Entities/GameObject/GameObject.cpp @@ -2798,7 +2798,7 @@ void GameObject::BuildValuesUpdate(uint8 updateType, ByteBuffer* data, Player* t return; bool forcedFlags = GetGoType() == GAMEOBJECT_TYPE_CHEST && GetGOInfo()->chest.groupLootRules && HasLootRecipient(); - bool targetIsGM = target->IsGameMaster() && AccountMgr::IsGMAccount(target->GetSession()->GetSecurity()); + bool targetIsGM = target->IsGameMaster() && target->GetSession()->IsGMAccount(); ByteBuffer fieldBuffer; diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp index 5a2860613..922cb3fa0 100644 --- a/src/server/game/Entities/Player/Player.cpp +++ b/src/server/game/Entities/Player/Player.cpp @@ -2192,14 +2192,14 @@ void Player::SetGameMaster(bool on) if (on) { m_ExtraFlags |= PLAYER_EXTRA_GM_ON; - if (AccountMgr::IsGMAccount(GetSession()->GetSecurity())) + if (GetSession()->IsGMAccount()) SetFaction(FACTION_FRIENDLY); SetPlayerFlag(PLAYER_FLAGS_GM); SetUnitFlag2(UNIT_FLAG2_ALLOW_CHEAT_SPELLS); if (Pet* pet = GetPet()) { - if (AccountMgr::IsGMAccount(GetSession()->GetSecurity())) + if (GetSession()->IsGMAccount()) pet->SetFaction(FACTION_FRIENDLY); pet->getHostileRefMgr().setOnlineOfflineState(false); } diff --git a/src/server/game/Entities/Player/SocialMgr.cpp b/src/server/game/Entities/Player/SocialMgr.cpp index 2893c99f7..487e41117 100644 --- a/src/server/game/Entities/Player/SocialMgr.cpp +++ b/src/server/game/Entities/Player/SocialMgr.cpp @@ -220,7 +220,7 @@ void SocialMgr::GetFriendInfo(Player* player, ObjectGuid friendGUID, FriendInfo& friendInfo.Class = 0; Player* pFriend = ObjectAccessor::FindConnectedPlayer(friendGUID); - if (!pFriend || AccountMgr::IsGMAccount(pFriend->GetSession()->GetSecurity())) + if (!pFriend || pFriend->GetSession()->IsGMAccount()) return; TeamId teamId = player->GetTeamId(); diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp index bf4a32d3d..91f6c275b 100644 --- a/src/server/game/Entities/Unit/Unit.cpp +++ b/src/server/game/Entities/Unit/Unit.cpp @@ -21142,7 +21142,7 @@ void Unit::BuildValuesUpdate(uint8 updateType, ByteBuffer* data, Player* target) else if (index == UNIT_FIELD_FLAGS) { uint32 appendValue = m_uint32Values[UNIT_FIELD_FLAGS]; - if (target->IsGameMaster() && AccountMgr::IsGMAccount(target->GetSession()->GetSecurity())) + if (target->IsGameMaster() && target->GetSession()->IsGMAccount()) appendValue &= ~UNIT_FLAG_NOT_SELECTABLE; fieldBuffer << uint32(appendValue); @@ -21167,7 +21167,7 @@ void Unit::BuildValuesUpdate(uint8 updateType, ByteBuffer* data, Player* target) if (cinfo->flags_extra & CREATURE_FLAG_EXTRA_TRIGGER) { - if (target->IsGameMaster() && AccountMgr::IsGMAccount(target->GetSession()->GetSecurity())) + if (target->IsGameMaster() && target->GetSession()->IsGMAccount()) { if (cinfo->Modelid1) displayId = cinfo->Modelid1; // Modelid1 is a visible model for gms diff --git a/src/server/game/Handlers/Socialhandler.cpp b/src/server/game/Handlers/Socialhandler.cpp index 5a0860cca..5a4557cc9 100644 --- a/src/server/game/Handlers/Socialhandler.cpp +++ b/src/server/game/Handlers/Socialhandler.cpp @@ -70,7 +70,7 @@ void WorldSession::HandleAddFriendOpcode(WorldPacket& recv_data) else { Player* pFriend = ObjectAccessor::FindConnectedPlayer(friendGuid); - if (pFriend && pFriend->IsVisibleGloballyFor(GetPlayer()) && !AccountMgr::IsGMAccount(pFriend->GetSession()->GetSecurity())) + if (pFriend && pFriend->IsVisibleGloballyFor(GetPlayer()) && !pFriend->GetSession()->IsGMAccount()) friendResult = FRIEND_ADDED_ONLINE; else friendResult = FRIEND_ADDED_OFFLINE; diff --git a/src/server/game/Server/WorldSession.cpp b/src/server/game/Server/WorldSession.cpp index 5ff13beca..7a830e00b 100644 --- a/src/server/game/Server/WorldSession.cpp +++ b/src/server/game/Server/WorldSession.cpp @@ -175,6 +175,11 @@ WorldSession::~WorldSession() LoginDatabase.Execute("UPDATE account SET online = 0 WHERE id = {};", GetAccountId()); // One-time query } +bool WorldSession::IsGMAccount() const +{ + return GetSecurity() >= SEC_GAMEMASTER; +} + std::string const& WorldSession::GetPlayerName() const { return _player ? _player->GetName() : DefaultPlayerName; diff --git a/src/server/game/Server/WorldSession.h b/src/server/game/Server/WorldSession.h index 0830a0bf5..89d0b4731 100644 --- a/src/server/game/Server/WorldSession.h +++ b/src/server/game/Server/WorldSession.h @@ -332,6 +332,8 @@ public: WorldSession(uint32 id, std::string&& name, std::shared_ptr sock, AccountTypes sec, uint8 expansion, time_t mute_time, LocaleConstant locale, uint32 recruiter, bool isARecruiter, bool skipQueue, uint32 TotalTime); ~WorldSession(); + bool IsGMAccount() const; + bool PlayerLoading() const { return m_playerLoading; } bool PlayerLogout() const { return m_playerLogout; } bool PlayerRecentlyLoggedOut() const { return m_playerRecentlyLogout; }