Core/RBAC: Create new permission 'Receive global GM messages/texts'
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
-- Add new permissions
|
||||
DELETE FROM `rbac_permissions` WHERE `id` IN (34, 37);
|
||||
INSERT INTO `rbac_permissions` (`id`, `name`) VALUES
|
||||
(34, 'Check if shoul appear in list using .gm ingame command'),
|
||||
(34, 'Check if should appear in list using .gm ingame command'),
|
||||
(37, 'Use staff badge in chat');
|
||||
|
||||
-- Add new role
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
-- Add new permission
|
||||
DELETE FROM `rbac_permissions` WHERE `id` = 44;
|
||||
INSERT INTO `rbac_permissions` (`id`, `name`) VALUES (44, 'Receive global GM messages/texts');
|
||||
|
||||
-- Add new role
|
||||
DELETE FROM `rbac_roles` WHERE `id` = 16;
|
||||
INSERT INTO `rbac_roles` (`id`, `name`) VALUES (16, 'Receive global GM messages/texts');
|
||||
|
||||
-- Add the permission to the role
|
||||
DELETE FROM `rbac_role_permissions` WHERE `roleId` = 16;
|
||||
INSERT INTO `rbac_role_permissions` (`roleId`, `permissionId`) VALUES (16, 44);
|
||||
|
||||
-- Add it to all GM+ groups
|
||||
DELETE FROM `rbac_group_roles` WHERE `roleId` = 16;
|
||||
INSERT INTO `rbac_group_roles` (`groupId`, `roleId`) VALUES
|
||||
(2, 16),
|
||||
(3, 16),
|
||||
(4, 16);
|
||||
@@ -66,6 +66,7 @@ enum RBACPermissions
|
||||
RBAC_PERM_COMMANDS_APPEAR_IN_GM_LIST = 34,
|
||||
RBAC_PERM_CHAT_USE_STAFF_BADGE = 37,
|
||||
RBAC_PERM_RESURRECT_WITH_FULL_HPS = 38,
|
||||
RBAC_PERM_RECEIVE_GLOBAL_GM_TEXTMESSAGE = 44,
|
||||
RBAC_PERM_MAX
|
||||
};
|
||||
|
||||
|
||||
@@ -2118,18 +2118,21 @@ void World::SendGlobalMessage(WorldPacket* packet, WorldSession* self, uint32 te
|
||||
/// Send a packet to all GMs (except self if mentioned)
|
||||
void World::SendGlobalGMMessage(WorldPacket* packet, WorldSession* self, uint32 team)
|
||||
{
|
||||
SessionMap::iterator itr;
|
||||
for (itr = m_sessions.begin(); itr != m_sessions.end(); ++itr)
|
||||
for (SessionMap::const_iterator itr = m_sessions.begin(); itr != m_sessions.end(); ++itr)
|
||||
{
|
||||
if (itr->second &&
|
||||
itr->second->GetPlayer() &&
|
||||
itr->second->GetPlayer()->IsInWorld() &&
|
||||
itr->second != self &&
|
||||
!AccountMgr::IsPlayerAccount(itr->second->GetSecurity()) &&
|
||||
(team == 0 || itr->second->GetPlayer()->GetTeam() == team))
|
||||
{
|
||||
itr->second->SendPacket(packet);
|
||||
}
|
||||
// check if session and can receive global GM Messages and its not self
|
||||
WorldSession* session = itr->second;
|
||||
if (!session || session == self || !session->HasPermission(RBAC_PERM_RECEIVE_GLOBAL_GM_TEXTMESSAGE))
|
||||
continue;
|
||||
|
||||
// Player should be in world
|
||||
Player* player = session->GetPlayer();
|
||||
if (!player || !player->IsInWorld())
|
||||
continue;
|
||||
|
||||
// Send only to same team, if team is given
|
||||
if (!team || player->GetTeam() == team)
|
||||
session->SendPacket(packet);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2217,15 +2220,19 @@ void World::SendGMText(int32 string_id, ...)
|
||||
|
||||
Trinity::WorldWorldTextBuilder wt_builder(string_id, &ap);
|
||||
Trinity::LocalizedPacketListDo<Trinity::WorldWorldTextBuilder> wt_do(wt_builder);
|
||||
for (SessionMap::iterator itr = m_sessions.begin(); itr != m_sessions.end(); ++itr)
|
||||
for (SessionMap::const_iterator itr = m_sessions.begin(); itr != m_sessions.end(); ++itr)
|
||||
{
|
||||
if (!itr->second || !itr->second->GetPlayer() || !itr->second->GetPlayer()->IsInWorld())
|
||||
// Session should have permissions to receive global gm messages
|
||||
WorldSession* session = itr->second;
|
||||
if (!session || !session->HasPermission(RBAC_PERM_RECEIVE_GLOBAL_GM_TEXTMESSAGE))
|
||||
continue;
|
||||
|
||||
if (AccountMgr::IsPlayerAccount(itr->second->GetSecurity()))
|
||||
// Player should be in world
|
||||
Player* player = session->GetPlayer();
|
||||
if (!player || !player->IsInWorld())
|
||||
continue;
|
||||
|
||||
wt_do(itr->second->GetPlayer());
|
||||
wt_do(player);
|
||||
}
|
||||
|
||||
va_end(ap);
|
||||
|
||||
Reference in New Issue
Block a user