bool LfgGroup::RemoveOfflinePlayers() // Return true if group is empty after check { sLfgMgr.LfgLog("Remove Offline %u, premade %u", GetId(), premadePlayers.empty() ? 0 : 1); if (m_memberSlots.empty()) { sLfgMgr.LfgLog("Group %u add to delete", GetId()); sLfgMgr.AddGroupToDelete(this); return true; } PlayerList toRemove; for(member_citerator citr = m_memberSlots.begin(); citr != m_memberSlots.end(); ++citr) { sLfgMgr.LfgLog("guid %u", citr->guid); Player *plr = sObjectMgr.GetPlayer(citr->guid); if (!plr || (!plr->GetSession() && !plr->IsBeingTeleported()) || (plr->GetGroup() && plr->GetGroup() != this && plr->GetGroup()->isLfgGroup() && ((LfgGroup*)plr->GetGroup())->IsInDungeon())) { sLfgMgr.LfgLog("Add to remove"); toRemove.insert(citr->guid); } } for(PlayerList::iterator itr = toRemove.begin(); itr != toRemove.end(); ++itr) { sLfgMgr.LfgLog("Check for premade %u", *itr); PlayerList::iterator premade = premadePlayers.find(*itr); if(premade != premadePlayers.end()) { sLfgMgr.LfgLog("premade yes"); for(PlayerList::iterator prm = premadePlayers.begin(); prm != premadePlayers.end(); ++prm) { Player *plr = sObjectMgr.GetPlayer(*prm); if(!plr || !plr->GetSession()) continue; Group* group = plr->GetGroup(); if(group) { sLfgMgr.RemoveFromQueue(plr, false); return true; } } for(PlayerList::iterator prm = premadePlayers.begin(); prm != premadePlayers.end(); ++prm) RemoveMember(*prm, 0); } } for(PlayerList::iterator itr = toRemove.begin(); itr != toRemove.end(); ++itr) { sLfgMgr.LfgLog("Remove %u", *itr); RemoveMember(*itr, 0); } toRemove.clear(); //flush empty group if (GetMembersCount() == 0) { sLfgMgr.LfgLog("Group %u add to delete 2", GetId()); sLfgMgr.AddGroupToDelete(this); return true; } return false; }
void Mud::removeInactivePlayers() { PlayerList toRemove = PlayerList(); for (auto iterator : mudPlayers) { // Proceed only if the player is not connected and is closing. if (!iterator->checkConnection() || iterator->closing) { // Add the player to the list of players that have to be removed. toRemove.insert(iterator); } } for (auto iterator = toRemove.begin(); iterator != toRemove.end(); ++iterator) { // Get the player at the given position. Player * player = *iterator; // Log the action of removing. Logger::log(LogLevel::Global, "Removing inactive player : " + player->getName()); // Only if the player has successfully logged in, save its state on DB. if (player->logged_in) { SQLiteDbms::instance().beginTransaction(); player->updateOnDB(); SQLiteDbms::instance().endTransaction(); } // Remove the player from the list of players. remPlayer(player); // Delete the player. delete (player); } }
bool LfgGroup::SelectRandomDungeon() { m_originalInfo = m_dungeonInfo; m_lfgFlags |= LFG_GRP_RANDOM; LfgLocksMap *groupLocks = GetLocksList(); std::vector<LFGDungeonEntry const*> options; LFGDungeonEntry const *currentRow = NULL; //Possible dungeons LfgDungeonList* list = sLfgMgr.GetRandomOptions(m_dungeonInfo->ID); for(LfgDungeonList::iterator itr = list->begin(); itr != list->end(); ++itr) options.push_back(*itr); //And now get only without locks for(LfgLocksMap::iterator itr = groupLocks->begin(); itr != groupLocks->end(); ++itr) { for(LfgLocksList::iterator itr2 = itr->second->begin(); itr2 != itr->second->end(); ++itr2) { for(std::vector<LFGDungeonEntry const*>::iterator itrDung = options.begin(); itrDung != options.end(); ++itrDung) { if ((*itrDung)->ID != (*itr2)->dungeonInfo->ID) continue; DungeonInfo* dungeonInfo = sLfgMgr.GetDungeonInfo((*itr2)->dungeonInfo->ID); if (dungeonInfo->locked || (*itr2)->lockType != LFG_LOCKSTATUS_RAID_LOCKED) { options.erase(itrDung); break; } } } } //This should not happen if (options.empty()) { PlayerList toRemove; for(member_witerator itr = m_memberSlots.begin(); itr != m_memberSlots.end(); ++itr) { Player *plr = sObjectMgr.GetPlayer(itr->guid); if (!plr) continue; sLfgMgr.SendLfgUpdatePlayer(plr, LFG_UPDATETYPE_GROUP_DISBAND); sLog.outError("LfgMgr: Cannot find any random dungeons for player %s", plr->GetName()); plr->GetSession()->SendNotification("Cannot find any random dungeons for this group, you have to find new group. We are sorry"); toRemove.insert(plr->GetGUID()); } for(PlayerList::iterator itr = toRemove.begin(); itr != toRemove.end(); ++itr) RemoveMember(*itr, 0); toRemove.clear(); sLfgMgr.AddGroupToDelete(this); return false; } //Select dungeon, there should be also bind check uint32 tmp = time(NULL)%options.size(); m_dungeonInfo = options[tmp]; return true; }
static QBStreamSound* findPlayer(int track) { QBStreamSound* player=NULL; PlayerList::iterator p = streamTrack.find(track); if (p != streamTrack.end()) { player = p->second; } else { player = new QBStreamSound(); streamTrack.insert(make_pair(track,player)); } return player; }