diff options
| author | Spp- <spp@jorge.gr> | 2011-09-08 15:11:55 +0200 |
|---|---|---|
| committer | Spp- <spp@jorge.gr> | 2011-09-08 15:11:55 +0200 |
| commit | 327fe7c24776d73499f07a91be65b752b03bb838 (patch) | |
| tree | 23664a2a7aaf3435221e1f3da5008b5178453af0 /src/server/game/Chat | |
| parent | d5cbc973730b2d52644c2090e000ef6f096b8c44 (diff) | |
Core: Define helper functions to know if an account is Player, Moderator, GM, Admin or Console
Diffstat (limited to 'src/server/game/Chat')
| -rwxr-xr-x | src/server/game/Chat/Channels/Channel.cpp | 25 | ||||
| -rwxr-xr-x | src/server/game/Chat/Chat.cpp | 8 | ||||
| -rwxr-xr-x | src/server/game/Chat/Commands/Level0.cpp | 2 | ||||
| -rwxr-xr-x | src/server/game/Chat/Commands/Level3.cpp | 2 | ||||
| -rwxr-xr-x | src/server/game/Chat/Commands/TicketCommands.cpp | 4 |
5 files changed, 21 insertions, 20 deletions
diff --git a/src/server/game/Chat/Channels/Channel.cpp b/src/server/game/Chat/Channels/Channel.cpp index d39018e69a4..d2665b65226 100755 --- a/src/server/game/Chat/Channels/Channel.cpp +++ b/src/server/game/Chat/Channels/Channel.cpp @@ -22,6 +22,7 @@ #include "SocialMgr.h" #include "World.h" #include "DatabaseEnv.h" +#include "AccountMgr.h" Channel::Channel(const std::string& name, uint32 channel_id, uint32 Team) : m_announce(true), m_ownership(true), m_name(name), m_password(""), m_flags(0), m_channelId(channel_id), m_ownerGUID(0), m_Team(Team) @@ -173,7 +174,7 @@ void Channel::Join(uint64 p, const char *pass) if (plr) { if (HasFlag(CHANNEL_FLAG_LFG) && - sWorld->getBoolConfig(CONFIG_RESTRICTED_LFG_CHANNEL) && plr->GetSession()->GetSecurity() == SEC_PLAYER && plr->GetGroup()) + sWorld->getBoolConfig(CONFIG_RESTRICTED_LFG_CHANNEL) && AccountMgr::IsPlayerAccount(plr->GetSession()->GetSecurity()) && plr->GetGroup()) { MakeNotInLfg(&data); SendToOne(&data, p); @@ -183,7 +184,7 @@ void Channel::Join(uint64 p, const char *pass) plr->JoinedChannel(this); } - if (m_announce && (!plr || plr->GetSession()->GetSecurity() < SEC_GAMEMASTER || !sWorld->getBoolConfig(CONFIG_SILENTLY_GM_JOIN_TO_CHANNEL))) + if (m_announce && (!plr || !AccountMgr::IsGMAccount(plr->GetSession()->GetSecurity()) || !sWorld->getBoolConfig(CONFIG_SILENTLY_GM_JOIN_TO_CHANNEL))) { MakeJoined(&data, p); SendToAll(&data); @@ -245,7 +246,7 @@ void Channel::Leave(uint64 p, bool send) bool changeowner = players[p].IsOwner(); players.erase(p); - if (m_announce && (!plr || plr->GetSession()->GetSecurity() < SEC_GAMEMASTER || !sWorld->getBoolConfig(CONFIG_SILENTLY_GM_JOIN_TO_CHANNEL))) + if (m_announce && (!plr || !AccountMgr::IsGMAccount(plr->GetSession()->GetSecurity()) || !sWorld->getBoolConfig(CONFIG_SILENTLY_GM_JOIN_TO_CHANNEL))) { WorldPacket data; MakeLeft(&data, p); @@ -283,7 +284,7 @@ void Channel::KickOrBan(uint64 good, const char *badname, bool ban) MakeNotMember(&data); SendToOne(&data, good); } - else if (!players[good].IsModerator() && sec < SEC_GAMEMASTER) + else if (!players[good].IsModerator() && !AccountMgr::IsGMAccount(sec)) { WorldPacket data; MakeNotModerator(&data); @@ -298,7 +299,7 @@ void Channel::KickOrBan(uint64 good, const char *badname, bool ban) MakePlayerNotFound(&data, badname); SendToOne(&data, good); } - else if (sec < SEC_GAMEMASTER && bad->GetGUID() == m_ownerGUID && good != m_ownerGUID) + else if (!AccountMgr::IsGMAccount(sec) && bad->GetGUID() == m_ownerGUID && good != m_ownerGUID) { WorldPacket data; MakeNotOwner(&data); @@ -347,7 +348,7 @@ void Channel::UnBan(uint64 good, const char *badname) MakeNotMember(&data); SendToOne(&data, good); } - else if (!players[good].IsModerator() && sec < SEC_GAMEMASTER) + else if (!players[good].IsModerator() && !AccountMgr::IsGMAccount(sec)) { WorldPacket data; MakeNotModerator(&data); @@ -390,7 +391,7 @@ void Channel::Password(uint64 p, const char *pass) MakeNotMember(&data); SendToOne(&data, p); } - else if (!players[p].IsModerator() && sec < SEC_GAMEMASTER) + else if (!players[p].IsModerator() && !AccountMgr::IsGMAccount(sec)) { WorldPacket data; MakeNotModerator(&data); @@ -422,7 +423,7 @@ void Channel::SetMode(uint64 p, const char *p2n, bool mod, bool set) MakeNotMember(&data); SendToOne(&data, p); } - else if (!players[p].IsModerator() && sec < SEC_GAMEMASTER) + else if (!players[p].IsModerator() && !AccountMgr::IsGMAccount(sec)) { WorldPacket data; MakeNotModerator(&data); @@ -452,7 +453,7 @@ void Channel::SetMode(uint64 p, const char *p2n, bool mod, bool set) // 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 - if ((plr->GetSession()->GetSecurity() < SEC_GAMEMASTER || newp->GetSession()->GetSecurity() < SEC_GAMEMASTER) && + if ((!AccountMgr::IsGMAccount(plr->GetSession()->GetSecurity()) || !AccountMgr::IsGMAccount(newp->GetSession()->GetSecurity())) && plr->GetTeam() != newp->GetTeam() && !sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_CHANNEL)) { WorldPacket data; @@ -492,7 +493,7 @@ void Channel::SetOwner(uint64 p, const char *newname) return; } - if (sec < SEC_GAMEMASTER && p != m_ownerGUID) + if (!AccountMgr::IsGMAccount(sec) && p != m_ownerGUID) { WorldPacket data; MakeNotOwner(&data); @@ -566,7 +567,7 @@ void Channel::List(Player* player) // PLAYER can't see MODERATOR, GAME MASTER, ADMINISTRATOR characters // MODERATOR, GAME MASTER, ADMINISTRATOR can see all - if (plr && (player->GetSession()->GetSecurity() > SEC_PLAYER || plr->GetSession()->GetSecurity() <= AccountTypes(gmLevelInWhoList)) && + if (plr && (!AccountMgr::IsPlayerAccount(player->GetSession()->GetSecurity()) || plr->GetSession()->GetSecurity() <= AccountTypes(gmLevelInWhoList)) && plr->IsVisibleGloballyFor(player)) { data << uint64(i->first); @@ -594,7 +595,7 @@ void Channel::Announce(uint64 p) MakeNotMember(&data); SendToOne(&data, p); } - else if (!players[p].IsModerator() && sec < SEC_GAMEMASTER) + else if (!players[p].IsModerator() && !AccountMgr::IsGMAccount(sec)) { WorldPacket data; MakeNotModerator(&data); diff --git a/src/server/game/Chat/Chat.cpp b/src/server/game/Chat/Chat.cpp index aaacaca2661..25f1fadba47 100755 --- a/src/server/game/Chat/Chat.cpp +++ b/src/server/game/Chat/Chat.cpp @@ -510,7 +510,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 (m_session->GetSecurity() > SEC_PLAYER && !strong && !sWorld->getBoolConfig(CONFIG_GM_LOWER_SECURITY)) + if (!AccountMgr::IsPlayerAccount(m_session->GetSecurity()) && !strong && !sWorld->getBoolConfig(CONFIG_GM_LOWER_SECURITY)) return false; if (target) @@ -696,7 +696,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)) { - if (table[i].SecurityLevel > SEC_PLAYER) + if (!AccountMgr::IsPlayerAccount(table[i].SecurityLevel)) { // chat case if (m_session) @@ -786,7 +786,7 @@ int ChatHandler::ParseCommands(const char* text) std::string fullcmd = text; - if (m_session && m_session->GetSecurity() <= SEC_PLAYER && sWorld->getBoolConfig(CONFIG_ALLOW_PLAYER_COMMANDS) == 0) + if (m_session && AccountMgr::IsPlayerAccount(m_session->GetSecurity()) && !sWorld->getBoolConfig(CONFIG_ALLOW_PLAYER_COMMANDS)) return 0; /// chat case (.command or !command format) @@ -811,7 +811,7 @@ int ChatHandler::ParseCommands(const char* text) if (!ExecuteCommandInTable(getCommandTable(), text, fullcmd)) { - if (m_session && m_session->GetSecurity() == SEC_PLAYER) + if (m_session && AccountMgr::IsPlayerAccount(m_session->GetSecurity())) return 0; SendSysMessage(LANG_NO_CMD); diff --git a/src/server/game/Chat/Commands/Level0.cpp b/src/server/game/Chat/Commands/Level0.cpp index a61ae629666..ad15cc99de9 100755 --- a/src/server/game/Chat/Commands/Level0.cpp +++ b/src/server/game/Chat/Commands/Level0.cpp @@ -129,7 +129,7 @@ bool ChatHandler::HandleSaveCommand(const char* /*args*/) Player* player = m_session->GetPlayer(); // save GM account without delay and output message - if (m_session->GetSecurity() > SEC_PLAYER) + if (!AccountMgr::IsPlayerAccount(m_session->GetSecurity())) { if (Player *target = getSelectedPlayer()) target->SaveToDB(); diff --git a/src/server/game/Chat/Commands/Level3.cpp b/src/server/game/Chat/Commands/Level3.cpp index 5bea5ae9aea..334911be09d 100755 --- a/src/server/game/Chat/Commands/Level3.cpp +++ b/src/server/game/Chat/Commands/Level3.cpp @@ -1933,7 +1933,7 @@ bool ChatHandler::HandleReviveCommand(const char *args) if (target) { - target->ResurrectPlayer(target->GetSession()->GetSecurity() > SEC_PLAYER ? 1.0f : 0.5f); + target->ResurrectPlayer(!AccountMgr::IsPlayerAccount(target->GetSession()->GetSecurity()) ? 1.0f : 0.5f); target->SpawnCorpseBones(); target->SaveToDB(); } diff --git a/src/server/game/Chat/Commands/TicketCommands.cpp b/src/server/game/Chat/Commands/TicketCommands.cpp index 32bc737b3be..2ae4632d172 100755 --- a/src/server/game/Chat/Commands/TicketCommands.cpp +++ b/src/server/game/Chat/Commands/TicketCommands.cpp @@ -171,7 +171,7 @@ bool ChatHandler::HandleGMTicketAssignToCommand(const char* args) uint64 targetAccId = sObjectMgr->GetPlayerAccountIdByGUID(targetGuid); uint32 targetGmLevel = AccountMgr::GetSecurity(targetAccId, realmID); // Target must exist and have administrative rights - if (!targetGuid || targetGmLevel == SEC_PLAYER) + if (!targetGuid || AccountMgr::IsPlayerAccount(targetGmLevel)) { SendSysMessage(LANG_COMMAND_TICKETASSIGNERROR_A); return true; @@ -191,7 +191,7 @@ bool ChatHandler::HandleGMTicketAssignToCommand(const char* args) } // Assign ticket SQLTransaction trans = SQLTransaction(NULL); - ticket->SetAssignedTo(targetGuid, targetGmLevel == SEC_ADMINISTRATOR); + ticket->SetAssignedTo(targetGuid, AccountMgr::IsAdminAccount(targetGmLevel)); ticket->SaveToDB(trans); sTicketMgr->UpdateLastChange(); |
