Example #1
0
void Turret::GetPrefetchResourceList(const char* pszObjectName, IObjectResourceGatherer* pInterface, ResourceList& Resources )
{
	// get the turret record
	char szTurretType[MAX_PATH];
	pInterface->GetPropString(pszObjectName, "TurretType", szTurretType, LTARRAYSIZE(szTurretType), NULL);
	
	if (!LTStrEmpty(szTurretType))
	{
		HRECORD hTurretRecord = g_pWeaponDB->GetTurretRecord(szTurretType);

		// get the base model and material
		HATTRIBUTE hBaseModelAttribute = g_pLTDatabase->GetAttribute(hTurretRecord, WDB_TURRET_sBaseModel);
		const char* pszBaseModel = g_pLTDatabase->GetString(hBaseModelAttribute, 0, NULL);
		if (pszBaseModel)
		{
			Resources.push_back(pszBaseModel);
		}

		HATTRIBUTE hBaseMaterialAttribute = g_pLTDatabase->GetAttribute(hTurretRecord, WDB_TURRET_sBaseMaterial);
		const char* pszBaseMaterial = g_pLTDatabase->GetString(hBaseMaterialAttribute, 0, NULL);
		if (pszBaseMaterial)
		{
			Resources.push_back(pszBaseMaterial);
		}

		// get the client FX resources
		GetClientFXResources(Resources, hTurretRecord, WDB_TURRET_sLoopFX);
		GetClientFXResources(Resources, hTurretRecord, WDB_TURRET_sDamageFX);

		HATTRIBUTE hDamageStateStruct = g_pLTDatabase->GetAttribute(hTurretRecord, WDB_TURRET_DamageState);
		uint32 nNumberOfDamageStates = g_pLTDatabase->GetNumValues(hDamageStateStruct);

		for (uint32 nDamageStateIndex = 0; nDamageStateIndex < nNumberOfDamageStates; ++nDamageStateIndex)
		{
			HATTRIBUTE hClientFX = CGameDatabaseReader::GetStructAttribute(hDamageStateStruct, nDamageStateIndex, WDB_TURRET_fxClientFX);
			const char* pszClientFX = g_pLTDatabase->GetString(hClientFX, 0, NULL);
			GetClientFXResources(Resources, pszClientFX);
		}

		// get the weapon record
		HATTRIBUTE hTurretWeaponLink = g_pLTDatabase->GetAttribute(hTurretRecord, WDB_TURRET_rWeapon);
		HRECORD hTurretWeapon = g_pLTDatabase->GetRecordLink(hTurretWeaponLink, 0, NULL);
		if (hTurretWeapon)
		{
			// get the default attribute
			HATTRIBUTE hDefaultAttribute = g_pLTDatabase->GetAttribute(hTurretWeapon, "Default");
            HRECORD hDefaultRecord = g_pLTDatabase->GetRecordLink(hDefaultAttribute, 0, NULL);

			// get everything under here
			GetRecordResources(Resources, hDefaultRecord, true);
		}
	}
}
Example #2
0
void Terrain::load()
{
    // Load terrain resources.
    ResourceList resourceList;

    // Heightmap
    resourceList.push_back( ResourceInfo( mHeightmapFile ) );

    // Textures
    for( LayerInstances::iterator i = mLayerInstances.begin(); i != mLayerInstances.end(); ++i )
    {
        for( std::vector<Path>::iterator j = (*i).mTextureFiles.begin(); j != (*i).mTextureFiles.end(); ++j )
        {
            resourceList.push_back( ResourceInfo( *j ) );
        }
    }

    mResourceManager.loadResources( resourceList, sigc::mem_fun( this, &Terrain::resourcesLoaded ) );
}
ResourceList Scheduler::allocate(Job &j, size_t max_res, size_t min_res) {
  ResourceList allocatedResources;

  if (resPool->size() >= min_res) {
    while (max_res-- > 0 && resPool->size() > 0) {
      allocatedResources.push_back(*resPool->wait_pop_back());
    }

    // LOGF(debug, "Allocated %1% resources to %2% ") % allocatedResources.size() % j;
  }
  return allocatedResources;
}
Example #4
0
ResourceList ResourceManager::list()
{
    ResourceList resourceList;

    Ogre::StringVectorPtr resources = mRGM.findResourceNames( mGroup, "*" );
    
    for( Ogre::StringVector::const_iterator i = resources->begin(); i != resources->end(); ++i )
    {
        resourceList.push_back( Path( *i ) );
    }

    return resourceList;
}
Example #5
0
void CreatureManager::loadAnimations(rapidjson::Document& data, ResourceList& list) {
	namespace rj = rapidjson;
	if (!data.HasMember("animations"))
		return;
	CreatureResources crRes;
	crRes.type = CResourceType::ANIMATION;
	const rj::Value& animations = data["animations"];
	for (rj::Value::ConstValueIterator it = animations.Begin(); it != animations.End(); ++it) {
		GameData::instance().resources->loadAnimation(*it);
		crRes.name = (*it)["name"].GetString();
		list.push_back(crRes);
	}
}
Example #6
0
	//---------------------------------------------------------------------------------------------------------
	void Checking::_CompareResource( ResourceList& reslist, const JsonEntryInfo& info )
	{
		for ( int i = 0; i < info.m_ResinfoArray.Getsize() ; ++ i)
		{
			const JsonResourceInfo& webres = info.m_ResinfoArray.At<JsonResourceInfo>(i);
			const JsonLocalResourceInfo& locres = m_LocalResourceList.m_ResinfoArray.At<JsonLocalResourceInfo>(i);
			if ( webres.m_LoacalPath != locres.m_LoacalPath )//说明本地没有这个资源
			{
				string url = info.m_BaseUrl + webres.m_ResUrl;
				JsonLocalResourceInfo ni;
				ni.m_LoacalPath = webres.m_LoacalPath;
				ni.m_Version = 0;
				m_LocalResourceList.m_ResinfoArray.Insert( i, ni );
				m_ResourceDownloadInfoMap.insert(
					eastl::make_pair(
					Utility::HashCode( url ),
					eastl::make_pair(
					&m_LocalResourceList.m_ResinfoArray.At<JsonLocalResourceInfo>(i),
					webres.m_Version)));
				reslist.push_back( eastl::make_pair( url, m_LocalPath + webres.m_LoacalPath ) );	
			}
			else//说明本地有这个资源,检测版本是否一致
			{
				if ( webres.m_Version != locres.m_Version )//说明资源不匹配
				{
					string url = info.m_BaseUrl + webres.m_ResUrl;
					m_ResourceDownloadInfoMap.insert(
						eastl::make_pair(
						Utility::HashCode( url ),
						eastl::make_pair(
						&m_LocalResourceList.m_ResinfoArray.At<JsonLocalResourceInfo>(i),
						webres.m_Version)));
					reslist.push_back( eastl::make_pair( url, m_LocalPath + webres.m_LoacalPath ) );	
				}
			}
		}
	}
SharedResource ResourceHandler::addResource( quint32 resourceType, SharedResource& resource )
{
    ResourceList *foreignResources;
    switch( resourceType ) {
    case RESOURCE_TYPE_SPRITE:
        foreignResources = &m_foreignSprites;
        break;
    case RESOURCE_TYPE_PICTURE:
        foreignResources = &m_foreignPictures;
        break;
    }

    foreignResources->push_back( resource );
    return resource;
}
SharedResource ResourceHandler::addResource( quint8 resourceType, quint32 identifier, quint16 frame, QFile *file )
{
    ResourceList *foreignResources;
    switch( resourceType ) {
    case RESOURCE_TYPE_SPRITE:
        foreignResources = &m_foreignSprites;
        break;
    case RESOURCE_TYPE_PICTURE:
        foreignResources = &m_foreignPictures;
        break;
    }

    SharedResource reference(new TibiaResource( resourceType, identifier, frame, file));
    foreignResources->push_back(reference);
    return reference;
}
Example #9
0
bool PictureFile::createNew( void )
{
    if( !m_loaded ) {
        m_count = 1;
        TibiaSprite picture;
        picture.id = 1;
        picture.setDummy( false );
        SharedResource newResource = g_resourceHandler.createLocalResource( RESOURCE_TYPE_PICTURE, 0, picture );
        ResourceList resources;
        resources.push_back( newResource );
        g_resourceHandler.addLocalResources( RESOURCE_TYPE_PICTURE, 0, resources );
        m_loaded = true;
        return true;
    }

    return false;
}
Example #10
0
ResourceList
Session::getResourcesUsed( bool reset )
{
    ScopedLock<ReentrantMutex> sl( session_mtx );

    ResourceList list;
    list.reserve( resources_used.size() );
    for( ResourceList::const_iterator i = resources_used.begin(); i != resources_used.end(); i++ )
    {
        list.push_back( i->get() );
    }

    if ( reset )
        resources_used.clear();

    return list;
}
Example #11
0
	//---------------------------------------------------------------------------------------------------------
	void Checking::_AllResource( ResourceList& reslist, const JsonEntryInfo& info )
	{
		m_LocalResourceList.m_ResinfoArray.Resize( info.m_ResinfoArray.Getsize() );
		for ( int i = 0; i < info.m_ResinfoArray.Getsize(); ++ i )
		{
			const JsonResourceInfo& res = info.m_ResinfoArray.At<JsonResourceInfo>(i);
			JsonLocalResourceInfo& local = m_LocalResourceList.m_ResinfoArray.At<JsonLocalResourceInfo>(i);
			string url = info.m_BaseUrl + res.m_ResUrl;
			local.m_LoacalPath = res.m_LoacalPath;
			local.m_Version = 0;
			m_ResourceDownloadInfoMap.insert(
				eastl::make_pair(
				Utility::HashCode( url ),
				eastl::make_pair(
				&m_LocalResourceList.m_ResinfoArray.At<JsonLocalResourceInfo>(i),
				res.m_Version)));
			reslist.push_back( eastl::make_pair( url, m_LocalPath + res.m_LoacalPath ) );
		}
	}
Example #12
0
void Game::load() {
	ResourceList list;
	list.push_back(new ResourceImage("image.game.icon", "res/icon.png"));
	list.push_back(new ResourceImage("image.gui.menuBackground", "res/gui/menuBackground.png"));
	list.push_back(new ResourceTexture("texture.gui.menuBackground", "image.gui.menuBackground"));
	list.push_back(new ResourceImage("image.tile.stone", "res/tile/stone.png"));
	list.push_back(new ResourceImage("image.tile.grass", "res/tile/grass.png"));
	list.push_back(new ResourceImage("image.mob.player", "res/mob/hero.png"));
	list.push_back(new TileSheet("tilesheet.tile.stone", "image.tile.stone"));
	list.push_back(new TileSheet("tilesheet.tile.grass", "image.tile.grass"));
	list.push_back(new TileSheet("tilesheet.mob.player", "image.mob.player"));

	ResourceLoader::queue(list);

	ResourceLoader::loadThread();
}