Go to the source code of this file.
Functions | |
bool | tTimerIsAccurate () |
returns true if a timer with more than millisecond accuracy is available | |
double | tSysTimeFloat () |
returns true if a timer with more than millisecond accuracy is available | |
double | tRealSysTimeFloat () |
returns the current frame's time ( from the playback ) | |
void | tAdvanceFrame (int usecdelay=0) |
returns the current frame's time ( from the real system ) | |
void | tDelay (int usecdelay) |
andvances one frame: updates the system time | |
void | tDelayForce (int usecdelay) |
delays for the specified number of microseconds |
void tAdvanceFrame | ( | int | usecdelay = 0 |
) |
returns the current frame's time ( from the real system )
Definition at line 320 of file tSysTime.cpp.
References TimeArchiver< Archiver >::Archive(), tRecorderBase::IsPlayingBack(), tTime::microseconds, tTime::seconds, st_Breakpoint(), tAdvanceFrameSys(), tASSERT, tDelay(), timeRelative, and timeStart.
Referenced by ConnectToServerCore(), nServerInfo::GetFromLAN(), nServerInfo::GetFromMaster(), main(), uMenu::Message(), gGame::NetSync(), next_free(), nNetObject::Object(), uMenu::OnEnter(), sg_HostGame(), gGame::StateUpdate(), nServerInfo::TellMasterAboutMe(), and welcome().
00322 { 00323 // delay a bit if we're not playing back 00324 if ( usecdelay > 0 ) 00325 tDelay( usecdelay ); 00326 00327 static tTime timeNewRelative; 00328 tAdvanceFrameSys( timeStart, timeNewRelative ); 00329 00330 // try to fetch time from playback 00331 // tTime timeAdvance; 00332 if ( TimeArchiver< tPlaybackBlock >::Archive( timeRelative ) ) 00333 { 00334 // timeRelative = timeRelative + timeAdvance; 00335 00336 // correct start time so transition to normal time after the recording ended is smooth 00337 timeStart = timeStart + timeNewRelative - timeRelative; 00338 } 00339 else 00340 { 00341 // must never be called when a recording is running 00342 tASSERT( !tRecorder::IsPlayingBack() ); 00343 00344 #ifdef FIXED_FRAMERATE 00345 tTime fixed, catchup, timeFixedRelative; 00346 fixed.seconds = 0; 00347 fixed.microseconds = (int)(1000000. / FIXED_FRAMERATE); 00348 timeFixedRelative = timeRelative + fixed; 00349 00350 catchup = timeFixedRelative/*game-time*/ - timeNewRelative/*real-time*/; 00351 if (catchup.seconds >= 0) { 00352 #ifdef DEBUG 00353 printf("catching up %d.%d seconds\n", catchup.seconds, catchup.microseconds); 00354 #endif 00355 for (int i = catchup.seconds; i; --i) 00356 tDelay(1000000); 00357 tDelay(catchup.microseconds); 00358 timeNewRelative = timeFixedRelative; 00359 } else { 00360 printf("WARNING: Real time ahead of game time!\nreal: %d.%06d\ngame: %d.%06d\ncatchup: %d.%06d\n", timeNewRelative.seconds, timeNewRelative.microseconds, timeFixedRelative.seconds, timeFixedRelative.microseconds, 1 - catchup.seconds, 1000000 - catchup.microseconds); 00361 #ifdef FIXED_FRAMERATE_PRIORITY 00362 timeNewRelative = timeFixedRelative; 00363 #endif 00364 } 00365 #endif 00366 00367 // timeAdvance = timeRealRelative - timeRelative; 00368 timeRelative = timeNewRelative; 00369 } 00370 00371 // try to archive it 00372 TimeArchiver< tRecordingBlock >::Archive( timeRelative ); 00373 #ifdef DEBUG 00374 { 00375 if ( timeRelative.microseconds == 337949 && timeRelative.seconds == 25 ) 00376 { 00377 st_Breakpoint(); 00378 } 00379 } 00380 #endif
void tDelay | ( | int | usecdelay | ) |
andvances one frame: updates the system time
Definition at line 294 of file tSysTime.cpp.
References tRecorderBase::IsPlayingBack().
Referenced by gGame::GameLoop(), uMenu::GenericBackground(), nServerInfo::GetFromLAN(), nServerInfo::GetFromLANContinuously(), uMenu::OnEnter(), Render(), nBasicNetworkSystem::Select(), and tAdvanceFrame().
00296 { 00297 // delay a bit if we're not playing back 00298 if ( ! tRecorder::IsPlayingBack() ) 00299 usleep( usecdelay ); 00300 else 00301 s_delayedInPlayback = true;
void tDelayForce | ( | int | usecdelay | ) |
delays for the specified number of microseconds
Definition at line 303 of file tSysTime.cpp.
References tTime::microseconds, and timeStart.
Referenced by rSysDep::SwapGL().
00305 { 00306 // delay a bit 00307 if ( !s_delayedInPlayback ) 00308 usleep( usecdelay ); 00309 else 00310 { 00311 // when recording, the machine was idling around. No need to play that back. 00312 // Only pretend to delay. 00313 tTime timeDelay; 00314 timeDelay.microseconds = usecdelay; 00315 timeStart = timeStart - timeDelay; 00316 } 00317 00318 s_delayedInPlayback = false;
double tRealSysTimeFloat | ( | ) |
returns the current frame's time ( from the playback )
Definition at line 408 of file tSysTime.cpp.
References tTime::microseconds, tTime::seconds, tAdvanceFrameSys(), timeRealRelative, and timeRealStart.
Referenced by PerformanceCounter::PerformanceCounter(), and rSysDep::SwapGL().
00410 { 00411 // get real time from real OS 00412 tAdvanceFrameSys( timeRealStart, timeRealRelative ); 00413 return ( timeRealRelative.seconds + timeRealRelative.microseconds*1E-6 ) * st_timeFactor;
double tSysTimeFloat | ( | ) |
returns true if a timer with more than millisecond accuracy is available
Definition at line 385 of file tSysTime.cpp.
References tTime::microseconds, tTime::seconds, and timeRelative.
Referenced by gJoystick::Act(), eTeam::AddPlayer(), eTeam::AddPlayerDirty(), eVoter::Age(), eVoter::AllowNameChange(), gGame::Analysis(), nQueryMessageStats::Block(), nSpamProtection::BlockTime(), cCockpit::cb_Framerate(), cCockpit::cb_RunningTime(), CenterDisplay(), eChatSpamTester::Check(), nSpamProtection::CheckSpam(), ConnectToServerCore(), gLogo::Display(), eVoteItemKick::DoCheckValid(), eVoteItemHarm::DoCheckValid(), rConsole::DoPrint(), nServerInfo::DoQueryAll(), gCycleMovement::DoTurn(), gCycle::DoTurn(), ePlayerNetID::ePlayerNetID(), eTimer::eTimer(), eVoteItem::Evaluate(), gServerMenuItem::Event(), gBrowserMenuItem::Event(), eVoter::eVoter(), nQueryMessageStats::FloodProtection(), free_server(), GameLoop(), nServerInfo::GetFromLAN(), nServerInfo::GetFromMaster(), nServerInfo::GetMasters(), nServerInfo::GetSmallServerInfo(), uMenu::HandleEvent(), uMenu::IdleInput(), uBind::IsDoubleBind(), ePlayerNetID::LastActivity(), login_callback(), main(), MenuBackground(), uMenu::Message(), gCycleMovement::MyInitAfterCreation(), gCycle::MyInitAfterCreation(), ePlayerNetID::MyInitAfterCreation(), net_destroy_handler(), nServerInfo::NetReadThis(), next_free(), nNetObject::Object(), nNetObject::ObjectDangerous(), uMenu::OnEnter(), gCycle::OnNotifyNewDestination(), gServerMenu::OnRender(), eVoter::PlayerChanged(), nQueryMessageStats::PrintWarning(), nServerInfo::QueryServer(), ePlayerNetID::RemoveChatbots(), gCycle::Render(), rConsole::Render(), gCycle::RenderName(), nServerLag::Report(), nClientLag::ReportLag(), gCycle::RequestSyncAll(), gCycle::RequestSyncOwner(), eTimer::Reset(), nServerLag::Reset(), gCycle::RightBeforeDeath(), nServerInfo::RunMaster(), nConfItemBase::s_GetConfigMessage(), rConsole::Scroll(), nDeletedInfo::Set(), uMenuItem::SetColor(), rConsole::SetHeight(), sg_FullscreenMessage(), sg_HostGame(), sg_Timestamp(), sn_DoDestroy(), sn_SendPlanned1(), sn_Statistics(), sn_Sync(), gGame::StateUpdate(), su_InputSync(), rSysDep::SwapGL(), nNetObject::SyncAll(), gGame::SyncState(), eTimer::SyncTime(), nServerLag::TakeCredit(), nServerInfo::TellMasterAboutMe(), eTimer::TimeNoSync(), gCycle::Timestep(), nClientLag::Timestep(), gCycleMovement::TimestepCore(), gCycle::TimestepCore(), gJoystick::Turn(), gServerMenu::Update(), update_settings(), ePlayerNetID::WaitToLeaveChat(), welcome(), and nNetObject::~nNetObject().
00387 { 00388 #ifdef DEBUG 00389 // if ( ! tRecorder::IsPlayingBack() ) 00390 // { 00391 // static tTime time; 00392 // tAdvanceFrameSys( timeStart, time ); 00393 // tTime timeStep = time - timeRelative; 00394 // if ( timeStep.seconds > 5 ) 00395 // { 00396 // std::cout << "tAdvanceFrame not called often enough!\n"; 00397 // st_Breakpoint(); 00398 // tAdvanceFrameSys( timeRealRelative ); 00399 // } 00400 // } 00401 #endif 00402 00403 return ( timeRelative.seconds + timeRelative.microseconds*1E-6 ) * st_timeFactor;
bool tTimerIsAccurate | ( | ) |
returns true if a timer with more than millisecond accuracy is available
Definition at line 221 of file tSysTime.cpp.
Referenced by se_SmoothTime(), and eTimer::SyncTime().