summaryrefslogtreecommitdiff
path: root/engine/clientframe.h
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 /engine/clientframe.h
downloadarchived-source-engine-2018-hl2-src-3bf9df6b2785fa6d951086978a3e66f49427166a.tar.xz
archived-source-engine-2018-hl2-src-3bf9df6b2785fa6d951086978a3e66f49427166a.zip
Diffstat (limited to 'engine/clientframe.h')
-rw-r--r--engine/clientframe.h83
1 files changed, 83 insertions, 0 deletions
diff --git a/engine/clientframe.h b/engine/clientframe.h
new file mode 100644
index 0000000..2d00876
--- /dev/null
+++ b/engine/clientframe.h
@@ -0,0 +1,83 @@
+//========= Copyright Valve Corporation, All rights reserved. ============//
+//
+// Purpose:
+//
+//=============================================================================//
+
+#ifndef CLIENTFRAME_H
+#define CLIENTFRAME_H
+#ifdef _WIN32
+#pragma once
+#endif
+
+#include <bitvec.h>
+#include <const.h>
+#include <tier1/mempool.h>
+
+class CFrameSnapshot;
+
+#define MAX_CLIENT_FRAMES 128
+
+class CClientFrame
+{
+public:
+
+ CClientFrame( void );
+ CClientFrame( int tickcount );
+ CClientFrame( CFrameSnapshot *pSnapshot );
+ virtual ~CClientFrame();
+ void Init( CFrameSnapshot *pSnapshot );
+ void Init( int tickcount );
+
+ // Accessors to snapshots. The data is protected because the snapshots are reference-counted.
+ inline CFrameSnapshot* GetSnapshot() const { return m_pSnapshot; };
+ void SetSnapshot( CFrameSnapshot *pSnapshot );
+ void CopyFrame( CClientFrame &frame );
+ virtual bool IsMemPoolAllocated() { return true; }
+
+public:
+
+ // State of entities this frame from the POV of the client.
+ int last_entity; // highest entity index
+ int tick_count; // server tick of this snapshot
+
+ // Used by server to indicate if the entity was in the player's pvs
+ CBitVec<MAX_EDICTS> transmit_entity; // if bit n is set, entity n will be send to client
+ CBitVec<MAX_EDICTS> *from_baseline; // if bit n is set, this entity was send as update from baseline
+ CBitVec<MAX_EDICTS> *transmit_always; // if bit is set, don't do PVS checks before sending (HLTV only)
+
+ CClientFrame* m_pNext;
+
+private:
+
+ // Index of snapshot entry that stores the entities that were active and the serial numbers
+ // for the frame number this packed entity corresponds to
+ // m_pSnapshot MUST be private to force using SetSnapshot(), see reference counters
+ CFrameSnapshot *m_pSnapshot;
+};
+
+// TODO substitute CClientFrameManager with an intelligent structure (Tree, hash, cache, etc)
+class CClientFrameManager
+{
+public:
+ CClientFrameManager(void);
+ virtual ~CClientFrameManager(void);
+
+ int AddClientFrame( CClientFrame *pFrame ); // returns current count
+ CClientFrame *GetClientFrame( int nTick, bool bExact = true );
+ void DeleteClientFrames( int nTick ); // -1 for all
+ int CountClientFrames( void ); // returns number of frames in list
+ void RemoveOldestFrame( void ); // removes the oldest frame in list
+
+ CClientFrame* AllocateFrame();
+
+private:
+ void FreeFrame( CClientFrame* pFrame );
+
+ CClientFrame *m_Frames; // updates can be delta'ed from here
+ CClientFrame *m_LastFrame;
+ int m_nFrames;
+ CClassMemoryPool< CClientFrame > m_ClientFramePool;
+};
+
+#endif // CLIENTFRAME_H