bool InstanceMgr::_DeleteInstance(Instance * in, bool ForcePlayersOut) { m_mapLock.Acquire(); InstanceMap * instancemap; InstanceMap::iterator itr; if(in->m_mapMgr) { // "ForcePlayersOut" will teleport the players in this instance to their entry point/hearthstone. // otherwise, they will get a 60 second timeout telling them they are not in this instance's group. if(in->m_mapMgr->HasPlayers()) { if(ForcePlayersOut) in->m_mapMgr->InstanceShutdown(); else { in->m_mapMgr->BeginInstanceExpireCountdown(); in->m_mapMgr->pInstance = NULL; } } else in->m_mapMgr->InstanceShutdown(); } // remove the instance from the large map. instancemap = m_instances[in->m_mapId]; if(instancemap) { itr = instancemap->find(in->m_instanceId); if(itr != instancemap->end()) instancemap->erase(itr); } // cleanup corpses, database references in->DeleteFromDB(); // delete the instance pointer. delete in; m_mapLock.Release(); return true; }