void InstanceMgr::OnGroupDestruction(Group* pGroup) { // this means a group has been deleted, so lets clear out all instances that they owned. // (instances don't transfer to the group leader, or anything) Instance* in; InstanceMap::iterator itr; InstanceMap* instancemap; uint32 i; m_mapLock.Acquire(); for (i = 0; i < NUM_MAPS; ++i) { instancemap = m_instances[i]; if (instancemap) { for (itr = instancemap->begin(); itr != instancemap->end();) { in = itr->second; ++itr; if (in->m_mapMgr && in->m_creatorGroup && in->m_creatorGroup == pGroup->GetID()) { if (IS_RESETABLE_INSTANCE(in)) { _DeleteInstance(in, false); } else if (in->m_mapMgr->HasPlayers()) { WorldPacket data(SMSG_RAID_GROUP_ONLY, 8); data << uint32(60000); data << uint32(1); for (PlayerStorageMap::iterator mitr = in->m_mapMgr->m_PlayerStorage.begin(); mitr != in->m_mapMgr->m_PlayerStorage.end(); ++mitr) { if ((*mitr).second->IsInWorld() && !(*mitr).second->raidgrouponlysent && (*mitr).second->GetInstanceID() == (int32)in->m_instanceId) { (*mitr).second->GetSession()->SendPacket(&data); (*mitr).second->raidgrouponlysent = true; sEventMgr.AddEvent((*mitr).second, &Player::EjectFromInstance, EVENT_PLAYER_EJECT_FROM_INSTANCE, 60000, 1, EVENT_FLAG_DO_NOT_EXECUTE_IN_WORLD_CONTEXT); } } } } } } } m_mapLock.Release(); }
void InstanceMgr::ResetSavedInstances(Player* plr) { WorldPacket data(SMSG_INSTANCE_RESET, 4); Instance* in; InstanceMap::iterator itr; InstanceMap* instancemap; uint32 i; if(!plr->IsInWorld() || plr->GetMapMgr()->GetMapInfo()->type != INSTANCE_NULL) return; m_mapLock.Acquire(); for(i = 0; i < NUM_MAPS; ++i) { if(m_instances[i] != NULL) { instancemap = m_instances[i]; for(itr = instancemap->begin(); itr != instancemap->end();) { in = itr->second; ++itr; if(IS_RESETABLE_INSTANCE(in) && (CHECK_INSTANCE_GROUP(in, plr->GetGroup()) || plr->GetLowGUID() == in->m_creatorGuid)) { if(in->m_mapMgr && in->m_mapMgr->HasPlayers()) { plr->GetSession()->SystemMessage("Failed to reset instance %u (%s), due to players still inside.", in->m_instanceId, in->m_mapMgr->GetMapInfo()->name); continue; } // <mapid> has been reset. data << uint32(in->m_mapId); plr->GetSession()->SendPacket(&data); // destroy the instance _DeleteInstance(in, true); } } } } m_mapLock.Release(); }
void InstanceMgr::ResetSavedInstances(Player * plr) { WorldPacket *pData; Instance * in; InstanceMap::iterator itr; InstanceMap * instancemap; uint32 i; if (!plr->IsInWorld() || plr->GetMapMgr()->GetMapInfo()->type != INSTANCE_NULL) return; m_mapLock.Acquire(); Group *group = plr->GetGroup(); for (i = 0; i < NUM_MAPS; ++i) { if (m_instances[i] != NULL) { instancemap = m_instances[i]; for (itr = instancemap->begin(); itr != instancemap->end();) { in = itr->second; ++itr; if (IS_RESETABLE_INSTANCE(in) && ((group && group->GetID() == in->m_creatorGroup) || plr->GetLowGUID() == in->m_creatorGuid)) { if (in->m_mapMgr && in->m_mapMgr->HasPlayers()) { pData = new WorldPacket(SMSG_INSTANCE_RESET_FAILED, 8); *pData << uint32(INSTANCE_RESET_ERROR_PLAYERS_INSIDE); *pData << uint32(in->m_mapId); plr->GetSession()->SendPacket(pData); delete pData; continue; } if (group) { group->m_instanceIds[in->m_mapId][in->m_difficulty] = 0; } // <mapid> has been reset. pData = new WorldPacket(SMSG_INSTANCE_RESET, 4); *pData << uint32(in->m_mapId); plr->GetSession()->SendPacket(pData); delete pData; // destroy the instance _DeleteInstance(in, true); } } } } m_mapLock.Release(); /* plr->m_playerInfo->savedInstanceIdsLock.Acquire(); for(int difficulty=0; difficulty<NUM_INSTANCE_MODES; difficulty++) { PlayerInstanceMap::iterator itr,itr2=plr->m_playerInfo->savedInstanceIds[difficulty].begin(); for(; itr2 != plr->m_playerInfo->savedInstanceIds[difficulty].end();) { itr = itr2; itr2++; in = sInstanceMgr.GetInstanceByIds((*itr).first, (*itr).second); if( !in ) continue; if(((group && group->GetID() == in->m_creatorGroup) || plr->GetLowGUID() == in->m_creatorGuid)) { if(in->m_mapMgr && in->m_mapMgr->HasPlayers()) { pData = new WorldPacket(SMSG_RESET_INSTANCE_FAILED, 8); *pData << uint32(INSTANCE_RESET_ERROR_PLAYERS_INSIDE); *pData << uint32(in->m_mapId); plr->GetSession()->SendPacket(pData); delete pData; continue; } if(group) { group->m_instanceIds[in->m_mapId][in->m_difficulty] = 0; } // <mapid> has been reset. pData = new WorldPacket(SMSG_RESET_INSTANCE, 4); *pData << uint32(in->m_mapId); plr->GetSession()->SendPacket(pData); delete pData; //remove instance from player plr->SetPersistentInstanceId(in->m_mapId, difficulty, 0); // destroy the instance _DeleteInstance(in, true); } } } plr->m_playerInfo->savedInstanceIdsLock.Release();*/ }