本文整理汇总了C++中CTimeValue::GetValue方法的典型用法代码示例。如果您正苦于以下问题:C++ CTimeValue::GetValue方法的具体用法?C++ CTimeValue::GetValue怎么用?C++ CTimeValue::GetValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CTimeValue
的用法示例。
在下文中一共展示了CTimeValue::GetValue方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Update
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;
}
}
}
}
}
示例2:
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
示例3: UpdateOnFrameStart
void gkTimer::UpdateOnFrameStart()
{
if(!m_bEnabled)
return;
if (sys_max_fps != 0)
{
CTimeValue timeFrameMax;
timeFrameMax.SetMilliSeconds((int64)(1000.f/(float)sys_max_fps));
static CTimeValue sTimeLast = gEnv->pTimer->GetAsyncTime();
const CTimeValue timeLast = timeFrameMax + sTimeLast;
while(timeLast.GetValue() > gEnv->pTimer->GetAsyncTime().GetValue())
{
volatile int i=0;
while(i++ < 1000);
}
sTimeLast = gEnv->pTimer->GetAsyncTime();
}
assert(m_pfnUpdate); // call Init() before
if ((m_nFrameCounter & 127)==0)
{
// every bunch of frames, check frequency to adapt to
// CPU power management clock rate changes
#ifdef OS_WIN32
LARGE_INTEGER TTicksPerSec;
if (QueryPerformanceFrequency(&TTicksPerSec))
{
// if returns false, no performance counter is available
m_lTicksPerSec=TTicksPerSec.QuadPart;
}
#endif
}
m_nFrameCounter++;
#ifdef PROFILING
m_fFrameTime = 0.020f; // 20ms = 50fps
g_lCurrentTime += (int)(m_fFrameTime*(float)(CTimeValue::TIMEVALUE_PRECISION));
m_lCurrentTime = g_lCurrentTime;
m_lLastTime = m_lCurrentTime;
RefreshGameTime(m_lCurrentTime);
RefreshUITime(m_lCurrentTime);
return;
#endif
int64 now = (*m_pfnUpdate)();
if (m_lForcedGameTime >= 0)
{
// m_lCurrentTime contains the time, which should be current
// but time has passed since Serialize until UpdateOnFrameStart
// so we have to make sure to compensate!
m_lOffsetTime = m_lForcedGameTime - now + m_lBaseTime;
m_lLastTime = now - m_lBaseTime;
m_lForcedGameTime = -1;
}
// Real time.
m_lCurrentTime = now - m_lBaseTime;
//m_fRealFrameTime = m_fFrameTime = (float)(m_lCurrentTime-m_lLastTime) / (float)(m_lTicksPerSec);
m_fRealFrameTime = m_fFrameTime = (float)((double)(m_lCurrentTime-m_lLastTime) / (double)(m_lTicksPerSec));
if( 0 != m_fixed_time_step) // Absolute zero used as a switch. looks wrong, but runs right ;-)
{
#ifdef OS_WIN32
if (m_fixed_time_step < 0)
{
// Enforce real framerate by sleeping.
float sleep = -m_fixed_time_step - m_fFrameTime;
if (sleep > 0)
{
// while first
// float now = GetAsyncCurTime();
bool breaksleep = 0;
// if (sleep < 0.01f)
// {
// for (int i=0; i < 1000000; ++i)
// {
// if( GetAsyncCurTime() - now > sleep )
// {
// breaksleep = 1;
// break;
// }
// }
// }
if (!breaksleep)
{
Sleep((unsigned int)(sleep*1000.f));
m_lCurrentTime = (*m_pfnUpdate)() - m_lBaseTime;
//m_fRealFrameTime = (float)(m_lCurrentTime-m_lLastTime) / (float)(m_lTicksPerSec);
m_fRealFrameTime = (float)((double)(m_lCurrentTime-m_lLastTime) / (double)(m_lTicksPerSec));
}
//.........这里部分代码省略.........