From fc78c48495661dc1e8393c637028971c8126a680 Mon Sep 17 00:00:00 2001 From: Spp Date: Mon, 25 Feb 2013 13:40:56 +0100 Subject: Core/RBAC: Create new permissions 'Notify if a command was not found' and 'Enables lower security than target check' --- src/server/game/Chat/Chat.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/server/game/Chat') diff --git a/src/server/game/Chat/Chat.cpp b/src/server/game/Chat/Chat.cpp index 3cae9d0f83a..7c92af2d67f 100644 --- a/src/server/game/Chat/Chat.cpp +++ b/src/server/game/Chat/Chat.cpp @@ -175,7 +175,7 @@ bool ChatHandler::HasLowerSecurityAccount(WorldSession* target, uint32 target_ac return false; // ignore only for non-players for non strong checks (when allow apply command at least to same sec level) - if (!AccountMgr::IsPlayerAccount(m_session->GetSecurity()) && !strong && !sWorld->getBoolConfig(CONFIG_GM_LOWER_SECURITY)) + if (m_session->HasPermission(RBAC_PERM_CHECK_FOR_LOWER_SECURITY) && !strong && !sWorld->getBoolConfig(CONFIG_GM_LOWER_SECURITY)) return false; if (target) @@ -361,6 +361,7 @@ bool ChatHandler::ExecuteCommandInTable(ChatCommand* table, const char* text, co // table[i].Name == "" is special case: send original command to handler if ((table[i].Handler)(this, table[i].Name[0] != '\0' ? text : oldtext)) { + // FIXME: When Command system is moved to RBAC this check must be changed if (!AccountMgr::IsPlayerAccount(table[i].SecurityLevel)) { // chat case @@ -476,7 +477,7 @@ bool ChatHandler::ParseCommands(char const* text) if (!ExecuteCommandInTable(getCommandTable(), text, fullcmd)) { - if (m_session && AccountMgr::IsPlayerAccount(m_session->GetSecurity())) + if (m_session && !m_session->HasPermission(RBAC_PERM_COMMANDS_NOTIFY_COMMAND_NOT_FOUND_ERROR)) return false; SendSysMessage(LANG_NO_CMD); -- cgit v1.2.3 From f67330e2ad348e39068a22fa072825d682b825c9 Mon Sep 17 00:00:00 2001 From: Spp Date: Mon, 25 Feb 2013 14:37:13 +0100 Subject: Core/RBAC: Create new permissions 'Allow channel chat between factions', 'Join channels without announce' (both need config option enabled and permission set) and 'Change channel settings without being channel moderator' --- sql/updates/auth/2013_02_25_12_auth_misc.sql | 34 +++++++++++++++++++++++ src/server/game/Accounts/RBAC.h | 3 ++ src/server/game/Chat/Channels/Channel.cpp | 41 ++++++++++++++-------------- 3 files changed, 58 insertions(+), 20 deletions(-) create mode 100644 sql/updates/auth/2013_02_25_12_auth_misc.sql (limited to 'src/server/game/Chat') diff --git a/sql/updates/auth/2013_02_25_12_auth_misc.sql b/sql/updates/auth/2013_02_25_12_auth_misc.sql new file mode 100644 index 00000000000..9d2f01a917d --- /dev/null +++ b/sql/updates/auth/2013_02_25_12_auth_misc.sql @@ -0,0 +1,34 @@ +-- Add new permissions +DELETE FROM `rbac_permissions` WHERE `id` IN (26, 46, 46); +INSERT INTO `rbac_permissions` (`id`, `name`) VALUES +(26, 'Allow channel chat between factions'), +(46, 'Join channels without announce'), +(46, 'Change channel settings without being channel moderator'); + +-- Add new role +DELETE FROM `rbac_roles` WHERE `id` IN (30, 31, 32); +INSERT INTO `rbac_roles` (`id`, `name`) VALUES +(30, 'Allow channel chat between factions'), +(31, 'Join channels without announce'), +(32, 'Change channel settings without being channel moderator'); + +-- Add the permission to the role +DELETE FROM `rbac_role_permissions` WHERE `roleId` IN (30, 31, 32); +INSERT INTO `rbac_role_permissions` (`roleId`, `permissionId`) VALUES +(30, 26), +(31, 46), +(32, 4645); + +-- Add it to all GM+ groups +DELETE FROM `rbac_role_permissions` WHERE `roleId` IN (30, 31, 32); +INSERT INTO `rbac_group_roles` (`groupId`, `roleId`) VALUES +(1, 30), +(2, 30), +(3, 30), +(4, 30), +(2, 31), +(3, 31), +(4, 31), +(2, 32), +(3, 32), +(4, 32); diff --git a/src/server/game/Accounts/RBAC.h b/src/server/game/Accounts/RBAC.h index 568c72303a4..f20734a1994 100644 --- a/src/server/game/Accounts/RBAC.h +++ b/src/server/game/Accounts/RBAC.h @@ -66,6 +66,7 @@ enum RBACPermissions RBAC_PERM_SKIP_CHECK_CHAT_SPAM = 22, RBAC_PERM_SKIP_CHECK_OVERSPEED_PING = 23, RBAC_PERM_TWO_SIDE_INTERACTION_CHAT = 25, + RBAC_PERM_TWO_SIDE_INTERACTION_CHANNEL = 26, RBAC_PERM_TWO_SIDE_INTERACTION_MAIL = 27, RBAC_PERM_COMMANDS_SAVE_WITHOUT_DELAY = 30, RBAC_PERM_COMMANDS_USE_UNSTUCK_WITH_ARGS = 31, @@ -80,6 +81,8 @@ enum RBACPermissions RBAC_PERM_OPCODE_WORLD_TELEPORT = 42, RBAC_PERM_OPCODE_WHOIS = 43, RBAC_PERM_RECEIVE_GLOBAL_GM_TEXTMESSAGE = 44, + RBAC_PERM_SILENTLY_JOIN_CHANNEL = 45, + RBAC_PERM_CHANGE_CHANNEL_NOT_MODERATOR = 46, RBAC_PERM_CHECK_FOR_LOWER_SECURITY = 47, RBAC_PERM_MAX }; diff --git a/src/server/game/Chat/Channels/Channel.cpp b/src/server/game/Chat/Channels/Channel.cpp index 9e7a63c9093..50ac4f66dec 100644 --- a/src/server/game/Chat/Channels/Channel.cpp +++ b/src/server/game/Chat/Channels/Channel.cpp @@ -180,7 +180,7 @@ void Channel::JoinChannel(Player* player, std::string const& pass) if (HasFlag(CHANNEL_FLAG_LFG) && sWorld->getBoolConfig(CONFIG_RESTRICTED_LFG_CHANNEL) && - AccountMgr::IsPlayerAccount(player->GetSession()->GetSecurity()) && + AccountMgr::IsPlayerAccount(player->GetSession()->GetSecurity()) && //FIXME: Move to RBAC player->GetGroup()) { WorldPacket data; @@ -191,8 +191,8 @@ void Channel::JoinChannel(Player* player, std::string const& pass) player->JoinedChannel(this); - if (_announce && (!AccountMgr::IsGMAccount(player->GetSession()->GetSecurity()) || - !sWorld->getBoolConfig(CONFIG_SILENTLY_GM_JOIN_TO_CHANNEL))) + if (_announce && (!sWorld->getBoolConfig(CONFIG_SILENTLY_GM_JOIN_TO_CHANNEL) || + !player->GetSession()->HasPermission(RBAC_PERM_SILENTLY_JOIN_CHANNEL))) { WorldPacket data; MakeJoined(&data, guid); @@ -252,8 +252,9 @@ void Channel::LeaveChannel(Player* player, bool send) bool changeowner = playersStore[guid].IsOwner(); playersStore.erase(guid); - if (_announce && (!AccountMgr::IsGMAccount(player->GetSession()->GetSecurity()) || - !sWorld->getBoolConfig(CONFIG_SILENTLY_GM_JOIN_TO_CHANNEL))) + + if (_announce && (!sWorld->getBoolConfig(CONFIG_SILENTLY_GM_JOIN_TO_CHANNEL) || + !player->GetSession()->HasPermission(RBAC_PERM_SILENTLY_JOIN_CHANNEL))) { WorldPacket data; MakeLeft(&data, guid); @@ -279,7 +280,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(); uint64 good = player->GetGUID(); if (!IsOn(good)) @@ -290,7 +290,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()->HasPermission(RBAC_PERM_CHANGE_CHANNEL_NOT_MODERATOR)) { WorldPacket data; MakeNotModerator(&data); @@ -310,7 +310,7 @@ void Channel::KickOrBan(Player const* player, std::string const& badname, bool b bool changeowner = _ownerGUID == victim; - if (!AccountMgr::IsGMAccount(sec) && changeowner && good != _ownerGUID) + if (!player->GetSession()->HasPermission(RBAC_PERM_CHANGE_CHANNEL_NOT_MODERATOR) && changeowner && good != _ownerGUID) { WorldPacket data; MakeNotOwner(&data); @@ -318,7 +318,7 @@ void Channel::KickOrBan(Player const* player, std::string const& badname, bool b return; } - bool notify = !(AccountMgr::IsGMAccount(sec) && sWorld->getBoolConfig(CONFIG_SILENTLY_GM_JOIN_TO_CHANNEL)); + bool notify = !sWorld->getBoolConfig(CONFIG_SILENTLY_GM_JOIN_TO_CHANNEL) || !player->GetSession()->HasPermission(RBAC_PERM_SILENTLY_JOIN_CHANNEL); if (ban && !IsBanned(victim)) { @@ -404,7 +404,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()->HasPermission(RBAC_PERM_CHANGE_CHANNEL_NOT_MODERATOR)) { WorldPacket data; MakeNotModerator(&data); @@ -424,7 +424,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) { uint64 guid = player->GetGUID(); - uint32 sec = player->GetSession()->GetSecurity(); if (!IsOn(guid)) { @@ -434,7 +433,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()->HasPermission(RBAC_PERM_CHANGE_CHANNEL_NOT_MODERATOR)) { WorldPacket data; MakeNotModerator(&data); @@ -449,10 +448,11 @@ void Channel::SetMode(Player const* player, std::string const& p2n, bool mod, bo uint64 victim = newp ? newp->GetGUID() : 0; if (!victim || !IsOn(victim) || + (player->GetTeam() != newp->GetTeam() && (!sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_CHANNEL) || + !player->GetSession()->HasPermission(RBAC_PERM_TWO_SIDE_INTERACTION_CHANNEL) || + !newp->GetSession()->HasPermission(RBAC_PERM_TWO_SIDE_INTERACTION_CHANNEL)))) // 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->GetTeam() != newp->GetTeam() && !sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_CHANNEL))) { WorldPacket data; MakePlayerNotFound(&data, p2n); @@ -477,7 +477,6 @@ void Channel::SetMode(Player const* player, std::string const& p2n, bool mod, bo void Channel::SetOwner(Player const* player, std::string const& newname) { uint64 guid = player->GetGUID(); - uint32 sec = player->GetSession()->GetSecurity(); if (!IsOn(guid)) { @@ -487,7 +486,7 @@ void Channel::SetOwner(Player const* player, std::string const& newname) return; } - if (!AccountMgr::IsGMAccount(sec) && guid != _ownerGUID) + if (!player->GetSession()->HasPermission(RBAC_PERM_CHANGE_CHANNEL_NOT_MODERATOR) && guid != _ownerGUID) { WorldPacket data; MakeNotOwner(&data); @@ -570,7 +569,6 @@ void Channel::List(Player const* player) void Channel::Announce(Player const* player) { uint64 guid = player->GetGUID(); - uint32 sec = player->GetSession()->GetSecurity(); if (!IsOn(guid)) { @@ -580,7 +578,7 @@ void Channel::Announce(Player const* player) return; } - if (!playersStore[guid].IsModerator() && !AccountMgr::IsGMAccount(sec)) + if (!playersStore[guid].IsModerator() && !player->GetSession()->HasPermission(RBAC_PERM_CHANGE_CHANNEL_NOT_MODERATOR)) { WorldPacket data; MakeNotModerator(&data); @@ -605,6 +603,10 @@ void Channel::Say(uint64 guid, std::string const& what, uint32 lang) if (what.empty()) return; + uint8 chatTag = 0; + if (Player* player = ObjectAccessor::FindPlayer(guid)) + chatTag = player->GetChatTag(); + if (sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_CHANNEL)) lang = LANG_UNIVERSAL; @@ -633,8 +635,7 @@ void Channel::Say(uint64 guid, std::string const& what, uint32 lang) data << uint64(guid); data << uint32(what.size() + 1); data << what; - Player* player = ObjectAccessor::FindPlayer(guid); - data << uint8(player ? player->GetChatTag() : 0); + data << uint8(chatTag); SendToAll(&data, !playersStore[guid].IsModerator() ? guid : false); } -- cgit v1.2.3 From fb9893a190a76d964b3b833d4f80e2a01c3cbf65 Mon Sep 17 00:00:00 2001 From: Spp Date: Mon, 25 Feb 2013 15:37:20 +0100 Subject: Add missing change related to permission 'Two side interaction channel' --- src/server/game/Chat/Channels/Channel.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/server/game/Chat') diff --git a/src/server/game/Chat/Channels/Channel.cpp b/src/server/game/Chat/Channels/Channel.cpp index 50ac4f66dec..ce155bc6bad 100644 --- a/src/server/game/Chat/Channels/Channel.cpp +++ b/src/server/game/Chat/Channels/Channel.cpp @@ -607,6 +607,7 @@ void Channel::Say(uint64 guid, std::string const& what, uint32 lang) if (Player* player = ObjectAccessor::FindPlayer(guid)) chatTag = player->GetChatTag(); + // TODO: Add proper RBAC check if (sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_CHANNEL)) lang = LANG_UNIVERSAL; @@ -669,7 +670,9 @@ void Channel::Invite(Player const* player, std::string const& newname) return; } - if (newp->GetTeam() != player->GetTeam() && !sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_CHANNEL)) + if (newp->GetTeam() != player->GetTeam() && (!sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_CHANNEL) || + !player->GetSession()->HasPermission(RBAC_PERM_TWO_SIDE_INTERACTION_CHANNEL) || + !newp->GetSession()->HasPermission(RBAC_PERM_TWO_SIDE_INTERACTION_CHANNEL))) { WorldPacket data; MakeInviteWrongFaction(&data); -- cgit v1.2.3 From 0c2402df955091f73898713c45c3f02cd8c25adf Mon Sep 17 00:00:00 2001 From: Spp Date: Mon, 25 Feb 2013 15:47:12 +0100 Subject: Core/RBAC: Create new permissions 'See two side who list', 'Add friends of other faction', 'See all levels with who command' and 'Allows to add a gm to friend list' --- sql/updates/auth/2013_02_25_14_auth_misc.sql | 39 +++++++++++++++ src/server/game/Accounts/RBAC.h | 5 ++ src/server/game/Chat/Channels/Channel.cpp | 4 +- src/server/game/Entities/Player/SocialMgr.cpp | 71 ++++++++++++++------------- src/server/game/Handlers/MiscHandler.cpp | 45 +++++++++-------- 5 files changed, 107 insertions(+), 57 deletions(-) create mode 100644 sql/updates/auth/2013_02_25_14_auth_misc.sql (limited to 'src/server/game/Chat') diff --git a/sql/updates/auth/2013_02_25_14_auth_misc.sql b/sql/updates/auth/2013_02_25_14_auth_misc.sql new file mode 100644 index 00000000000..c02b600b12f --- /dev/null +++ b/sql/updates/auth/2013_02_25_14_auth_misc.sql @@ -0,0 +1,39 @@ +-- Add new permissions +DELETE FROM `rbac_permissions` WHERE `id` IN (28, 29, 35, 40); +INSERT INTO `rbac_permissions` (`id`, `name`) VALUES +(28, 'See two side who list'), +(29, 'Add friends of other faction'), +(35, 'See all security levels with who command'), +(40, 'Allows to add a gm to friend list'); + +-- Add new role +DELETE FROM `rbac_roles` WHERE `id` IN (33, 34); +INSERT INTO `rbac_roles` (`id`, `name`) VALUES +(35, 'See two side who list'), +(36, 'Add friends of other faction'), +(37, 'See all security levels with who command'), +(38, 'Allows to add a gm to friend list'); + +-- Add the permission to the role +DELETE FROM `rbac_role_permissions` WHERE `roleId` IN (35, 36, 37, 38); +INSERT INTO `rbac_role_permissions` (`roleId`, `permissionId`) VALUES +(35, 28), +(36, 29), +(37, 35), +(38, 40); + +-- Add it to all groups +DELETE FROM `rbac_role_permissions` WHERE `roleId` IN (35, 36, 37, 38); +INSERT INTO `rbac_group_roles` (`groupId`, `roleId`) VALUES +(2, 35), +(3, 35), +(4, 35), +(2, 36), +(3, 36), +(4, 36), +(2, 37), +(3, 37), +(4, 37), +(2, 38), +(3, 38), +(4, 38); diff --git a/src/server/game/Accounts/RBAC.h b/src/server/game/Accounts/RBAC.h index eb9220a317a..0bd193d3841 100644 --- a/src/server/game/Accounts/RBAC.h +++ b/src/server/game/Accounts/RBAC.h @@ -59,6 +59,7 @@ enum RBACPermissions RBAC_PERM_GAMEMASTER_COMMANDS = 9, RBAC_PERM_ADMINISTRATOR_COMMANDS = 10, RBAC_PERM_LOG_GM_TRADE = 11, + // Free = 12 RBAC_PERM_SKIP_CHECK_INSTANCE_REQUIRED_BOSSES = 13, RBAC_PERM_SKIP_CHECK_CHARACTER_CREATION_TEAMMASK = 14, RBAC_PERM_SKIP_CHECK_CHARACTER_CREATION_CLASSMASK = 15, @@ -74,15 +75,19 @@ enum RBACPermissions RBAC_PERM_TWO_SIDE_INTERACTION_CHAT = 25, RBAC_PERM_TWO_SIDE_INTERACTION_CHANNEL = 26, RBAC_PERM_TWO_SIDE_INTERACTION_MAIL = 27, + RBAC_PERM_TWO_SIDE_WHO_LIST = 28, + RBAC_PERM_TWO_SIDE_ADD_FRIEND = 29, RBAC_PERM_COMMANDS_SAVE_WITHOUT_DELAY = 30, RBAC_PERM_COMMANDS_USE_UNSTUCK_WITH_ARGS = 31, RBAC_PERM_COMMANDS_BE_ASSIGNED_TICKET = 32, RBAC_PERM_COMMANDS_NOTIFY_COMMAND_NOT_FOUND_ERROR = 33, RBAC_PERM_COMMANDS_APPEAR_IN_GM_LIST = 34, + RBAC_PERM_WHO_SEE_ALL_SEC_LEVELS = 35, RBAC_PERM_CAN_FILTER_WHISPERS = 36, RBAC_PERM_CHAT_USE_STAFF_BADGE = 37, RBAC_PERM_RESURRECT_WITH_FULL_HPS = 38, RBAC_PERM_RESTORE_SAVED_GM_STATE = 39, + RBAC_PERM_ALLOW_GM_FRIEND = 40, RBAC_PERM_USE_START_GM_LEVEL = 41, RBAC_PERM_OPCODE_WORLD_TELEPORT = 42, RBAC_PERM_OPCODE_WHOIS = 43, diff --git a/src/server/game/Chat/Channels/Channel.cpp b/src/server/game/Chat/Channels/Channel.cpp index ce155bc6bad..86d03859bc7 100644 --- a/src/server/game/Chat/Channels/Channel.cpp +++ b/src/server/game/Chat/Channels/Channel.cpp @@ -552,7 +552,9 @@ void Channel::List(Player const* player) // PLAYER can't see MODERATOR, GAME MASTER, ADMINISTRATOR characters // MODERATOR, GAME MASTER, ADMINISTRATOR can see all - if (member && (!AccountMgr::IsPlayerAccount(player->GetSession()->GetSecurity()) || member->GetSession()->GetSecurity() <= AccountTypes(gmLevelInWhoList)) && + if (member && + (player->GetSession()->HasPermission(RBAC_PERM_WHO_SEE_ALL_SEC_LEVELS) || + member->GetSession()->GetSecurity() <= AccountTypes(gmLevelInWhoList)) && member->IsVisibleGloballyFor(player)) { data << uint64(i->first); diff --git a/src/server/game/Entities/Player/SocialMgr.cpp b/src/server/game/Entities/Player/SocialMgr.cpp index e5bbac59e00..7a2b36e23bf 100644 --- a/src/server/game/Entities/Player/SocialMgr.cpp +++ b/src/server/game/Entities/Player/SocialMgr.cpp @@ -216,34 +216,38 @@ void SocialMgr::GetFriendInfo(Player* player, uint32 friendGUID, FriendInfo &fri friendInfo.Level = 0; friendInfo.Class = 0; - Player* pFriend = ObjectAccessor::FindPlayer(friendGUID); - if (!pFriend) + Player* target = ObjectAccessor::FindPlayer(friendGUID); + if (!target) return; - uint32 team = player->GetTeam(); - AccountTypes security = player->GetSession()->GetSecurity(); - bool allowTwoSideWhoList = sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_WHO_LIST); - AccountTypes gmLevelInWhoList = AccountTypes(sWorld->getIntConfig(CONFIG_GM_LEVEL_IN_WHO_LIST)); - PlayerSocialMap::iterator itr = player->GetSocial()->m_playerSocialMap.find(friendGUID); if (itr != player->GetSocial()->m_playerSocialMap.end()) friendInfo.Note = itr->second.Note; // PLAYER see his team only and PLAYER can't see MODERATOR, GAME MASTER, ADMINISTRATOR characters // MODERATOR, GAME MASTER, ADMINISTRATOR can see all - if (pFriend && - (!AccountMgr::IsPlayerAccount(security) || - ((pFriend->GetTeam() == team || allowTwoSideWhoList) && (pFriend->GetSession()->GetSecurity() <= gmLevelInWhoList))) && - pFriend->IsVisibleGloballyFor(player)) + + if (!player->GetSession()->HasPermission(RBAC_PERM_WHO_SEE_ALL_SEC_LEVELS) && + target->GetSession()->GetSecurity() > AccountTypes(sWorld->getIntConfig(CONFIG_GM_LEVEL_IN_WHO_LIST))) + return; + + // player can see member of other team only if CONFIG_ALLOW_TWO_SIDE_WHO_LIST + if (target->GetTeam() != player->GetTeam() && + !sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_WHO_LIST) && !player->GetSession()->HasPermission(RBAC_PERM_TWO_SIDE_WHO_LIST)) + return; + + if (target->IsVisibleGloballyFor(player)) { - friendInfo.Status = FRIEND_STATUS_ONLINE; - if (pFriend->isAFK()) - friendInfo.Status = FRIEND_STATUS_AFK; - if (pFriend->isDND()) + if (target->isDND()) friendInfo.Status = FRIEND_STATUS_DND; - friendInfo.Area = pFriend->GetZoneId(); - friendInfo.Level = pFriend->getLevel(); - friendInfo.Class = pFriend->getClass(); + else if (target->isAFK()) + friendInfo.Status = FRIEND_STATUS_AFK; + else + friendInfo.Status = FRIEND_STATUS_ONLINE; + + friendInfo.Area = target->GetZoneId(); + friendInfo.Level = target->getLevel(); + friendInfo.Class = target->getClass(); } } @@ -295,28 +299,29 @@ void SocialMgr::BroadcastToFriendListers(Player* player, WorldPacket* packet) if (!player) return; - uint32 team = player->GetTeam(); - AccountTypes security = player->GetSession()->GetSecurity(); - uint32 guid = player->GetGUIDLow(); - AccountTypes gmLevelInWhoList = AccountTypes(sWorld->getIntConfig(CONFIG_GM_LEVEL_IN_WHO_LIST)); - bool allowTwoSideWhoList = sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_WHO_LIST); - for (SocialMap::const_iterator itr = m_socialMap.begin(); itr != m_socialMap.end(); ++itr) { - PlayerSocialMap::const_iterator itr2 = itr->second.m_playerSocialMap.find(guid); + PlayerSocialMap::const_iterator itr2 = itr->second.m_playerSocialMap.find(player->GetGUID()); if (itr2 != itr->second.m_playerSocialMap.end() && (itr2->second.Flags & SOCIAL_FLAG_FRIEND)) { - Player* pFriend = ObjectAccessor::FindPlayer(MAKE_NEW_GUID(itr->first, 0, HIGHGUID_PLAYER)); + Player* target = ObjectAccessor::FindPlayer(MAKE_NEW_GUID(itr->first, 0, HIGHGUID_PLAYER)); + if (!target || !target->IsInWorld()) + continue; + + if (!target->GetSession()->HasPermission(RBAC_PERM_WHO_SEE_ALL_SEC_LEVELS) && + player->GetSession()->GetSecurity() > AccountTypes(sWorld->getIntConfig(CONFIG_GM_LEVEL_IN_WHO_LIST))) + continue; + + // player can see member of other team only if CONFIG_ALLOW_TWO_SIDE_WHO_LIST + if (target->GetTeam() != player->GetTeam() && + !sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_WHO_LIST) && + !target->GetSession()->HasPermission(RBAC_PERM_TWO_SIDE_WHO_LIST)) + continue; // 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() && - (!AccountMgr::IsPlayerAccount(pFriend->GetSession()->GetSecurity()) || - ((pFriend->GetTeam() == team || allowTwoSideWhoList) && security <= gmLevelInWhoList)) && - player->IsVisibleGloballyFor(pFriend)) - { - pFriend->GetSession()->SendPacket(packet); - } + if (player->IsVisibleGloballyFor(target)) + target->GetSession()->SendPacket(packet); } } } diff --git a/src/server/game/Handlers/MiscHandler.cpp b/src/server/game/Handlers/MiscHandler.cpp index 45cf1d17450..3864acb8f88 100644 --- a/src/server/game/Handlers/MiscHandler.cpp +++ b/src/server/game/Handlers/MiscHandler.cpp @@ -241,7 +241,7 @@ void WorldSession::HandleWhoOpcode(WorldPacket& recvData) level_max = STRONG_MAX_LEVEL; uint32 team = _player->GetTeam(); - uint32 security = GetSecurity(); + bool allowTwoSideWhoList = sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_WHO_LIST); uint32 gmLevelInWhoList = sWorld->getIntConfig(CONFIG_GM_LEVEL_IN_WHO_LIST); uint32 displaycount = 0; @@ -254,42 +254,40 @@ void WorldSession::HandleWhoOpcode(WorldPacket& recvData) HashMapHolder::MapType const& m = sObjectAccessor->GetPlayers(); for (HashMapHolder::MapType::const_iterator itr = m.begin(); itr != m.end(); ++itr) { - if (AccountMgr::IsPlayerAccount(security)) - { - // player can see member of other team only if CONFIG_ALLOW_TWO_SIDE_WHO_LIST - if (itr->second->GetTeam() != team && !allowTwoSideWhoList) - continue; + Player* target = itr->second; + // player can see member of other team only if CONFIG_ALLOW_TWO_SIDE_WHO_LIST + if (target->GetTeam() != team && !allowTwoSideWhoList && !HasPermission(RBAC_PERM_TWO_SIDE_WHO_LIST)) + continue; - // player can see MODERATOR, GAME MASTER, ADMINISTRATOR only if CONFIG_GM_IN_WHO_LIST - if ((itr->second->GetSession()->GetSecurity() > AccountTypes(gmLevelInWhoList))) - continue; - } + // player can see MODERATOR, GAME MASTER, ADMINISTRATOR only if CONFIG_GM_IN_WHO_LIST + if (!HasPermission(RBAC_PERM_WHO_SEE_ALL_SEC_LEVELS) && target->GetSession()->GetSecurity() > AccountTypes(gmLevelInWhoList)) + continue; - //do not process players which are not in world - if (!(itr->second->IsInWorld())) + // do not process players which are not in world + if (!target->IsInWorld()) continue; // check if target is globally visible for player - if (!(itr->second->IsVisibleGloballyFor(_player))) + if (!target->IsVisibleGloballyFor(_player)) continue; // check if target's level is in level range - uint8 lvl = itr->second->getLevel(); + uint8 lvl = target->getLevel(); if (lvl < level_min || lvl > level_max) continue; // check if class matches classmask - uint32 class_ = itr->second->getClass(); + uint8 class_ = target->getClass(); if (!(classmask & (1 << class_))) continue; // check if race matches racemask - uint32 race = itr->second->getRace(); + uint32 race = target->getRace(); if (!(racemask & (1 << race))) continue; - uint32 pzoneid = itr->second->GetZoneId(); - uint8 gender = itr->second->getGender(); + uint32 pzoneid = target->GetZoneId(); + uint8 gender = target->getGender(); bool z_show = true; for (uint32 i = 0; i < zones_count; ++i) @@ -305,7 +303,7 @@ void WorldSession::HandleWhoOpcode(WorldPacket& recvData) if (!z_show) continue; - std::string pname = itr->second->GetName(); + std::string pname = target->GetName(); std::wstring wpname; if (!Utf8toWStr(pname, wpname)) continue; @@ -314,7 +312,7 @@ void WorldSession::HandleWhoOpcode(WorldPacket& recvData) if (!(wplayer_name.empty() || wpname.find(wplayer_name) != std::wstring::npos)) continue; - std::string gname = sGuildMgr->GetGuildNameById(itr->second->GetGuildId()); + std::string gname = sGuildMgr->GetGuildNameById(target->GetGuildId()); std::wstring wgname; if (!Utf8toWStr(gname, wgname)) continue; @@ -324,7 +322,7 @@ void WorldSession::HandleWhoOpcode(WorldPacket& recvData) continue; std::string aname; - if (AreaTableEntry const* areaEntry = GetAreaEntryByAreaID(itr->second->GetZoneId())) + if (AreaTableEntry const* areaEntry = GetAreaEntryByAreaID(pzoneid)) aname = areaEntry->area_name[GetSessionDbcLocale()]; bool s_show = true; @@ -575,13 +573,14 @@ void WorldSession::HandleAddFriendOpcodeCallBack(PreparedQueryResult result, std team = Player::TeamForRace(fields[1].GetUInt8()); friendAccountId = fields[2].GetUInt32(); - if (!AccountMgr::IsPlayerAccount(GetSecurity()) || sWorld->getBoolConfig(CONFIG_ALLOW_GM_FRIEND) || AccountMgr::IsPlayerAccount(AccountMgr::GetSecurity(friendAccountId, realmID))) + if (HasPermission(RBAC_PERM_ALLOW_GM_FRIEND) || sWorld->getBoolConfig(CONFIG_ALLOW_GM_FRIEND) || + AccountMgr::IsPlayerAccount(AccountMgr::GetSecurity(friendAccountId, realmID))) { if (friendGuid) { if (friendGuid == GetPlayer()->GetGUID()) friendResult = FRIEND_SELF; - else if (GetPlayer()->GetTeam() != team && !sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_ADD_FRIEND) && AccountMgr::IsPlayerAccount(GetSecurity())) + else if (GetPlayer()->GetTeam() != team && !sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_ADD_FRIEND) && !HasPermission(RBAC_PERM_TWO_SIDE_ADD_FRIEND)) friendResult = FRIEND_ENEMY; else if (GetPlayer()->GetSocial()->HasFriend(GUID_LOPART(friendGuid))) friendResult = FRIEND_ALREADY; -- cgit v1.2.3 From d47b95cc0a09c7fd5c10b6e2a7bb9d33d7f11db1 Mon Sep 17 00:00:00 2001 From: Spp Date: Mon, 25 Feb 2013 15:51:48 +0100 Subject: Missing change related to permission 'Change channel settings' --- src/server/game/Chat/Channels/Channel.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/server/game/Chat') diff --git a/src/server/game/Chat/Channels/Channel.cpp b/src/server/game/Chat/Channels/Channel.cpp index 86d03859bc7..5f6bc8b7865 100644 --- a/src/server/game/Chat/Channels/Channel.cpp +++ b/src/server/game/Chat/Channels/Channel.cpp @@ -363,7 +363,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()->HasPermission(RBAC_PERM_CHANGE_CHANNEL_NOT_MODERATOR)) { WorldPacket data; MakeNotModerator(&data); -- cgit v1.2.3