SessionManager::SessionList SessionManager::SessionMapToList(SessionMap &map) { SessionList list; for (SessionMap::iterator it=map.begin(); it!=map.end(); it++) { list.push_back(it->second); } return list; }
void LaunchDaemon::_ForwardEventMessage(uid_t user, BMessage* message) { if (fUserMode) return; // Forward event to user launch_daemon(s) if (user == 0) { for (SessionMap::iterator iterator = fSessions.begin(); iterator != fSessions.end(); iterator++) { Session* session = iterator->second; session->Daemon().SendMessage(message); // ignore reply } } else { Session* session = FindSession(user); if (session != NULL) session->Daemon().SendMessage(message); } }
template <class F> void ConnectionImpl::closeInternal(const F& f) { if (heartbeatTask) { heartbeatTask->cancel(); } { Mutex::ScopedUnlock u(lock); connector->close(); } //notifying sessions of failure can result in those session being //deleted which in turn results in a call to erase(); this can //even happen on this thread, when 's' goes out of scope //below. Using a copy prevents the map being modified as we //iterate through. SessionMap copy; sessions.swap(copy); for (SessionMap::iterator i = copy.begin(); i != copy.end(); ++i) { boost::shared_ptr<SessionImpl> s = i->second.lock(); if (s) f(s); } }
void OnPVPKill(Player * killer, Player * killed) { if (killer->GetGUID() == killed->GetGUID()) { return; } if (killer->GetSession()->GetRemoteAddress() == killed->GetSession()->GetRemoteAddress() || killed->GetMaxHealth() <= 10000) // Normally players try farm with new characters with low health then modify the Health according your server. { std::string str = ""; SessionMap ss = sWorld->GetAllSessions(); for (SessionMap::const_iterator itr = ss.begin(); itr != ss.end(); ++itr) if (itr->second->GetSecurity() > 0) str = "|cFFFFFC00[Anti-Farm System]|cFF00FFFF[|cFF60FF00" + std::string(killer->GetName()) + "|cFF00FFFF] Possivel Farmer |CFFEE0000 [ATENÇÃO GMS!]"; WorldPacket data(SMSG_NOTIFICATION, (str.size()+1)); data << str; sWorld->SendGlobalGMMessage(&data); } else { return; } }
void CreatureTextMgr::SendChatPacket(WorldPacket* data, WorldObject* source, ChatMsg msgType, uint64 whisperGuid, TextRange range, Team team, bool gmOnly) const { if (!source) return; float dist = sWorld->getFloatConfig(CONFIG_LISTEN_RANGE_SAY); switch (msgType) { case CHAT_MSG_MONSTER_YELL: dist = sWorld->getFloatConfig(CONFIG_LISTEN_RANGE_YELL); break; case CHAT_MSG_MONSTER_EMOTE: case CHAT_MSG_RAID_BOSS_EMOTE: dist = sWorld->getFloatConfig(CONFIG_LISTEN_RANGE_TEXTEMOTE); break; case CHAT_MSG_MONSTER_WHISPER: case CHAT_MSG_RAID_BOSS_WHISPER: { if (range == TEXT_RANGE_NORMAL)//ignores team and gmOnly { Player* player = ObjectAccessor::FindPlayer(whisperGuid); if (!player || !player->GetSession()) return; player->GetSession()->SendPacket(data); return; } break; } default: break; } switch (range) { case TEXT_RANGE_AREA: { uint32 areaId = source->GetAreaId(); Map::PlayerList const& pList = source->GetMap()->GetPlayers(); for (Map::PlayerList::const_iterator itr = pList.begin(); itr != pList.end(); ++itr) { if (itr->getSource()->GetAreaId() == areaId && (!team || Team(itr->getSource()->GetTeam()) == team) && (!gmOnly || itr->getSource()->isGameMaster())) { if (data->GetOpcode() == SMSG_MESSAGECHAT)//override whisperguid with actual player's guid data->put<uint64>(1+4+8+4+4+(int32)(strlen(source->GetName())+1), uint64(itr->getSource()->GetGUID())); (itr->getSource())->GetSession()->SendPacket(data); } } return; } case TEXT_RANGE_ZONE: { uint32 zoneId = source->GetZoneId(); Map::PlayerList const& pList = source->GetMap()->GetPlayers(); for (Map::PlayerList::const_iterator itr = pList.begin(); itr != pList.end(); ++itr) { if (itr->getSource()->GetZoneId() == zoneId && (!team || Team(itr->getSource()->GetTeam()) == team) && (!gmOnly || itr->getSource()->isGameMaster())) { if (data->GetOpcode() == SMSG_MESSAGECHAT)//override whisperguid with actual player's guid data->put<uint64>(1+4+8+4+4+(int32)(strlen(source->GetName())+1), uint64(itr->getSource()->GetGUID())); (itr->getSource())->GetSession()->SendPacket(data); } } return; } case TEXT_RANGE_MAP: { Map::PlayerList const& pList = source->GetMap()->GetPlayers(); for (Map::PlayerList::const_iterator itr = pList.begin(); itr != pList.end(); ++itr) { if (data->GetOpcode() == SMSG_MESSAGECHAT)//override whisperguid with actual player's guid data->put<uint64>(1+4+8+4+4+(int32)(strlen(source->GetName())+1), uint64(itr->getSource()->GetGUID())); if ((!team || Team(itr->getSource()->GetTeam()) == team) && (!gmOnly || itr->getSource()->isGameMaster())) (itr->getSource())->GetSession()->SendPacket(data); } return; } case TEXT_RANGE_WORLD: { const SessionMap smap = sWorld->GetAllSessions(); for (SessionMap::const_iterator iter = smap.begin(); iter != smap.end(); ++iter) { if (Player* plr = (*iter).second->GetPlayer()) { if (data->GetOpcode() == SMSG_MESSAGECHAT)//override whisperguid with actual player's guid data->put<uint64>(1+4+8+4+4+(int32)(strlen(source->GetName())+1), uint64(plr->GetGUID())); if (plr->GetSession() && (!team || Team(plr->GetTeam()) == team) && (!gmOnly || plr->isGameMaster())) plr->GetSession()->SendPacket(data); } } return; } case TEXT_RANGE_NORMAL: default: break; } source->SendMessageToSetInRange(data, dist, true); }
/// Dtor. virtual ~SessionManager() { f8_scoped_lock guard(_mutex); std::for_each (_sessionmap.begin(), _sessionmap.end(), [](typename decltype(_sessionmap)::value_type& pp){ delete pp.second; }); }
~MemorySessionStore() { // Delete all the sessions but while locked lock_guard<shared_mutex> lock(_lock); sessions.erase(sessions.begin(), sessions.end()); }
static bool SendChat(ChatHandler *handler, const char *args, bool donorChat) { Player *player; std::string temp = args; time_t t = time(NULL); if( !handler->GetSession() || !handler->GetSession()->GetPlayer() || !(player = handler->GetSession()->GetPlayer()) || !player->CanSpeak() || !args || temp.empty() || temp.find_first_not_of(' ') == std::string::npos ) return false; std::transform(temp.begin(), temp.end(), temp.begin(), ::tolower); double seconds = difftime(t, chatInfo[player->GetGUID()].lastMessageTime); if( chatInfo[player->GetGUID()].lastMessage.compare(temp) == 0 && seconds < 15 ) { handler->PSendSysMessage("Please wait %.f seconds before repeating yourself.", 15.0-seconds); handler->SetSentErrorMessage(true); return false; } else if( chatInfo[player->GetGUID()].lastMessage.compare(temp) == 0 ) chatInfo[player->GetGUID()].messageRepeats++; else chatInfo[player->GetGUID()].messageRepeats = 0; if( chatInfo[player->GetGUID()].messageRepeats > 3 ) { handler->PSendSysMessage("Please quit repeating yourself."); handler->SetSentErrorMessage(true); return false; } chatInfo[player->GetGUID()].lastMessage = temp; chatInfo[player->GetGUID()].lastMessageTime = t; std::stringstream msg; msg << "|cff00ff00[" << (donorChat ? "Donor" : "Global") << "]|r "; switch(handler->GetSession()->GetSecurity()) { default: break; case SEC_MODERATOR: case SEC_GAMEMASTER: case SEC_ADMINISTRATOR: msg << "|cff00ffff[GM]|r "; break; case SEC_DEVELOPER: msg << "|cffff8000[Dev]|r "; break; case SEC_OWNER: msg << "|cfffa0000[Owner]|r "; break; } msg << PlayerChatLink(player) << " |cfffaeb00" << args << "|r"; SessionMap sessions = sWorld->GetAllSessions(); for( SessionMap::iterator itr = sessions.begin(); itr != sessions.end(); ++itr ) { if( !itr->second || (donorChat && itr->second->GetSecurity() < SEC_DONOR)) continue; Player *plr = itr->second->GetPlayer(); if( !plr || (player->GetSession()->GetSecurity() <= SEC_DONOR && plr->GetSocial()->HasIgnore(player->GetGUIDLow())) ) continue; sWorld->SendServerMessage(SERVER_MSG_STRING, msg.str().c_str(), plr); } return true; }
void CreatureTextMgr::SendNonChatPacket(WorldPacket* data, WorldObject* source, ChatMsg msgtype, WorldObject* whisperTarget, CreatureTextRange range, Team team, bool gmOnly) const { if (!source) return; switch (msgtype) { case CHAT_MSG_MONSTER_PARTY: { if (!whisperTarget) return; if (Player* whisperPlayer = whisperTarget->ToPlayer()) { if (Group* group = whisperPlayer->GetGroup()) group->BroadcastPacket(data, false); } return; } case CHAT_MSG_MONSTER_WHISPER: case CHAT_MSG_RAID_BOSS_WHISPER: { if (range == TEXT_RANGE_NORMAL) // ignores team and gmOnly { if (!whisperTarget || whisperTarget->GetTypeId() != TYPEID_PLAYER) return; whisperTarget->ToPlayer()->GetSession()->SendPacket(data); return; } } break; case CHAT_TYPE_SAY://default dist default: break; } switch (range) { case TEXT_RANGE_AREA: { uint32 areaId = source->GetAreaId(); Map::PlayerList const& pList = source->GetMap()->GetPlayers(); for (Map::PlayerList::const_iterator itr = pList.begin(); itr != pList.end(); ++itr) if (itr->getSource()->GetAreaId() == areaId && (!team || (team && itr->getSource()->GetTeam() == team)) && (!gmOnly || itr->getSource()->isGameMaster())) itr->getSource()->GetSession()->SendPacket(data); } return; case TEXT_RANGE_ZONE: { uint32 zoneId = source->GetZoneId(); Map::PlayerList const& pList = source->GetMap()->GetPlayers(); for (Map::PlayerList::const_iterator itr = pList.begin(); itr != pList.end(); ++itr) if (itr->getSource()->GetZoneId() == zoneId && (!team || (team && itr->getSource()->GetTeam() == team)) && (!gmOnly || itr->getSource()->isGameMaster())) itr->getSource()->GetSession()->SendPacket(data); } return; case TEXT_RANGE_MAP: { Map::PlayerList const& pList = source->GetMap()->GetPlayers(); for (Map::PlayerList::const_iterator itr = pList.begin(); itr != pList.end(); ++itr) if (!team || ((team && itr->getSource()->GetTeam() == team) && (!gmOnly || itr->getSource()->isGameMaster()))) itr->getSource()->GetSession()->SendPacket(data); } return; case TEXT_RANGE_WORLD: { const SessionMap smap = sWorld.GetAllSessions(); for (SessionMap::const_iterator iter = smap.begin(); iter != smap.end(); ++iter) if (Player* plr = (*iter).second->GetPlayer()) if (plr->GetSession() && (!team || (team && plr->GetTeam() == team)) && (!gmOnly || plr->isGameMaster())) plr->GetSession()->SendPacket(data); } return; case TEXT_RANGE_NORMAL: default: break; } float dist = GetRangeForChatType(msgtype); source->SendMessageToSetInRange(data, dist, true); }
static bool HandleWorldChatCommand(ChatHandler * handler, const char * args) { if (!handler->GetSession()->GetPlayer()->CanSpeak()) return false; std::string temp = args; if (!args || temp.find_first_not_of(' ') == std::string::npos) return false; std::string msg = ""; Player * player = handler->GetSession()->GetPlayer(); switch(player->GetSession()->GetSecurity()) { // Player case SEC_PLAYER: if (player->GetTeam() == ALLIANCE) { msg += "|cff0000ff[Alianza] "; msg += GetNameLink(player); msg += " |cfffaeb00"; } else { msg += "|cffff0000[Horda] "; msg += GetNameLink(player); msg += " |cfffaeb00"; } break; // VIP case 1: msg += "|cffC400C4[Gm-R1] "; msg += GetNameLink(player); msg += " |cfffaeb00"; break; // Trial GM - 2 case 2: msg += "|cff800000[Gm-R2] "; msg += GetNameLink(player); msg += " |cfffaeb00"; break; // GM - 3 case 3: msg += "|cff0000FF[GM-R3] "; msg += GetNameLink(player); msg += " |cfffaeb00"; break; // GM-4 case 4: msg += "|CFF800080[GM-R4] "; msg += GetNameLink(player); msg += " |cfffaeb00"; break; // Developer - 5 case 5: msg += "|cff000000[Administrador] "; msg += GetNameLink(player); msg += " |cfffaeb00"; break; // Admin - 6 case 6: msg += "|cffFF0000[ADMIN] "; msg += GetNameLink(player); msg += " |cfffaeb00"; break; // CONSOLA case 7: msg += "|cffFF0000[SERVIDOR] "; msg += GetNameLink(player); msg += " |cfffaeb00"; break; } msg += args; if (FACTION_SPECIFIC) { SessionMap sessions = sWorld->GetAllSessions(); for (SessionMap::iterator itr = sessions.begin(); itr != sessions.end(); ++itr) if (Player* plr = itr->second->GetPlayer()) if (plr->GetTeam() == player->GetTeam()) sWorld->SendServerMessage(SERVER_MSG_STRING, msg.c_str(), plr); } else sWorld->SendServerMessage(SERVER_MSG_STRING, msg.c_str(), 0); return true; }
void _SendWorldChat(Player* player, string message) { size_t stringpos; if(message.find("|TInterface") != string::npos) return; if(message.find("\n") != string::npos ) return; if((stringpos = message.find("|Hquest:")) != string::npos) return; if((stringpos = message.find("|Htrade:")) != string::npos) return; if((stringpos = message.find("|Htalent:")) != string::npos) return; if((stringpos = message.find("|Henchant:")) != string::npos) return; if((stringpos = message.find("|Hachievement:")) != string::npos) return; if((stringpos = message.find("|Hglyph:")) != string::npos) return; if((stringpos = message.find("|Hspell:")) != string::npos) return; if((stringpos = message.find("Hitem:")) != string::npos) return; if(message.find("|c") != string::npos && message.find("|r") != string::npos) return; if(message.find("|c") != string::npos && message.find("|h") != string::npos) return; uint8 cheksSize = 118;//Change these if you want to add more words to the array. std::string checks[118];//Change these if you want to add more words to the array. // Strony (Sites) // Strony (Sites) checks[0] ="http://"; checks[1] =".com"; checks[2] =".net"; checks[3] =".org"; checks[4] ="www."; checks[5] ="wow-"; checks[6] ="-wow"; checks[7] ="no-ip"; checks[8] =".zapto"; checks[9] =".biz"; checks[10] =".servegame"; checks[11] =".br"; checks[12] ="com.br"; checks[13] ="h t t p : / /"; checks[14] =". c o m"; checks[15] =". n e t"; checks[16] =". o r g"; checks[17] ="w w w ."; checks[18] =" w o w -"; checks[19] ="- w o w"; checks[20] ="n o - i p"; checks[21] =". z a p t o"; checks[22] =". b i z"; checks[23] =". s e r v e g a m e"; checks[24] =". b r"; checks[25] ="c o m . b r"; checks[26] ="h t t p : / /"; checks[27] =". c o m"; checks[28] =". n e t"; checks[29] =". o r g"; checks[30] ="w w w ."; checks[31] =" w o w -"; checks[32] ="- w o w"; checks[33] ="n o - i p"; checks[34] =". z a p t o"; checks[35] =". b i z"; checks[36] =". s e r v e g a m e"; checks[37] =". b r"; checks[38] ="c o m . b r"; checks[39] ="h t t p : / /"; checks[40] =". c o m"; checks[41] =". n e t"; checks[42] =". o r g"; checks[43] ="w w w ."; checks[44] =" w o w -"; checks[45] ="- w o w"; checks[46] ="n o - i p"; checks[47] =". z a p t o"; checks[48] =". b i z"; checks[49] =". s e r v e g a m e"; checks[50] =". b r"; checks[51] =" c o m . b r"; checks[52] ="h t t p : / /"; checks[53] =". c o m"; checks[54] =". n e t"; checks[55] =". o r g"; checks[56] ="w w w ."; checks[57] ="w o w -"; checks[58] ="- w o w"; checks[59] ="n o - i p"; checks[60] =". z a p t o"; checks[61] =". b i z"; checks[62] =". s e r v e g a m e"; checks[63] =". b r"; checks[64] ="c o m . b r"; checks[65] ="trevon"; checks[66] ="megawow"; checks[67] ="fatalwow"; checks[68] ="uniforgiven-wow"; checks[69] ="wow-autolouco"; checks[70] ="heaven-wow"; checks[71] ="fireballwow"; checks[72] ="wowbrasilpa"; checks[73] ="fatalitywow"; checks[74] ="demonic-wow"; checks[75] ="revenge-wow"; checks[76] ="heavenwow"; checks[77] ="undead-wow"; checks[78] ="linebr"; checks[79] ="azralon"; checks[80] ="black-wow"; checks[81] ="trevonwow"; checks[82] ="t r e v o n"; checks[83] ="m e g a w o w"; checks[84] ="f a t a l w o w"; checks[85] ="u n i f o r g i v e n - w o w"; checks[86] ="w o w - a u t o l o u c o"; checks[87] ="h e a v e n - w o w"; checks[88] ="f i r e b a l l w o w"; checks[89] ="w o w b r a s i l p a"; checks[90] ="f a t a l i t y w o w"; checks[91] ="d e m o n i c - w o w"; checks[92] ="r e v e n g e - w o w"; checks[93] ="h e a v e n w o w"; checks[94] ="u n d e a d - w o w"; checks[95] ="l i n e b r"; checks[96] ="a z r a l o n"; checks[97] ="b l a c k - w o w"; checks[98] ="t r e v o n w o w"; checks[99] ="t r e v o n"; checks[100] ="m e g a w o w"; checks[101] ="f a t a l w o w"; checks[102] ="u n i f o r g i v e n - w o w"; checks[103] ="w o w - a u t o l o u c o"; checks[104] ="h e a v e n - w o w"; checks[105] ="f i r e b a l l w o w"; checks[106] ="w o w b r a s i l p a"; checks[107] ="f a t a l i t y w o w"; checks[108] ="d e m o n i c - w o w"; checks[109] ="r e v e n g e - w o w"; checks[110] ="h e a v e n w o w"; checks[111] ="u n d e a d - w o w"; checks[112] ="l i n e b r"; checks[113] ="a z r a l o n"; checks[114] ="b l a c k - w o w"; checks[115] ="t r e v o n w o w"; checks[116] =" [The Lightbringer's Redemption]"; checks[117] ="[The Lightbringer's Redemption]"; for (int i = 0; i < cheksSize; ++i) { if (message.find(checks[i]) != string::npos) { std::string say = ""; std::string str = ""; say = message; ChatHandler(player->GetSession()).PSendSysMessage("|cffFF0000Mensagem Bloqueada.. Impossível divulgar ou usar palavras obcenas."); SessionMap ss = sWorld->GetAllSessions(); for (SessionMap::const_iterator itr = ss.begin(); itr != ss.end(); ++itr) if (itr->second->GetSecurity() > 0) str = "[Anti Divulgação][" + string(player->GetName()) + "][" + say + "]"; WorldPacket data(SMSG_NOTIFICATION, (str.size()+1)); data << str; sWorld->SendGlobalGMMessage(&data); return; } } string msg; ostringstream chat_string; switch(player->GetSession()->GetSecurity()) { case SEC_PLAYER: if (player->GetTeam() == ALLIANCE) { msg += " |TInterface/ICONS/INV_BannerPVP_02.png:16|t [Jogador] "; msg += GetNameLink(player); msg += ":|#0000FF"; } else { msg += " |TInterface/ICONS/INV_BannerPVP_01.png:16|t[Jogador] "; msg += GetNameLink(player); msg += ":|#FF0000"; } break; // Jogador Vip case SEC_VIP: msg += " |TInterface/ICONS/Ability_Warrior_StalwartProtector.png:16|t [V.I.P] "; msg += GetNameLink(player); msg += ":|#FFFF00"; break; // Moderador - Divulgador case SEC_MODERATOR: msg += " |TInterface/ICONS/Achievement_Dungeon_UtgardePinnacle.png:16|t [Divulgador] "; msg += GetNameLink(player); msg += ":|#00FF00"; break; // Game Master Suporte case SEC_TRIAL_GM: msg += " |TInterface/ICONS/Achievement_Dungeon_UtgardePinnacle_10man.png:16|t [Game Master - Suporte] "; msg += GetNameLink(player); msg += ":|#990000"; break; // Game Master Evento case SEC_JUNIOR_GM: msg += " |TInterface/ICONS/Achievement_Dungeon_UtgardePinnacle_Heroic.png:16|t [Game Master - Evento] "; msg += GetNameLink(player); msg += ":|#99FF00"; break; // Game Master Lider case SEC_GAMEMASTER: msg += " |TInterface/ICONS/Achievement_Dungeon_UtgardePinnacle_Normal.png:16|t [Game Master - Lider] "; msg += GetNameLink(player); msg += ":|#FF3300"; break; // Programador case SEC_DEVELOPER: msg += " |TInterface/ICONS/Achievement_Dungeon_UtgardePinnacle_25man.png:16|t [Programador] "; msg += GetNameLink(player); msg += ":|#CC0000"; break; // Sub-Administrador case SEC_HEAD_OF_STAFF: msg += " |TInterface/ICONS/Achievement_Dungeon_UlduarRaid_IronDwarf_01.png:16|t [Sub-Administrador] "; msg += GetNameLink(player); msg += ":|#660000"; break; // Administrador case SEC_ADMINISTRATOR: msg += " |TInterface/ICONS/Ability_Rogue_MasterOfSubtlety.png:16|t [Administrador] "; msg += GetNameLink(player); msg += ":|#333333"; break; // Dono do Servidor case SEC_CONSOLE: msg += " |TInterface/ICONS/Ability_Rogue_MasterOfSubtlety.png:16|t "; msg += GetNameLink(player); msg += ":|#333333"; break; } chat_string << msg << " " << message; char c_msg[1024]; snprintf(c_msg, 1024, chat_string.str().c_str()); sWorld->SendGlobalText(c_msg, NULL); }