summaryrefslogtreecommitdiff
path: root/gcsdk/jobtime.cpp
diff options
context:
space:
mode:
authorFluorescentCIAAfricanAmerican <[email protected]>2020-04-22 12:56:21 -0400
committerFluorescentCIAAfricanAmerican <[email protected]>2020-04-22 12:56:21 -0400
commit3bf9df6b2785fa6d951086978a3e66f49427166a (patch)
tree2c0f1f0c63c4832882bc93814ebd2c2b1c6224e5 /gcsdk/jobtime.cpp
downloadarchived-source-engine-2018-hl2-src-master.tar.xz
archived-source-engine-2018-hl2-src-master.zip
Diffstat (limited to 'gcsdk/jobtime.cpp')
-rw-r--r--gcsdk/jobtime.cpp78
1 files changed, 78 insertions, 0 deletions
diff --git a/gcsdk/jobtime.cpp b/gcsdk/jobtime.cpp
new file mode 100644
index 0000000..c2dd039
--- /dev/null
+++ b/gcsdk/jobtime.cpp
@@ -0,0 +1,78 @@
+//========= Copyright Valve Corporation, All rights reserved. ============//
+//
+// Purpose: Encapsultes the job system's version of time (which is != to wall clock time)
+//
+//=============================================================================
+
+#include "stdafx.h"
+
+// memdbgon must be the last include file in a .cpp file!!!
+#include "tier0/memdbgon.h"
+
+namespace GCSDK
+{
+
+uint64 CJobTime::sm_lTimeCur = 0;
+
+//-----------------------------------------------------------------------------
+// Purpose: Constructor
+//-----------------------------------------------------------------------------
+CJobTime::CJobTime()
+{
+ m_lTime = sm_lTimeCur;
+}
+
+
+//----------------------------------------------------------------------------
+// Purpose: Sets our value to the current time
+//-----------------------------------------------------------------------------
+void CJobTime::SetToJobTime()
+{
+ m_lTime = sm_lTimeCur;
+}
+
+
+//-----------------------------------------------------------------------------
+// Purpose: Sets our value as an offset from the current time
+//-----------------------------------------------------------------------------
+void CJobTime::SetFromJobTime( int64 dMicroSecOffset )
+{
+ m_lTime = sm_lTimeCur + dMicroSecOffset;
+}
+
+
+//-----------------------------------------------------------------------------
+// Purpose: Returns the amount of time that's passed between our time and the
+// current time.
+// Output: Time that's passed between our time and the current time
+//-----------------------------------------------------------------------------
+int64 CJobTime::CServerMicroSecsPassed() const
+{
+ return( sm_lTimeCur - m_lTime );
+}
+
+
+//-----------------------------------------------------------------------------
+// Purpose: Updates our current time value. We only
+// update the time once per frame-- the rest of the time, we just
+// access a cached copy of the time. On the server, we use an arbitrary
+// time value beginning at 0, and incremented by 50 milliseconds every
+// frame.
+// NOTE: This should only be called once per frame.
+//-----------------------------------------------------------------------------
+void CJobTime::UpdateJobTime( int cMicroSecPerShellFrame )
+{
+ sm_lTimeCur += cMicroSecPerShellFrame; // force a 50 msec clock
+}
+
+
+//-----------------------------------------------------------------------------
+// Purpose: Stomps the current clock with the specified time
+// Input : lCurrentTime - new current time
+//-----------------------------------------------------------------------------
+void CJobTime::SetCurrentJobTime( uint64 lCurrentTime )
+{
+ sm_lTimeCur = lCurrentTime;
+}
+
+} // namespace GCSDK \ No newline at end of file