Example #1
0
void InstanceMgr::CheckForExpiredInstances()
{
	// checking for any expired instances.
	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;

				// use a "soft" delete here.
				if(in->m_mapInfo->type != INSTANCE_NONRAID && !(in->m_mapInfo->type == INSTANCE_MULTIMODE && in->m_difficulty == MODE_NORMAL) && HasInstanceExpired(in))
					_DeleteInstance(in, false);
			}

		}
	}
	m_mapLock.Release();
}
Example #2
0
InstanceMap* MapInstanced::CreateInstance(uint32 InstanceId, InstanceSave* save, Difficulty difficulty)
{
    // load/create a map
    TRINITY_GUARD(ACE_Thread_Mutex, Lock);

    // make sure we have a valid map id
    const MapEntry* entry = sMapStore.LookupEntry(GetId());
    if (!entry)
    {
        sLog->outError("CreateInstance: no entry for map %d", GetId());
        ASSERT(false);
    }
    const InstanceTemplate* iTemplate = sObjectMgr->GetInstanceTemplate(GetId());
    if (!iTemplate)
    {
        sLog->outError("CreateInstance: no instance template for map %d", GetId());
        ASSERT(false);
    }

    // some instances only have one difficulty
    GetDownscaledMapDifficultyData(GetId(), difficulty);

    sLog->outDebug(LOG_FILTER_MAPS, "MapInstanced::CreateInstance: %s map instance %d for %d created with difficulty %s", save?"":"new ", InstanceId, GetId(), difficulty?"heroic":"normal");

    InstanceMap* map = new InstanceMap(GetId(), GetGridExpiry(), InstanceId, difficulty, this);
    ASSERT(map->IsDungeon());

    bool load_data = save != NULL;
    map->CreateInstanceData(load_data);

    m_InstancedMaps[InstanceId] = map;
    return map;
}
Example #3
0
void InstanceMgr::ResetHeroicInstances()
{
	// checking for any expired instances.
	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_dbcMap->israid())
				{
					// use a "soft" delete here.
					if(in->m_difficulty == MODE_5PLAYER_HEROIC)
						_DeleteInstance(in, false);
				}
			}

		}
	}
	m_mapLock.Release();
}
Example #4
0
Instance * InstanceMgr::GetSavedInstance(uint32 map_id, uint32 guid)
{
		InstanceMap::iterator itr;
		InstanceMap * instancemap;

		m_mapLock.Acquire();
		instancemap = m_instances[map_id];
		if(instancemap)
		{
			for(itr = instancemap->begin(); itr != instancemap->end();)
			{
				if(itr != instancemap->end())
				{
					if( itr->second->m_SavedPlayers.find(guid) != itr->second->m_SavedPlayers.end() )
					{
						m_mapLock.Release();
						return itr->second;
					}
					++itr;
				}
			}
		}

		// instance is non-existant (shouldn't really happen for units...)
		m_mapLock.Release();
		return 0;

}
Example #5
0
InstanceMap* MapManager::CreateInstanceMap(uint32 id, uint32 InstanceId, DungeonDifficulties difficulty, InstanceSave *save)
{
    // make sure we have a valid map id
    const MapEntry* entry = sMapStore.LookupEntry(id);
    if (!entry)
    {
        sLog.outLog(LOG_DEFAULT, "ERROR: CreateInstanceMap: no entry for map %d", id);
        ASSERT(false);
    }

    if (!ObjectMgr::GetInstanceTemplate(id))
    {
        sLog.outLog(LOG_DEFAULT, "ERROR: CreateInstanceMap: no instance template for map %d", id);
        ASSERT(false);
    }

    // some instances only have one difficulty
    if (entry && !entry->SupportsHeroicMode())
        difficulty = DIFFICULTY_NORMAL;

    DEBUG_LOG("MapInstanced::CreateInstanceMap: %s map instance %d for %d created with difficulty %d", save?"":"new ", InstanceId, id, difficulty);

    InstanceMap *map = new InstanceMap(id, i_gridCleanUpDelay, InstanceId, difficulty);
    ASSERT(map->IsDungeon());

    bool load_data = save != NULL;
    map->CreateInstanceData(load_data);

    return map;
}
Example #6
0
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_creatorGroup && in->m_creatorGroup == pGroup->GetID())
					_DeleteInstance(in, false);
			}
		}
	}
	m_mapLock.Release();
}
InstanceMap* MapInstanced::CreateInstance(uint32 InstanceId, InstanceSave* save, Difficulty difficulty)
{
    // load/create a map
    INFINITY_GUARD(ACE_Thread_Mutex, Lock);

    // make sure we have a valid map id
    const MapEntry* entry = sMapStore.LookupEntry(GetId());
    if (!entry)
    {
        IC_LOG_ERROR("maps", "CreateInstance: no entry for map %d", GetId());
        ASSERT(false);
    }
    const InstanceTemplate* iTemplate = sObjectMgr->GetInstanceTemplate(GetId());
    if (!iTemplate)
    {
        IC_LOG_ERROR("maps", "CreateInstance: no instance template for map %d", GetId());
        ASSERT(false);
    }

    IC_LOG_DEBUG("maps", "MapInstanced::CreateInstance: %s map instance %d for %d created with difficulty %s", save?"":"new ", InstanceId, GetId(), difficulty?"heroic":"normal");

    InstanceMap* map = new InstanceMap(GetId(), GetGridExpiry(), InstanceId, difficulty, this);
    ASSERT(map->IsDungeon());

    map->LoadRespawnTimes();

    bool load_data = save != NULL;
    map->CreateInstanceData(load_data);

    m_InstancedMaps[InstanceId] = map;
    return map;
}
Example #8
0
void InstanceMgr::CheckForExpiredInstances()
{
	// checking for any expired instances.
	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;

				// use a "soft" delete here.
				if(HasInstanceExpired(in))
					_DeleteInstance(in, false);
			}
		}
	}
	m_mapLock.Release();
}
InstanceMap* MapManager::CreateInstanceMap(uint32 id, uint32 InstanceId, Difficulty difficulty, InstanceSave *save)
{
    // make sure we have a valid map id
    if (!sMapStore.LookupEntry(id))
    {
        sLog.outError("CreateInstanceMap: no entry for map %d", id);
        MANGOS_ASSERT(false);
    }
    if (!ObjectMgr::GetInstanceTemplate(id))
    {
        sLog.outError("CreateInstanceMap: no instance template for map %d", id);
        MANGOS_ASSERT(false);
    }

    // some instances only have one difficulty
    if (!GetMapDifficultyData(id, difficulty))
        difficulty = DUNGEON_DIFFICULTY_NORMAL;

    DEBUG_LOG("MapInstanced::CreateInstanceMap: %s map instance %d for %d created with difficulty %d", save?"":"new ", InstanceId, id, difficulty);

    InstanceMap *map = new InstanceMap(id, i_gridCleanUpDelay, InstanceId, difficulty);
    MANGOS_ASSERT(map->IsDungeon());

    bool load_data = save != NULL;
    map->CreateInstanceData(load_data);

    return map;
}
Example #10
0
InstanceMap* MapInstanced::CreateInstanceMap(uint32 InstanceId, Difficulty difficulty, InstanceSave *save)
{
    // load/create a map
    Guard guard(*this);

    // make sure we have a valid map id
    if (!sMapStore.LookupEntry(GetId()))
    {
        sLog.outError("CreateInstanceMap: no entry for map %d", GetId());
        MANGOS_ASSERT(false);
    }
    if (!ObjectMgr::GetInstanceTemplate(GetId()))
    {
        sLog.outError("CreateInstanceMap: no instance template for map %d", GetId());
        MANGOS_ASSERT(false);
    }

    // some instances only have one difficulty
    if (!GetMapDifficultyData(GetId(),difficulty))
        difficulty = DUNGEON_DIFFICULTY_NORMAL;

    DEBUG_LOG("MapInstanced::CreateInstanceMap: %s map instance %d for %d created with difficulty %d", save?"":"new ", InstanceId, GetId(), difficulty);

    InstanceMap *map = new InstanceMap(GetId(), GetGridExpiry(), InstanceId, difficulty, this);
    MANGOS_ASSERT(map->IsDungeon());

    bool load_data = save != NULL;
    map->CreateInstanceData(load_data);

    m_InstancedMaps[InstanceId] = map;
    return map;
}
Example #11
0
InstanceMap* MapInstanced::CreateInstance(uint32 InstanceId, InstanceSave *save, uint8 difficulty)
{
    // load/create a map
    Guard guard(*this);

    // make sure we have a valid map id
    const MapEntry* entry = sMapStore.LookupEntry(GetId());
    if (!entry)
    {
        sLog.outError("CreateInstance: no entry for map %d", GetId());
        ASSERT(false);
    }
    const InstanceTemplate * iTemplate = objmgr.GetInstanceTemplate(GetId());
    if (!iTemplate)
    {
        sLog.outError("CreateInstance: no instance template for map %d", GetId());
        ASSERT(false);
    }

    // some instances only have one difficulty
    if (entry && !entry->SupportsHeroicMode())
        difficulty = DIFFICULTY_NORMAL;

    sLog.outDebug("MapInstanced::CreateInstance: %s map instance %d for %d created with difficulty %s", save?"":"new ", InstanceId, GetId(), difficulty?"heroic":"normal");

    InstanceMap *map = new InstanceMap(GetId(), GetGridExpiry(), InstanceId, difficulty, this);
    ASSERT(map->IsDungeon());

    bool load_data = save != NULL;
    map->CreateInstanceData(load_data);

    m_InstancedMaps[InstanceId] = map;
    return map;
}
Example #12
0
void InstanceMgr::BuildXMLStats(char* m_file)
{
	uint32 i;
	InstanceMap::iterator itr;
	InstanceMap* instancemap;
	Instance* in;

	m_mapLock.Acquire();
	for(i = 0; i < NUM_MAPS; ++i)
	{
		if(m_singleMaps[i] != NULL)
			BuildStats(m_singleMaps[i], m_file, NULL, m_singleMaps[i]->GetMapInfo());
		else
		{
			instancemap = m_instances[i];
			if(instancemap != NULL)
			{
				for(itr = instancemap->begin(); itr != instancemap->end();)
				{
					in = itr->second;
					++itr;

					if(in->m_mapMgr == NULL)
						continue;

					BuildStats(in->m_mapMgr, m_file, in, in->m_mapInfo);
				}
			}
		}
	}
	m_mapLock.Release();
}
Example #13
0
Instance * InstanceMgr::GetSavedInstance(uint32 map_id, uint32 guid, uint32 difficulty)
{
	InstanceMap::iterator itr;
	InstanceMap * instancemap;

	m_mapLock.Acquire();
	instancemap = m_instances[map_id];
	if(instancemap)
	{
		for(itr = instancemap->begin(); itr != instancemap->end();)
		{
			if(itr != instancemap->end())
			{
				itr->second->m_SavedLock.Acquire();
				if(itr->second->m_difficulty == difficulty)
				{
					if( itr->second->m_SavedPlayers.find(guid) != itr->second->m_SavedPlayers.end() )
					{
						itr->second->m_SavedLock.Release();
						m_mapLock.Release();
						return itr->second;
					}
				}
				itr->second->m_SavedLock.Release();
				++itr;
			}
		}
	}
	m_mapLock.Release();
	return NULL;
}
Example #14
0
MapMgr* InstanceMgr::GetInstance(uint32 MapId, uint32 InstanceId)
{
	Instance * in;
	InstanceMap::iterator itr;
	InstanceMap * instancemap;
	MapInfo * inf = WorldMapInfoStorage.LookupEntry(MapId);

	// we can *never* teleport to maps without a mapinfo.
	if( inf == NULL || MapId >= NUM_MAPS )
		return NULLMAPMGR;


	// single-instance maps never go into the instance set.
	if( inf->type == INSTANCE_NULL )
		return m_singleMaps[MapId];

	m_mapLock.Acquire();
	instancemap = m_instances[MapId];
	if(instancemap != NULL)
	{
		// check our saved instance id. see if its valid, and if we can join before trying to find one.
		itr = instancemap->find(InstanceId);
		if(itr != instancemap->end())
		{
			if(itr->second->m_mapMgr)
			{
				m_mapLock.Release();
				return itr->second->m_mapMgr;
			}
		}

		// iterate over our instances, and see if any of them are owned/joinable by him.
		for(itr = instancemap->begin(); itr != instancemap->end();)
		{
			in = itr->second;
			++itr;

			// this is our instance.
			if(in->m_mapMgr == NULL)
			{
				// create the actual instance.
				in->m_mapMgr = _CreateInstance(in);
				m_mapLock.Release();
				return in->m_mapMgr;
			}
			else
			{
				// instance is already created.
				m_mapLock.Release();
				return in->m_mapMgr;
			}
		}
	}

	// if we're here, it means there are no instances on that map, or none of the instances on that map are joinable
	// by this player.
	m_mapLock.Release();
	return NULLMAPMGR;
}
Example #15
0
void InstanceMgr::ResetSavedInstances(Player* plr)
{
	WorldPacket data(SMSG_INSTANCE_RESET, 4);
	Instance * in;
	InstanceMap::iterator itr;
	InstanceMap* instancemap;
	MapEntry* map;
	uint32 i;

	if(plr == NULL || !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];
			map = dbcMap.LookupEntry(i);
			for(itr = instancemap->begin(); itr != instancemap->end();)
			{
				in = itr->second;
				++itr;

				if((!map->israid()) && in->m_mapInfo->type == INSTANCE_MULTIMODE && plr->GetGroupID() == in->m_creatorGroup)
				{
					if( in->m_difficulty == MODE_5PLAYER_HEROIC && in->m_SavedPlayers.size() )//heroic instances can't be reset once they are saved.
					{
						plr->GetSession()->SystemMessage("Heroic instances are reset daily at 08:00 CET!");
						continue;
					}

					if(plr->GetGroup() != NULL && plr->GetGroup()->GetLeader() != plr->m_playerInfo)
					{
						plr->GetSession()->SystemMessage("Can't reset instance %u (%s), you are not the group leader!", in->m_instanceId, in->m_mapMgr->GetMapInfo()->name);
						continue;
					}

					if(in->m_mapMgr && in->m_mapMgr->HasPlayers())
					{
						plr->GetSession()->SystemMessage("Can't reset instance %u (%s) when there are still players inside!", in->m_instanceId, in->m_mapMgr->GetMapInfo()->name);
						continue;
					}

					// destroy the instance
					bool destroyed = _DeleteInstance(in, true);

					if(destroyed)
					{
						// <mapid> has been reset.
						data << uint32(in->m_mapId);
						plr->GetSession()->SendPacket(&data);
					}
				}
			}
		}
	}
    m_mapLock.Release();
}
Example #16
0
void 
  JdbcModule::deleteObject(const zorba::DynamicContext* aDynamincContext, String aObjectUUID, String aMap) {
    InstanceMap* lInstanceMap = getCreateInstanceMap(aDynamincContext, aMap);
    if (lInstanceMap==NULL)
      throwMapError(aMap);
    jobject oResult = lInstanceMap->getInstance(aObjectUUID);
    if(oResult==NULL)
      throwMapError(aMap);
    lInstanceMap->deleteInstance(aObjectUUID);
}
Example #17
0
void InstanceMgr::PlayerLeftGroup(Group * pGroup, Player* pPlayer)
{
	// does this group own any instances? we have to kick the player out of those instances.
	Instance * in;
	InstanceMap::iterator itr;
	InstanceMap * instancemap;
	WorldPacket data(SMSG_RAID_GROUP_ONLY, 8);
	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;

				bool eject = false;

				if(pPlayer->GetGUID() == in->m_creatorGuid)
					eject = true;
				else if(pPlayer->GetGroupID() == in->m_creatorGroup)
					eject = true;
				else
				{
					// Are we on the saved list?
					in->m_SavedLock.Acquire();
					if( in->m_SavedPlayers.find(pPlayer->GetLowGUID()) != in->m_SavedPlayers.end() )
						eject = true;
					in->m_SavedLock.Release();
				}

				if(eject)
				{
					// better make sure we're actually in that instance.. :P
					if(!pPlayer->raidgrouponlysent && pPlayer->GetInstanceID() == (int32)in->m_instanceId)
					{
						data << uint32(60000) << uint32(1);
						pPlayer->GetSession()->SendPacket(&data);
						pPlayer->raidgrouponlysent=true;

						sEventMgr.AddEvent(pPlayer, &Player::EjectFromInstance, EVENT_PLAYER_EJECT_FROM_INSTANCE, 60000, 1, EVENT_FLAG_DO_NOT_EXECUTE_IN_WORLD_CONTEXT);

						m_mapLock.Release();
						return;
					}
				}
			}
		}
	}
	m_mapLock.Release();
}
Example #18
0
void InstanceMgr::BuildRaidSavedInstancesForPlayer(Player* plr)
{
#if VERSION_STRING != Cata
    WorldPacket data(SMSG_RAID_INSTANCE_INFO, 200);
#else
    WorldPacket data(SMSG_RAID_INSTANCE_INFO, 4);
#endif
    Instance* in;
    InstanceMap::iterator itr;
    InstanceMap* instancemap;
    uint32 i;
    uint32 counter = 0;

    data << counter;
    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 (in->m_persistent && PlayerOwnsInstance(in, plr))
                {
                    data << uint32(in->m_mapId);                        // obviously the mapid
                    data << uint32(in->m_difficulty);                    // instance difficulty
                    data << uint64(in->m_instanceId);                    // self-explanatory
                    data << uint8(1);                                    // expired = 0
                    data << uint8(0);                                    // extended = 1

                    if (in->m_expiration > UNIXTIME)
                        data << uint32(in->m_expiration - UNIXTIME);
                    else
                        data << uint32(0);

#if VERSION_STRING == Cata
                    data << uint32(0);
#endif

                    ++counter;
                }
            }
        }
    }
    m_mapLock.Release();


    *(uint32*)&data.contents()[0] = counter;

    plr->GetSession()->SendPacket(&data);
}
Example #19
0
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();
}
Example #20
0
void InstanceMgr::ResetSavedInstances(PlayerPointer 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  ( in->m_mapInfo->type == INSTANCE_NONRAID && 
					( plr->GetLowGUID() == in->m_creatorGuid || 
					( plr->GetGroup() && plr->GetGroup()->GetID() == in->m_creatorGroup )))
				{
					if(in->m_mapMgr && in->m_mapMgr->HasPlayers())
					{
						plr->GetSession()->SystemMessage("Can't reset instance %u (%s) when there are still players inside!", in->m_instanceId, in->m_mapMgr->GetMapInfo()->name);
						continue;
					}

					// <mapid> has been reset.
					data << uint32(in->m_mapId);
					plr->GetSession()->SendPacket(&data);

					// reset groupinstanceid
					if(plr->GetGroup())
						plr->GetGroup()->SetGroupInstanceID(0);

					// destroy the instance
					_DeleteInstance(in, true);
				}
			}
		}
	}
    m_mapLock.Release();	
}
bool
AndroidSurfaceTexture::Init(GLContext* aContext, GLuint aTexture)
{

  if (!aTexture && !CanDetach()) {
    // We have no texture and cannot initialize detached, bail out
    return false;
  }

  if (NS_WARN_IF(NS_FAILED(
      SurfaceTexture::New(aTexture, ReturnTo(&mSurfaceTexture))))) {
    return false;
  }

  if (!aTexture) {
    mSurfaceTexture->DetachFromGLContext();
  }

  mAttachedContext = aContext;

  if (NS_WARN_IF(NS_FAILED(
      Surface::New(mSurfaceTexture, ReturnTo(&mSurface))))) {
    return false;
  }

  mNativeWindow = AndroidNativeWindow::CreateFromSurface(jni::GetEnvForThread(),
                                                         mSurface.Get());
  MOZ_ASSERT(mNativeWindow, "Failed to create native window from surface");

  mID = sInstances.Add(this);

  return true;
}
Example #22
0
void InstanceMgr::BuildSavedInstancesForPlayer(Player* plr)
{
#if VERSION_STRING != Cata
    WorldPacket data(4);
    Instance* in;
    InstanceMap::iterator itr;
    InstanceMap* instancemap;
    uint32 i;

    if (!plr->IsInWorld() || plr->GetMapMgr()->GetMapInfo()->type != INSTANCE_NULL)
    {
        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 (PlayerOwnsInstance(in, plr) && in->m_mapInfo->type == INSTANCE_NONRAID)
                    {
                        m_mapLock.Release();

                        data.SetOpcode(SMSG_UPDATE_LAST_INSTANCE);
                        data << uint32(in->m_mapId);
                        plr->GetSession()->SendPacket(&data);

                        data.Initialize(SMSG_UPDATE_INSTANCE_OWNERSHIP);
                        data << uint32(0x01);
                        plr->GetSession()->SendPacket(&data);

                        return;
                    }
                }
            }
        }
        m_mapLock.Release();
    }

    data.SetOpcode(SMSG_UPDATE_INSTANCE_OWNERSHIP);
    data << uint32(0x00);
    plr->GetSession()->SendPacket(&data);
#endif
}
Example #23
0
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;
}
Example #24
0
void InstanceMgr::BuildSavedInstancesForPlayer(Player* plr)
{
	WorldPacket data(4);
	Instance * in;
	InstanceMap::iterator itr;
	InstanceMap * instancemap;
	uint32 i;

	if(!plr->IsInWorld() || plr->GetMapMgr()->GetMapInfo()->type != INSTANCE_NULL)
	{
		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( !in->m_dbcMap->israid() && (PlayerOwnsInstance(in, plr) >= OWNER_CHECK_OK) )
					{
						m_mapLock.Release();

						data.SetOpcode(SMSG_UPDATE_LAST_INSTANCE);
						data << uint32(in->m_mapId);
						plr->GetSession()->SendPacket(&data);

						data.Initialize(SMSG_UPDATE_INSTANCE_OWNERSHIP);
						data << uint32(0x01);
						plr->GetSession()->SendPacket(&data);
						break; //next mapid
					}
				}
			}
		}
		m_mapLock.Release();
	}

	data.SetOpcode(SMSG_UPDATE_INSTANCE_OWNERSHIP);
	data << uint32(0x00);
	plr->GetSession()->SendPacket(&data);
}
Example #25
0
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();
}
AndroidSurfaceTexture::~AndroidSurfaceTexture()
{
  sInstances.Remove(mID);

  mFrameAvailableCallback = nullptr;

  if (mSurfaceTexture) {
    GeckoAppShell::UnregisterSurfaceTextureFrameListener(mSurfaceTexture);
    mSurfaceTexture = nullptr;
  }
}
InstanceMap* MapInstanced::CreateInstance(uint32 InstanceId, InstanceSave* save, Difficulty difficulty)
{ 
    // load/create a map
    TRINITY_GUARD(ACE_Thread_Mutex, Lock);

    // make sure we have a valid map id
    const MapEntry* entry = sMapStore.LookupEntry(GetId());
    if (!entry)
    {
        sLog->outError("CreateInstance: no entry for map %d", GetId());
        ASSERT(false);
    }
    const InstanceTemplate* iTemplate = sObjectMgr->GetInstanceTemplate(GetId());
    if (!iTemplate)
    {
        sLog->outError("CreateInstance: no instance template for map %d", GetId());
        ASSERT(false);
    }

    // some instances only have one difficulty
    GetDownscaledMapDifficultyData(GetId(), difficulty);

    ;//sLog->outDebug(LOG_FILTER_MAPS, "MapInstanced::CreateInstance: %s map instance %d for %d created with difficulty %s", save?"":"new ", InstanceId, GetId(), difficulty?"heroic":"normal");

    InstanceMap* map = new InstanceMap(GetId(), InstanceId, difficulty, this);
    ASSERT(map->IsDungeon());

    map->LoadRespawnTimes();

    if (save)
        map->CreateInstanceScript(true, save->GetInstanceData(), save->GetCompletedEncounterMask());
    else
        map->CreateInstanceScript(false, "", 0);

    if (!save) // this is for sure a dungeon (assert above), no need to check here
        sInstanceSaveMgr->AddInstanceSave(GetId(), InstanceId, difficulty);

    m_InstancedMaps[InstanceId] = map;
    return map;
}
Example #28
0
void InstanceMgr::BuildRaidSavedInstancesForPlayer(Player * plr)
{
    WorldPacket data(SMSG_RAID_INSTANCE_INFO, 200);
    Instance * in;
    InstanceMap::iterator itr;
    InstanceMap * instancemap;
    uint32 i;
    uint32 counter = 0;

    data << counter;
    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 (in->m_persistent && PlayerOwnsInstance(in, plr))
                {
                    data << in->m_mapId;
                    data << uint32(in->m_expiration - UNIXTIME);
                    data << in->m_instanceId;
                    data << ++counter;
                }
            }
        }
    }
    m_mapLock.Release();

#ifdef USING_BIG_ENDIAN
    *(uint32*)&data.contents()[0] = swap32(counter);
#else
    *(uint32*)&data.contents()[0] = counter;
#endif
    plr->GetSession()->SendPacket(&data);
}
Example #29
0
void InstanceMgr::BuildXMLStats(char * m_file)
{
	uint32 i;
	InstanceMap::iterator itr;
	InstanceMap * instancemap;
	Instance * in;

	m_mapLock.Acquire();
	for(i = 0; i < NUM_MAPS; i++)
	{
		if(m_singleMaps[i] != NULL)
			BuildStats(m_singleMaps[i], m_file, NULL, m_singleMaps[i]->GetMapInfo());
	}
	// Crow: WE CAN MAKE THIS BETTER, FASTER, STRONGER!!!

	for(i = 0; i < NUM_MAPS; i++)
	{
		if(m_singleMaps[i] == NULL)
		{
			instancemap = m_instances[i];
			if(instancemap != NULL)
			{
				for(itr = instancemap->begin(); itr != instancemap->end();)
				{
					in = itr->second;
					++itr;

					if(in->m_mapMgr == NULL)
						continue;

					BuildStats(in->m_mapMgr, m_file, in, in->m_mapInfo);
				}
			}
		}
	}

	m_mapLock.Release();
	Log.Debug("InstanceMgr", "Dumping XML stats...");
}
Example #30
0
void InstanceMgr::BuildRaidSavedInstancesForPlayer(PlayerPointer plr)
{
	WorldPacket data(SMSG_RAID_INSTANCE_INFO, 200);
	Instance * in;
	InstanceMap::iterator itr;
	InstanceMap * instancemap;
	uint32 i;
	uint32 counter = 0;

	data << counter;
	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;

				uint8 poinst = PlayerOwnsInstance(in, plr);
				if( poinst >= OWNER_CHECK_OK )
				{
					data << in->m_mapId;
					data << uint32(in->m_expiration - UNIXTIME);
					data << in->m_instanceId;
					data << in->m_difficulty;
					++counter;
				}
			}
		}
	}
	m_mapLock.Release();

	*(uint32*)&data.contents()[0] = counter;
	plr->GetSession()->SendPacket(&data);
}