Beispiel #1
0
void CDownloadMgr::WaitForDownloadsToFinish(const char** resources, int numResources, float timeout)
{
	CDownloadableResourcePtr* pResources=new CDownloadableResourcePtr[numResources];
	for (int i=0; i<numResources; ++i)
	{
		CDownloadableResourcePtr pRes = FindResourceByName(resources[i]);
		if (pRes)
		{
			pRes->StartDownloading();
		}
		pResources[i] = pRes;
	}
	CTimeValue startTime = gEnv->pTimer->GetAsyncTime();
	while (true)
	{
		bool allFinished = true;
		for (int i=0; i<numResources; ++i)
		{
			CDownloadableResourcePtr pRes = pResources[i];
			if (pRes)
			{
				CDownloadableResource::TState state = pRes->GetState();
				if (state & CDownloadableResource::k_callbackInProgressMask)
				{
					allFinished = false;
					break;
				}
			}
		}
		CTimeValue currentTime = gEnv->pTimer->GetAsyncTime();
		if (allFinished || currentTime.GetDifferenceInSeconds(startTime) > timeout)
		{
			break;
		}
		CrySleep(100);
	};
	delete [] pResources;
	DispatchCallbacks();
}
Beispiel #2
0
void CAntiCheatManager::OnSessionEnd()
{
	DumpPlayerRecords();
	DumpCheatRecords();
	DecayCheatRecords();
	
	CloseLogFile();
	BackupLogFileAndSubmit();	

	CTimeValue currentTime = gEnv->pTimer->GetAsyncTime();
	float deltaSeconds = currentTime.GetDifferenceInSeconds(m_lastDownloadTime);
	if (deltaSeconds > g_pGameCVars->g_dataRefreshFrequency * 3600)
	{
		CDownloadableResourcePtr res = GetDownloadableResource();
		if (res)
		{
			// Clear the downloaded data and start download again
			res->Purge();
			res->StartDownloading();
		}
		m_lastDownloadTime = currentTime;
	}
}