BVB Source Codes

CRYENGINE Show ServerTimer.cpp Source code

Return Download CRYENGINE: download ServerTimer.cpp Source code - Download CRYENGINE Source code - Type:.cpp
  1. // Copyright 2001-2016 Crytek GmbH / Crytek Group. All rights reserved.
  2.  
  3. #include "StdAfx.h"
  4. #include "ServerTimer.h"
  5.  
  6. CServerTimer CServerTimer::m_this;
  7.  
  8. CServerTimer::CServerTimer()
  9. {
  10.         m_remoteFrameStartTime = 1.0f;
  11.         m_frameTime = 0.001f;
  12.         m_replicationTime = 0;
  13. }
  14.  
  15. void CServerTimer::ResetTimer()
  16. {
  17.         CRY_ASSERT(false);
  18. }
  19.  
  20. void CServerTimer::UpdateOnFrameStart()
  21. {
  22.         CTimeValue lastTime = m_remoteFrameStartTime;
  23.  
  24.         if (gEnv->bServer)
  25.                 m_remoteFrameStartTime = gEnv->pTimer->GetFrameStartTime();
  26.         else if (INetChannel* pChannel = CCryAction::GetCryAction()->GetClientChannel())
  27.         {
  28.                 if (pChannel->IsTimeReady())
  29.                         m_remoteFrameStartTime = pChannel->GetRemoteTime();
  30.         }
  31.  
  32.         m_frameTime = (m_remoteFrameStartTime - lastTime).GetSeconds();
  33.         m_frameTime = CLAMP(m_frameTime, 0.001f, 0.25f);
  34.  
  35.         m_replicationTime += m_frameTime;
  36. }
  37.  
  38. float CServerTimer::GetCurrTime(ETimer /* which */) const
  39. {
  40.         return GetFrameStartTime().GetSeconds();
  41. }
  42.  
  43. const CTimeValue& CServerTimer::GetFrameStartTime(ETimer /* which */) const
  44. {
  45.         return m_remoteFrameStartTime;
  46. }
  47.  
  48. CTimeValue CServerTimer::GetAsyncTime() const
  49. {
  50.         return gEnv->pTimer->GetAsyncTime();
  51. }
  52.  
  53. float CServerTimer::GetAsyncCurTime()
  54. {
  55.         return gEnv->pTimer->GetAsyncCurTime();
  56. }
  57.  
  58. float CServerTimer::GetReplicationTime() const
  59. {
  60.         return m_replicationTime;
  61. }
  62.  
  63. float CServerTimer::GetFrameTime(ETimer /* which */) const
  64. {
  65.         return m_frameTime;
  66. }
  67.  
  68. float CServerTimer::GetRealFrameTime() const
  69. {
  70.         return gEnv->pTimer->GetRealFrameTime();
  71. }
  72.  
  73. float CServerTimer::GetTimeScale() const
  74. {
  75.         return 1; //m_time_scale;
  76. }
  77.  
  78. float CServerTimer::GetTimeScale(uint32 channel) const
  79. {
  80.         return 1.0f;
  81. }
  82.  
  83. void CServerTimer::SetTimeScale(float scale, uint32 channel)
  84. {
  85. }
  86.  
  87. void CServerTimer::ClearTimeScales()
  88. {
  89. }
  90.  
  91. void CServerTimer::EnableTimer(const bool bEnable)
  92. {
  93.         CRY_ASSERT(false);
  94. }
  95.  
  96. bool CServerTimer::IsTimerEnabled() const
  97. {
  98.         return true;
  99. }
  100.  
  101. float CServerTimer::GetFrameRate()
  102. {
  103.         return gEnv->pTimer->GetFrameRate();
  104. }
  105.  
  106. void CServerTimer::Serialize(TSerialize ser)
  107. {
  108.         CRY_ASSERT(false);
  109. }
  110.  
  111. bool CServerTimer::PauseTimer(ETimer /* which */, bool /*bPause*/)
  112. {
  113.         assert(false);
  114.         return false;
  115. }
  116.  
  117. bool CServerTimer::IsTimerPaused(ETimer /* which */)
  118. {
  119.         return false;
  120. }
  121.  
  122. bool CServerTimer::SetTimer(ETimer which, float timeInSeconds)
  123. {
  124.         return false;
  125. }
  126.  
  127. void CServerTimer::SecondsToDateUTC(time_t time, struct tm& outDateUTC)
  128. {
  129.         gEnv->pTimer->SecondsToDateUTC(time, outDateUTC);
  130. }
  131.  
  132. time_t CServerTimer::DateToSecondsUTC(struct tm& timePtr)
  133. {
  134.         return gEnv->pTimer->DateToSecondsUTC(timePtr);
  135. }
  136.  
  137. float CServerTimer::TicksToSeconds(int64 ticks) const
  138. {
  139.         return gEnv->pTimer->TicksToSeconds(ticks);
  140. }
  141.  
  142. int64 CServerTimer::GetTicksPerSecond()
  143. {
  144.         return gEnv->pTimer->GetTicksPerSecond();
  145. }
  146.  
downloadServerTimer.cpp Source code - Download CRYENGINE Source code
Related Source Codes/Software:
postal - 2017-06-11
reactide - Reactide is the first dedicated IDE for React web ... 2017-06-11
rkt - rkt is a pod-native container engine for Linux. It... 2017-06-11
uWebSockets - Tiny WebSockets https://for... 2017-06-11
realworld - TodoMVC for the RealWorld - Exemplary fullstack Me... 2017-06-11
CRYENGINE - CRYENGINE is a powerful real-time game development... 2017-06-11
goreplay - GoReplay is an open-source tool for capturing and ... 2017-06-10
pyenv - Simple Python version management 2017-06-10
redux-saga - An alternative side effect model for Redux apps ... 2017-06-10
angular-starter - 2017-06-10

 Back to top