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'

This commit is contained in:
Spp
2013-02-25 15:48:19 +01:00
parent fb9893a190
commit 0c2402df95
5 changed files with 107 additions and 57 deletions
@@ -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);
+5
View File
@@ -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,
+3 -1
View File
@@ -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);
+38 -33
View File
@@ -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);
}
}
}
+22 -23
View File
@@ -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<Player>::MapType const& m = sObjectAccessor->GetPlayers();
for (HashMapHolder<Player>::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;