summaryrefslogtreecommitdiff
path: root/engine/packed_entity.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 /engine/packed_entity.cpp
downloadarchived-source-engine-2018-hl2-src-3bf9df6b2785fa6d951086978a3e66f49427166a.tar.xz
archived-source-engine-2018-hl2-src-3bf9df6b2785fa6d951086978a3e66f49427166a.zip
Diffstat (limited to 'engine/packed_entity.cpp')
-rw-r--r--engine/packed_entity.cpp117
1 files changed, 117 insertions, 0 deletions
diff --git a/engine/packed_entity.cpp b/engine/packed_entity.cpp
new file mode 100644
index 0000000..9944f82
--- /dev/null
+++ b/engine/packed_entity.cpp
@@ -0,0 +1,117 @@
+//========= Copyright Valve Corporation, All rights reserved. ============//
+//
+// Purpose:
+//
+// $NoKeywords: $
+//
+//=============================================================================//
+#include <malloc.h>
+#include <string.h>
+#include <assert.h>
+#include "packed_entity.h"
+#include "basetypes.h"
+#include "changeframelist.h"
+#include "dt_send.h"
+#include "dt_send_eng.h"
+#include "server_class.h"
+
+// memdbgon must be the last include file in a .cpp file!!!
+#include "tier0/memdbgon.h"
+
+
+// -------------------------------------------------------------------------------------------------- //
+// PackedEntity.
+// -------------------------------------------------------------------------------------------------- //
+
+PackedEntity::PackedEntity()
+{
+ m_pData = NULL;
+ m_pChangeFrameList = NULL;
+ m_nSnapshotCreationTick = 0;
+ m_nShouldCheckCreationTick = 0;
+}
+
+PackedEntity::~PackedEntity()
+{
+ FreeData();
+
+ if ( m_pChangeFrameList )
+ {
+ m_pChangeFrameList->Release();
+ m_pChangeFrameList = NULL;
+ }
+}
+
+
+bool PackedEntity::AllocAndCopyPadded( const void *pData, unsigned long size )
+{
+ FreeData();
+
+ unsigned long nBytes = PAD_NUMBER( size, 4 );
+
+ // allocate the memory
+ m_pData = malloc( nBytes );
+
+ if ( !m_pData )
+ {
+ Assert( m_pData );
+ return false;
+ }
+
+ Q_memcpy( m_pData, pData, size );
+ SetNumBits( nBytes * 8 );
+
+ return true;
+}
+
+
+int PackedEntity::GetPropsChangedAfterTick( int iTick, int *iOutProps, int nMaxOutProps )
+{
+ if ( m_pChangeFrameList )
+ {
+ return m_pChangeFrameList->GetPropsChangedAfterTick( iTick, iOutProps, nMaxOutProps );
+ }
+ else
+ {
+ // signal that we don't have a changelist
+ return -1;
+ }
+}
+
+
+const CSendProxyRecipients* PackedEntity::GetRecipients() const
+{
+ return m_Recipients.Base();
+}
+
+
+int PackedEntity::GetNumRecipients() const
+{
+ return m_Recipients.Count();
+}
+
+
+void PackedEntity::SetRecipients( const CUtlMemory<CSendProxyRecipients> &recipients )
+{
+ m_Recipients.CopyArray( recipients.Base(), recipients.Count() );
+}
+
+
+bool PackedEntity::CompareRecipients( const CUtlMemory<CSendProxyRecipients> &recipients )
+{
+ if ( recipients.Count() != m_Recipients.Count() )
+ return false;
+
+ return memcmp( recipients.Base(), m_Recipients.Base(), sizeof( CSendProxyRecipients ) * m_Recipients.Count() ) == 0;
+}
+
+void PackedEntity::SetServerAndClientClass( ServerClass *pServerClass, ClientClass *pClientClass )
+{
+ m_pServerClass = pServerClass;
+ m_pClientClass = pClientClass;
+ if ( pServerClass )
+ {
+ Assert( pServerClass->m_pTable );
+ SetShouldCheckCreationTick( pServerClass->m_pTable->HasPropsEncodedAgainstTickCount() );
+ }
+} \ No newline at end of file