当前位置: 首页>>代码示例>>C++>>正文


C++ CTimeValue::GetDifferenceInSeconds方法代码示例

本文整理汇总了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();
}
开发者ID:aronarts,项目名称:FireNET,代码行数:55,代码来源:NetworkStallTicker.cpp

示例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();
}
开发者ID:Aytunes,项目名称:Tanks,代码行数:39,代码来源:DownloadMgr.cpp

示例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;
	}
}
开发者ID:aronarts,项目名称:FireNET,代码行数:23,代码来源:AntiCheatManager.cpp


注:本文中的CTimeValue::GetDifferenceInSeconds方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。