void CNetworkStallTickerThread::Run() { bool gotLockLastTime=true; #if WARN_ABOUT_LONG_STALLS_IN_TICKER CTimeValue started=gEnv->pTimer->GetAsyncTime(); CTimeValue ended; #endif SetName("NetworkStallTicker"); while (m_threadRunning) { if (gEnv->pNetwork) { gEnv->pNetwork->SyncWithGame(eNGS_SleepNetwork); } if (gotLockLastTime) { CrySleep(33); } else { CrySleep(1); } { if (gEnv->pNetwork) { SCOPED_TICKER_TRY_LOCK; if (SCOPED_TICKER_HAS_LOCK) { gEnv->pNetwork->SyncWithGame(eNGS_MinimalUpdateForLoading); gotLockLastTime=true; } else { gotLockLastTime=false; } gEnv->pNetwork->SyncWithGame(eNGS_WakeNetwork); } #if WARN_ABOUT_LONG_STALLS_IN_TICKER ended = gEnv->pTimer->GetAsyncTime(); if (ended.GetDifferenceInSeconds(started)>1.f) { CryLogAlways("THREADEDLOADING:: No update for %f",ended.GetDifferenceInSeconds(started)); } started=ended; #endif } } Stop(); }
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(); }
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; } }