Example #1
0
ResourceSet ResourceInfo::toResourceSet( const ResourceList& rResourceList )
{
    ResourceSet set;
    std::insert_iterator<ResourceSet> ii( set, set.begin() );
    std::copy( rResourceList.begin(), rResourceList.end(), ii );
    return set;
}
Example #2
0
void SurveyTool::StartUsing(PlayerObject* player)
{
    Message*			message;
    ResourceCategory*	mainCat = gResourceManager->getResourceCategoryById(getInternalAttribute<uint32>("survey_tool_resource_category"));
    ResourceList		resourceList;

    mainCat->getResources(resourceList,true);

    gMessageFactory->StartMessage();
    gMessageFactory->addUint32(opResourceListForSurveyMessage);

    gMessageFactory->addUint32(resourceList.size());

    ResourceList::iterator resourceIt = resourceList.begin();

    while(resourceIt != resourceList.end())
    {
        Resource* tmpResource = (*resourceIt);

        gMessageFactory->addString(tmpResource->getName());
        gMessageFactory->addUint64(tmpResource->getId());
        gMessageFactory->addString((tmpResource->getType())->getDescriptor());

        ++resourceIt;
    }

    gMessageFactory->addString(mainCat->getName());
    gMessageFactory->addUint64(mId);

    message = gMessageFactory->EndMessage();

    (player->getClient())->SendChannelA(message, player->getAccountId(),CR_Client,4);
}
Example #3
0
//-------------------------------------------------------------------------------------------------
void sdResourceSystem::GarbageCollect()
{
	sdRequestInfoListItr itr = m_kCachedList.begin();
	sdRequestInfoListItr itr_end = m_kCachedList.end();
	for (; itr != itr_end; ++itr)
	{
		sdRequestInfo& kRequestInfo = *itr;
		RaiseEvent(kRequestInfo.m_spResource);
	}
	m_kCachedList.clear();

	itr = m_kRequestList.begin();
	itr_end = m_kRequestList.end();
	for (; itr != itr_end;)
	{
		sdRequestInfo& kRequestInfo = *itr;

		if (kRequestInfo.m_eRequest == sdRequestInfo::E_REQ_LOAD && kRequestInfo.m_spResource->Cached())
		{
			RaiseEvent(kRequestInfo.m_spResource);
			itr = m_kRequestList.erase(itr);
		}
		else
		{
			++itr;
		}
	}
	m_kRequestList.clear();

	ResourceGroupVecItr itr_res_gp = m_kResourceGroupVec.begin();
	ResourceGroupVecItr itr_res_gp_end = m_kResourceGroupVec.end();
	for (; itr_res_gp != itr_res_gp_end; ++itr_res_gp)
	{
		sdResourceGroup* pkResourceGroup = *itr_res_gp;
		if (!pkResourceGroup)
			continue;

		ResourceList kResourceList;
		pkResourceGroup->GarbageCollect(kResourceList);

		ResourceListItr itr_res_list = kResourceList.begin();
		ResourceListItr itr_res_list_end = kResourceList.end();
		for (; itr_res_list != itr_res_list_end; ++itr_res_list)
		{
			// 后台线程清除资源
			//RequestFree(*itr_res_list);

			// 主线程清除资源
			sdResourcePtr pkResource = *itr_res_list;
			pkResource->FreeResource(false);
			pkResource = 0;
		}
	}
}