本文整理汇总了C++中CTimeValue类的典型用法代码示例。如果您正苦于以下问题:C++ CTimeValue类的具体用法?C++ CTimeValue怎么用?C++ CTimeValue使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CTimeValue类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: WriteFrameHeaders
// Description:
//
// Arguments:
//
// Return:
//
void CVisualLog::WriteFrameHeaders( int iFrameNum, const char *sImageName )
{
// Frame header example: Frame 0 [Frame000000.jpg] [34.527]
CTimeValue time = gEnv->pTimer->GetFrameStartTime();
fprintf( m_fLogFile, "Frame %d [%s] [%0.3f]\n", iFrameNum, sImageName, time.GetSeconds() );
fprintf( m_fLogParamsFile, "Frame %d [%s] [%0.3f]\n", iFrameNum, sImageName, time.GetSeconds() );
}
开发者ID:NightOwlsEntertainment,项目名称:PetBox_A_Journey_to_Conquer_Elementary_Algebra,代码行数:14,代码来源:VisualLog.cpp
示例2: gettimeofday
void
CTimer::Update()
{
char *p0;
struct tm *tm;
time_t mlSec;
uint32_t muMSec;
CTimeValue *tp;
struct timeval tv;
struct timezone tz;
if ( !MINA_TRYLOCK(&this->muLock) )
{
return;
}
gettimeofday(&tv, &tz);
mlSec = tv.tv_sec;
muMSec = tv.tv_usec / TIME_MSEC;
this->moTime.Set(mlSec * TIME_SEC + tv.tv_usec * TIME_USEC, TIME_NSEC);
tp = &this->moCacheTimes[muSlot];
if (tp->Sec() == mlSec)
{
tp->Msec(muMSec);
MINA_UNLOCK(&this->muLock);
return;
}
if (muSlot == TIME_SLOTS - 1)
{
muSlot = 0;
}
else
{
muSlot++;
}
tp = &this->moCacheTimes[muSlot];
tp->Sec(mlSec);
tp->Msec(muMSec);
p0 = &maacFormatTimes[muSlot][0];
tm = gmtime(&mlSec);
strftime(p0, FORM_TIME_LEN, "%Y-%m-%d %H:%M:%S", tm);
this->mpoCacheTime = tp;
this->mpcFormatTime = p0;
MINA_UNLOCK(&this->muLock);
}
示例3:
CTimeValue CTimeValue::operator-(const CTimeValue& rstTime)
{
timeval stTimeValResult;
CTimeUtility::TimeValMinus(m_stTimeval, rstTime.m_stTimeval, stTimeValResult);
CTimeValue stTimeManager;
stTimeManager.SetTimeValue(stTimeValResult);
return stTimeManager;
}
示例4: 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();
}
示例5: TRACE
CUnitTest::~CUnitTest(void)
{
TRACE(TRACE_ENABLE);
CTimeValue elapsed = m_timeEnded-m_timeStarted;
int32 days, hours, minutes;
float seconds;
elapsed.GetTime(days, hours, minutes, seconds);
const char* errorColour = (m_errorTotal != 0) ? COLOUR_ERROR : COLOUR_DEFAULT;
LOG_ALWAYS(m_log, COLOUR_TEST_INFO "[%s] " COLOUR_DEFAULT "%d tests completed in %s%d days, %02u:%02u:%06.3fs; " COLOUR_DEFAULT "%s%d errors\n\n" COLOUR_RESET, m_name, m_totalTests, (elapsed.GetTicks() < 0) ? "-" : "", days, hours, minutes, seconds, errorColour, m_errorTotal);
}
示例6: ProcessEvent
virtual void ProcessEvent( EFlowEvent event, SActivationInfo *pActInfo )
{
switch (event)
{
case eFE_Initialize:
{
pActInfo->pGraph->SetRegularlyUpdated( pActInfo->myID, false );
}
break;
case eFE_Update:
{
float fPeriod = GetPortFloat(pActInfo,IN_PERIOD);
CTimeValue time = gEnv->pTimer->GetFrameStartTime();
CTimeValue dt = time - m_lastTickTime;
if (dt.GetSeconds() >= fPeriod)
{
m_lastTickTime = time;
++m_count;
ActivateOutput( pActInfo, OUT_COUNT, m_count );
if (m_count >= GetPortInt( pActInfo, IN_LIMIT ))
{
pActInfo->pGraph->SetRegularlyUpdated( pActInfo->myID, false );
ActivateOutput( pActInfo, OUT_FINISHED, GetPortAny( pActInfo, IN_START ));
}
}
}
break;
case eFE_Activate:
{
if (IsPortActive(pActInfo,IN_START))
{
pActInfo->pGraph->SetRegularlyUpdated( pActInfo->myID, true );
m_count = 0;
m_lastTickTime = gEnv->pTimer->GetFrameStartTime();
}
if (IsPortActive(pActInfo,IN_STOP))
{
pActInfo->pGraph->SetRegularlyUpdated( pActInfo->myID, false );
}
if (IsPortActive(pActInfo,IN_CONTINUE))
{
pActInfo->pGraph->SetRegularlyUpdated( pActInfo->myID, true );
}
}
break;
}
}
开发者ID:NightOwlsEntertainment,项目名称:PetBox_A_Journey_to_Conquer_Elementary_Algebra,代码行数:50,代码来源:FlowTimeNode.cpp
示例7: CRY_ASSERT
//------------------------------------------------------------------------
void CFireModePlugin_Overheat::Activate(bool activate)
{
CWeapon* pWeapon = m_pOwnerFiremode->GetWeapon();
CRY_ASSERT(pWeapon);
if(activate)
{
m_heat = 0.f;
m_overheat = 0.f;
if(m_nextHeatTime > 0.0f)
{
CTimeValue time = gEnv->pTimer->GetFrameStartTime();
float dt = m_nextHeatTime - time.GetSeconds();
if(dt > 0.0f)
{
m_heat = min(dt,1.0f);
}
if(dt > 1.0f)
{
m_overheat = dt - 1.0f;
}
m_nextHeatTime = 0.0f;
}
}
else
{
if(m_heatEffectId)
{
pWeapon->DetachEffect(m_heatEffectId);
m_heatEffectId = 0;
}
m_nextHeatTime = 0.0f;
if(m_heat>0.0f)
{
CTimeValue time = gEnv->pTimer->GetFrameStartTime();
m_nextHeatTime = time.GetSeconds() + m_heat + m_overheat;
}
m_heat = 0.f;
m_overheat = 0.f;
}
m_firedThisFrame = false;
}
示例8: NET_IMPLEMENT_SIMPLE_ATSYNC_MESSAGE
NET_IMPLEMENT_SIMPLE_ATSYNC_MESSAGE( CGameServerChannel, SyncTimeServer, eNRT_ReliableOrdered, eMPF_NoSendDelay )
{
CTimeValue value = gEnv->pTimer->GetAsyncTime();
INetSendablePtr msg = new CSimpleNetMessage<SSyncTimeClient>(SSyncTimeClient(param.id, param.clientTime, param.serverTime, value.GetValue()), CGameClientChannel::SyncTimeClient);
GetNetChannel()->AddSendable(msg, 0, NULL, NULL);
return true;
}
开发者ID:NightOwlsEntertainment,项目名称:PetBox_A_Journey_to_Conquer_Elementary_Algebra,代码行数:8,代码来源:GameServerChannel.cpp
示例9: ScriptTimer
//////////////////////////////////////////////////////////////////////////
// Create a new timer and put it in the list of managed timers.
int CScriptTimerMgr::AddTimer( ScriptTimer &timer )
{
CTimeValue nCurrTimeMillis = gEnv->pTimer->GetFrameStartTime();
timer.nStartTime = nCurrTimeMillis.GetMilliSecondsAsInt64();
timer.nEndTime = timer.nStartTime + timer.nMillis;
if (!timer.nTimerID)
{
m_nLastTimerID++;
timer.nTimerID = m_nLastTimerID;
}
else
{
if (timer.nTimerID > m_nLastTimerID)
m_nLastTimerID = timer.nTimerID+1;
}
m_mapTempTimers[timer.nTimerID] = new ScriptTimer(timer);
return timer.nTimerID;
}
示例10: ProcessEvent
void ProcessEvent(EFlowEvent event, SActivationInfo* pActivationInfo)
{
switch (event)
{
case eFE_Initialize:
{
SetAutoUpdate(pActivationInfo, GetPortBool(pActivationInfo, eIP_Auto));
break;
}
case eFE_Activate:
{
if (IsPortActive(pActivationInfo, eIP_Auto))
{
SetAutoUpdate(pActivationInfo, GetPortBool(pActivationInfo, eIP_Auto));
}
else if (IsPortActive(pActivationInfo, eIP_Freq))
{
m_frequency = GetPortFloat(pActivationInfo, eIP_Freq);
}
else if (IsPortActive(pActivationInfo, eIP_Sync))
{
Sync(pActivationInfo);
}
break;
}
case eFE_Update:
{
CTimeValue delta = gEnv->pTimer->GetFrameStartTime() - m_prevTime;
if (delta.GetSeconds() >= m_frequency)
{
Sync(pActivationInfo);
}
break;
}
}
}
示例11: OnClientReceivedKill
void CLagOMeter::OnClientReceivedKill(const CActor::KillParams &killParams)
{
CTimeValue currentTime = gEnv->pTimer->GetAsyncTime();
if (killParams.shooterId == g_pGame->GetClientActorId())
{
// Try to find the corresponding request hit info to see how far lagged behind we are
int index = killParams.lagOMeterHitId;
if (index > 0 && index < HIT_HISTORY_COUNT)
{
SHitRequestHistory& item = m_hitHistory[index];
if (item.requestTime.GetValue() != 0)
{
CTimeValue diff = currentTime - item.requestTime;
CTelemetryCollector* pTelemetryCollector = (CTelemetryCollector*)g_pGame->GetITelemetryCollector();
if (pTelemetryCollector)
{
pTelemetryCollector->LogEvent("Kill Latency", diff.GetMilliSeconds());
}
}
}
}
}
示例12: FindResourceByName
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();
}
示例13: DumpPlayerRecords
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;
}
}
示例14: CleanUpServers
void CGameQueryListener::CleanUpServers()
{
if(m_servers.size() == 0)
return;
CTimeValue now = gEnv->pTimer->GetFrameStartTime();
std::vector<SGameServer>::iterator it;
//kill old servers
for(int i = 0; i < m_servers.size(); ++i)
{
uint32 seconds = (uint32)(now.GetSeconds() - m_servers[i].m_lastTime.GetSeconds());
if(!seconds)
continue;
if(seconds > 10)
{
it = m_servers.begin();
for(int inc = 0; inc < i; ++inc)
++it;
m_servers.erase(it);
--i;
}
}
}
开发者ID:NightOwlsEntertainment,项目名称:PetBox_A_Journey_to_Conquer_Elementary_Algebra,代码行数:24,代码来源:GameQueryListener.cpp
示例15: while
void CallbackTimer::Update()
{
if (!m_timeouts.empty())
{
if (m_resort)
{
std::sort(m_timeouts.begin(), m_timeouts.end());
m_resort = false;
}
CTimeValue now = gEnv->pTimer->GetFrameStartTime();
while (!m_timeouts.empty() && (m_timeouts.front().timeout <= now))
{
TimeoutInfo timeout = m_timeouts.front();
m_timeouts.pop_front();
TimerInfo timer = m_timers[timeout.timerID];
timer.callback(timer.userdata, timeout.timerID);
if (m_timers.validate(timeout.timerID))
{
if (!timer.repeating)
m_timers.erase(timeout.timerID);
else
{
CTimeValue nextTimeout = timeout.timeout + timer.interval;
if (nextTimeout.GetValue() <= now.GetValue())
nextTimeout.SetValue(now.GetValue() + 1);
timeout.timeout = nextTimeout;
m_timeouts.push_back(timeout);
m_resort = true;
}
}
}
}
}