本文整理汇总了C++中CTimeValue::GetDifferenceInSeconds方法的典型用法代码示例。如果您正苦于以下问题:C++ CTimeValue::GetDifferenceInSeconds方法的具体用法?C++ CTimeValue::GetDifferenceInSeconds怎么用?C++ CTimeValue::GetDifferenceInSeconds使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CTimeValue
的用法示例。
在下文中一共展示了CTimeValue::GetDifferenceInSeconds方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Run
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();
}
示例2: WaitForDownloadsToFinish
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();
}
示例3: OnSessionEnd
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;
}
}