From ad18945ef3663aa43053d95ce77be073ea9a5bc5 Mon Sep 17 00:00:00 2001 From: komashchenko Date: Thu, 31 Jul 2025 23:22:32 +0300 Subject: [PATCH 1/3] Update `CEntityInstance`, support updated `NetworkStateChanged` --- public/entity2/entityinstance.h | 96 ++++++++++++++++++++++++--------- 1 file changed, 71 insertions(+), 25 deletions(-) diff --git a/public/entity2/entityinstance.h b/public/entity2/entityinstance.h index 61e282aad..c58177897 100644 --- a/public/entity2/entityinstance.h +++ b/public/entity2/entityinstance.h @@ -18,6 +18,53 @@ struct CEntityPrecacheContext; struct ChangeAccessorFieldPathIndexInfo_t; struct datamap_t; + +struct NetworkStateChangedData +{ + inline NetworkStateChangedData() : m_Unk00(1), m_Unk48(-1), m_nArrayIndex(-1), m_nPathIndex(ChangeAccessorFieldPathIndex_t()), m_Unk60(0) { } + inline explicit NetworkStateChangedData( bool bFullChanged ) : m_Unk00(static_cast(!bFullChanged)), m_Unk48(-1), m_nArrayIndex(-1), m_nPathIndex(ChangeAccessorFieldPathIndex_t()), m_Unk60(0) { } + + // nLocalOffset is the flattened field offset + // calculated taking into account embedded structures + // if PathIndex is specified, then the offset must start from the last object in the chain + // nArrayIndex is the index of the array element + // if the field is a CNetworkUtlVectorBase, otherwise pass -1 + // nPathIndex is the value to specify + // if the path to the field goes through one or more pointers, otherwise pass -1 + // this value is usually a member of the CNetworkVarChainer and belongs to the last object in the chain + inline NetworkStateChangedData( uint32 nLocalOffset, int32 nArrayIndex = -1, ChangeAccessorFieldPathIndex_t nPathIndex = ChangeAccessorFieldPathIndex_t() ) : m_Unk00(1), m_LocalOffsets(0, 1), m_Unk48(-1), m_nArrayIndex(nArrayIndex), m_nPathIndex(nPathIndex), m_Unk60(0) + { + m_LocalOffsets.AddToHead(nLocalOffset); + } + + inline NetworkStateChangedData(const std::initializer_list< uint32 > nLocalOffsets, int32 nArrayIndex = -1, ChangeAccessorFieldPathIndex_t nPathIndex = ChangeAccessorFieldPathIndex_t()) : m_Unk00(1), m_LocalOffsets(0, nLocalOffsets.size()), m_Unk48(-1), m_nArrayIndex(nArrayIndex), m_nPathIndex(nPathIndex), m_Unk60(1) + { + for ( const uint32& nLocalOffset : nLocalOffsets ) + { + m_LocalOffsets.AddToTail( nLocalOffset ); + } + } + + uint32 m_Unk00; // Perhaps it is an enum, default 1, when 0 adds FL_FULL_EDICT_CHANGED + CUtlVector m_LocalOffsets; + // Probably only works in the debug build, as it has always been empty + CUtlString m_ClassName; + CUtlString m_FieldName; + int32 m_Unk48; // default -1 + int32 m_nArrayIndex; // default -1 + ChangeAccessorFieldPathIndex_t m_nPathIndex; // default -1 (can also be -2) + int16 m_Unk60; // default 0, if m_LocalOffsets has multiple values, it is set to 1 +}; +COMPILE_TIME_ASSERT(sizeof(NetworkStateChangedData) == 64); + +// Not entirely sure +struct NetworkStateChanged3Data +{ + CUtlVector m_Unk0; + CUtlVector m_Unk24; +}; + + class CEntityInstance { public: @@ -30,6 +77,9 @@ class CEntityInstance virtual void Precache( const CEntityPrecacheContext* pContext ) = 0; virtual void AddedToEntityDatabase() = 0; virtual void Spawn( const CEntityKeyValues* pKeyValues ) = 0; + + virtual void unk001() = 0; + virtual void PostDataUpdate( /*DataUpdateType_t*/int updateType ) = 0; virtual void OnDataUnchangedInPVS() = 0; virtual void Activate( /*ActivateType_t*/int activateType ) = 0; @@ -37,7 +87,7 @@ class CEntityInstance virtual void OnSetDormant( /*EntityDormancyType_t*/int prevDormancyType, /*EntityDormancyType_t*/int newDormancyType ) = 0; virtual void* ScriptEntityIO() = 0; - virtual int ScriptAcceptInput( const CUtlSymbolLarge &sInputName, CEntityInstance* pActivator, CEntityInstance* pCaller, const variant_t &value, int nOutputID ) = 0; + virtual int ScriptAcceptInput( const CUtlSymbolLarge &sInputName, CEntityInstance* pActivator, CEntityInstance* pCaller, const variant_t &value, int nOutputID, void* pUnk1, void* pUnk2 ) = 0; virtual void PreDataUpdate( /*DataUpdateType_t*/int updateType ) = 0; @@ -49,37 +99,35 @@ class CEntityInstance virtual void OnSave() = 0; virtual void OnRestore() = 0; - virtual void unk001() = 0; + virtual void unk101() = 0; + virtual int ObjectCaps() = 0; virtual CEntityIndex RequiredEdictIndex() = 0; - - // marks an entire entity for transmission over the network - virtual void NetworkStateChanged() = 0; - + // marks a field for transmission over the network - // nOffset is the flattened field offset - // calculated taking into account embedded structures - // if PathIndex is specified, then the offset must start from the last object in the chain - // nItem is the index of the array element - // if the field is a CNetworkUtlVectorBase, otherwise pass -1 - // PathIndex is the value to specify - // if the path to the field goes through one or more pointers, otherwise pass -1 - // this value is usually a member of the CNetworkVarChainer and belongs to the last object in the chain - virtual void NetworkStateChanged( uint nOffset, int nItem = -1, ChangeAccessorFieldPathIndex_t PathIndex = ChangeAccessorFieldPathIndex_t() ) = 0; - - virtual void LogFieldInfo( const char* pszFieldName, const char* pszInfo ) = 0; + virtual void NetworkStateChanged( const NetworkStateChangedData& data ) = 0; // Function replaces old version NetworkStateChanged( uint nOffset, int, ChangeAccessorFieldPathIndex_t PathIndex ) + virtual void NetworkStateChangedBranch( const void* data ) = 0; // Game never call this function during testing + virtual void NetworkStateChanged_3( const NetworkStateChanged3Data& data ) = 0; + virtual void NetworkStateUnkSetBool( bool bUnk ) = 0; // Affects behavior of NetworkStateChanged + virtual void NetworkStateChangedLog( const char* pszFieldName, const char* pszInfo ) = 0; virtual bool FullEdictChanged() = 0; - virtual void unk101() = 0; - virtual void unk102() = 0; + + virtual void unk201() = 0; + virtual void unk202() = 0; + virtual ChangeAccessorFieldPathIndex_t AddChangeAccessorPath( const CFieldPath& path ) = 0; virtual void AssignChangeAccessorPathIds() = 0; virtual ChangeAccessorFieldPathIndexInfo_t* GetChangeAccessorPathInfo_1() = 0; virtual ChangeAccessorFieldPathIndexInfo_t* GetChangeAccessorPathInfo_2() = 0; - virtual void unk201() = 0; + virtual void unk301() = 0; + virtual void unk302() = 0; + virtual void ReloadPrivateScripts() = 0; virtual datamap_t* GetDataDescMap() = 0; - virtual void unk301() = 0; + + virtual void unk401() = 0; + virtual SchemaMetaInfoHandle_t Schema_DynamicBinding() = 0; public: @@ -105,10 +153,8 @@ class CEntityInstance void* m_hPrivateScope; // 0x18 - CEntityPrivateScriptScope public: CEntityKeyValues* m_pKeyValues; // 0x20 -private: - uint8 pad[8]; -public: - CScriptComponent* m_CScriptComponent; // 0x30 + CScriptComponent* m_CScriptComponent; // 0x28 + bool m_bVisibleinPVS; // 0x30 }; // -------------------------------------------------------------------------------------------------- // From 99d635024b02853aee1f58faaf20adc1c9cc5ea2 Mon Sep 17 00:00:00 2001 From: komashchenko Date: Wed, 6 Aug 2025 18:57:56 +0300 Subject: [PATCH 2/3] Update `NetworkStateChangedData` --- public/entity2/entityinstance.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/public/entity2/entityinstance.h b/public/entity2/entityinstance.h index c58177897..43b1bac22 100644 --- a/public/entity2/entityinstance.h +++ b/public/entity2/entityinstance.h @@ -21,8 +21,8 @@ struct datamap_t; struct NetworkStateChangedData { - inline NetworkStateChangedData() : m_Unk00(1), m_Unk48(-1), m_nArrayIndex(-1), m_nPathIndex(ChangeAccessorFieldPathIndex_t()), m_Unk60(0) { } - inline explicit NetworkStateChangedData( bool bFullChanged ) : m_Unk00(static_cast(!bFullChanged)), m_Unk48(-1), m_nArrayIndex(-1), m_nPathIndex(ChangeAccessorFieldPathIndex_t()), m_Unk60(0) { } + inline NetworkStateChangedData() : m_Unk00(1), m_nLine(-1), m_nArrayIndex(-1), m_nPathIndex(ChangeAccessorFieldPathIndex_t()), m_Unk60(0) { } + inline explicit NetworkStateChangedData( bool bFullChanged ) : m_Unk00(static_cast(!bFullChanged)), m_nLine(-1), m_nArrayIndex(-1), m_nPathIndex(ChangeAccessorFieldPathIndex_t()), m_Unk60(0) { } // nLocalOffset is the flattened field offset // calculated taking into account embedded structures @@ -32,12 +32,12 @@ struct NetworkStateChangedData // nPathIndex is the value to specify // if the path to the field goes through one or more pointers, otherwise pass -1 // this value is usually a member of the CNetworkVarChainer and belongs to the last object in the chain - inline NetworkStateChangedData( uint32 nLocalOffset, int32 nArrayIndex = -1, ChangeAccessorFieldPathIndex_t nPathIndex = ChangeAccessorFieldPathIndex_t() ) : m_Unk00(1), m_LocalOffsets(0, 1), m_Unk48(-1), m_nArrayIndex(nArrayIndex), m_nPathIndex(nPathIndex), m_Unk60(0) + inline NetworkStateChangedData( uint32 nLocalOffset, int32 nArrayIndex = -1, ChangeAccessorFieldPathIndex_t nPathIndex = ChangeAccessorFieldPathIndex_t() ) : m_Unk00(1), m_LocalOffsets(0, 1), m_nLine(-1), m_nArrayIndex(nArrayIndex), m_nPathIndex(nPathIndex), m_Unk60(0) { m_LocalOffsets.AddToHead(nLocalOffset); } - inline NetworkStateChangedData(const std::initializer_list< uint32 > nLocalOffsets, int32 nArrayIndex = -1, ChangeAccessorFieldPathIndex_t nPathIndex = ChangeAccessorFieldPathIndex_t()) : m_Unk00(1), m_LocalOffsets(0, nLocalOffsets.size()), m_Unk48(-1), m_nArrayIndex(nArrayIndex), m_nPathIndex(nPathIndex), m_Unk60(1) + inline NetworkStateChangedData(const std::initializer_list< uint32 > nLocalOffsets, int32 nArrayIndex = -1, ChangeAccessorFieldPathIndex_t nPathIndex = ChangeAccessorFieldPathIndex_t()) : m_Unk00(1), m_LocalOffsets(0, nLocalOffsets.size()), m_nLine(-1), m_nArrayIndex(nArrayIndex), m_nPathIndex(nPathIndex), m_Unk60(1) { for ( const uint32& nLocalOffset : nLocalOffsets ) { @@ -48,9 +48,9 @@ struct NetworkStateChangedData uint32 m_Unk00; // Perhaps it is an enum, default 1, when 0 adds FL_FULL_EDICT_CHANGED CUtlVector m_LocalOffsets; // Probably only works in the debug build, as it has always been empty - CUtlString m_ClassName; CUtlString m_FieldName; - int32 m_Unk48; // default -1 + CUtlString m_FileName; + int32 m_nLine; // default -1 int32 m_nArrayIndex; // default -1 ChangeAccessorFieldPathIndex_t m_nPathIndex; // default -1 (can also be -2) int16 m_Unk60; // default 0, if m_LocalOffsets has multiple values, it is set to 1 From 4f3cce2955b8bd29f0ae1170e16093370dff2f0a Mon Sep 17 00:00:00 2001 From: GAMMACASE <31375974+GAMMACASE@users.noreply.github.com> Date: Wed, 6 Aug 2025 21:38:10 +0300 Subject: [PATCH 3/3] Cosmetic changes --- public/entity2/entityinstance.h | 67 ++++++++++++++++++--------------- 1 file changed, 36 insertions(+), 31 deletions(-) diff --git a/public/entity2/entityinstance.h b/public/entity2/entityinstance.h index 43b1bac22..3d6a7b2ca 100644 --- a/public/entity2/entityinstance.h +++ b/public/entity2/entityinstance.h @@ -18,11 +18,14 @@ struct CEntityPrecacheContext; struct ChangeAccessorFieldPathIndexInfo_t; struct datamap_t; - struct NetworkStateChangedData { - inline NetworkStateChangedData() : m_Unk00(1), m_nLine(-1), m_nArrayIndex(-1), m_nPathIndex(ChangeAccessorFieldPathIndex_t()), m_Unk60(0) { } - inline explicit NetworkStateChangedData( bool bFullChanged ) : m_Unk00(static_cast(!bFullChanged)), m_nLine(-1), m_nArrayIndex(-1), m_nPathIndex(ChangeAccessorFieldPathIndex_t()), m_Unk60(0) { } + inline NetworkStateChangedData() : m_unk001(1), m_FieldOffset(-1), m_nArrayIndex(-1), m_nPathIndex(ChangeAccessorFieldPathIndex_t()), m_unk101(0) { } + inline explicit NetworkStateChangedData( bool bFullChanged ) : + m_unk001(static_cast(!bFullChanged)), m_FieldOffset(-1), + m_nArrayIndex(-1), m_nPathIndex(ChangeAccessorFieldPathIndex_t()), + m_unk101(0) + { } // nLocalOffset is the flattened field offset // calculated taking into account embedded structures @@ -32,12 +35,14 @@ struct NetworkStateChangedData // nPathIndex is the value to specify // if the path to the field goes through one or more pointers, otherwise pass -1 // this value is usually a member of the CNetworkVarChainer and belongs to the last object in the chain - inline NetworkStateChangedData( uint32 nLocalOffset, int32 nArrayIndex = -1, ChangeAccessorFieldPathIndex_t nPathIndex = ChangeAccessorFieldPathIndex_t() ) : m_Unk00(1), m_LocalOffsets(0, 1), m_nLine(-1), m_nArrayIndex(nArrayIndex), m_nPathIndex(nPathIndex), m_Unk60(0) + inline NetworkStateChangedData( uint32 nLocalOffset, int32 nArrayIndex = -1, ChangeAccessorFieldPathIndex_t nPathIndex = ChangeAccessorFieldPathIndex_t() ) : + m_unk001(1), m_LocalOffsets(0, 1), m_FieldOffset(-1), m_nArrayIndex(nArrayIndex), m_nPathIndex(nPathIndex), m_unk101(0) { m_LocalOffsets.AddToHead(nLocalOffset); } - inline NetworkStateChangedData(const std::initializer_list< uint32 > nLocalOffsets, int32 nArrayIndex = -1, ChangeAccessorFieldPathIndex_t nPathIndex = ChangeAccessorFieldPathIndex_t()) : m_Unk00(1), m_LocalOffsets(0, nLocalOffsets.size()), m_nLine(-1), m_nArrayIndex(nArrayIndex), m_nPathIndex(nPathIndex), m_Unk60(1) + inline NetworkStateChangedData(const std::initializer_list< uint32 > nLocalOffsets, int32 nArrayIndex = -1, ChangeAccessorFieldPathIndex_t nPathIndex = ChangeAccessorFieldPathIndex_t()) : + m_unk001(1), m_LocalOffsets(0, nLocalOffsets.size()), m_FieldOffset(-1), m_nArrayIndex(nArrayIndex), m_nPathIndex(nPathIndex), m_unk101(1) { for ( const uint32& nLocalOffset : nLocalOffsets ) { @@ -45,26 +50,19 @@ struct NetworkStateChangedData } } - uint32 m_Unk00; // Perhaps it is an enum, default 1, when 0 adds FL_FULL_EDICT_CHANGED + uint32 m_unk001; // Perhaps it is an enum, default 1, when 0 adds FL_FULL_EDICT_CHANGED CUtlVector m_LocalOffsets; - // Probably only works in the debug build, as it has always been empty + + // AMNOTE: Mostly unused/debug + CUtlString m_ClassName; CUtlString m_FieldName; - CUtlString m_FileName; - int32 m_nLine; // default -1 - int32 m_nArrayIndex; // default -1 - ChangeAccessorFieldPathIndex_t m_nPathIndex; // default -1 (can also be -2) - int16 m_Unk60; // default 0, if m_LocalOffsets has multiple values, it is set to 1 -}; -COMPILE_TIME_ASSERT(sizeof(NetworkStateChangedData) == 64); + int32 m_FieldOffset; + int32 m_nArrayIndex; + ChangeAccessorFieldPathIndex_t m_nPathIndex; -// Not entirely sure -struct NetworkStateChanged3Data -{ - CUtlVector m_Unk0; - CUtlVector m_Unk24; + int16 m_unk101; // default 0, if m_LocalOffsets has multiple values, it is set to 1 }; - class CEntityInstance { public: @@ -105,28 +103,33 @@ class CEntityInstance virtual CEntityIndex RequiredEdictIndex() = 0; // marks a field for transmission over the network - virtual void NetworkStateChanged( const NetworkStateChangedData& data ) = 0; // Function replaces old version NetworkStateChanged( uint nOffset, int, ChangeAccessorFieldPathIndex_t PathIndex ) - virtual void NetworkStateChangedBranch( const void* data ) = 0; // Game never call this function during testing - virtual void NetworkStateChanged_3( const NetworkStateChanged3Data& data ) = 0; - virtual void NetworkStateUnkSetBool( bool bUnk ) = 0; // Affects behavior of NetworkStateChanged + virtual void NetworkStateChanged( const NetworkStateChangedData& data ) = 0; + + // AMNOTE: NetworkState related methods + virtual void unk201( const void* data ) = 0; + virtual void unk202( const void* data ) = 0; + + // Toggles network update state, if set to false would skip network updates + virtual void NetworkUpdateState( bool state ) = 0; virtual void NetworkStateChangedLog( const char* pszFieldName, const char* pszInfo ) = 0; + virtual bool FullEdictChanged() = 0; - virtual void unk201() = 0; - virtual void unk202() = 0; + virtual void unk301() = 0; + virtual void unk302() = 0; virtual ChangeAccessorFieldPathIndex_t AddChangeAccessorPath( const CFieldPath& path ) = 0; virtual void AssignChangeAccessorPathIds() = 0; virtual ChangeAccessorFieldPathIndexInfo_t* GetChangeAccessorPathInfo_1() = 0; virtual ChangeAccessorFieldPathIndexInfo_t* GetChangeAccessorPathInfo_2() = 0; - virtual void unk301() = 0; - virtual void unk302() = 0; + virtual void unk401() = 0; + virtual void unk402() = 0; virtual void ReloadPrivateScripts() = 0; virtual datamap_t* GetDataDescMap() = 0; - virtual void unk401() = 0; + virtual void unk501() = 0; virtual SchemaMetaInfoHandle_t Schema_DynamicBinding() = 0; @@ -153,8 +156,10 @@ class CEntityInstance void* m_hPrivateScope; // 0x18 - CEntityPrivateScriptScope public: CEntityKeyValues* m_pKeyValues; // 0x20 - CScriptComponent* m_CScriptComponent; // 0x28 - bool m_bVisibleinPVS; // 0x30 +private: + uint8 pad[8]; +public: + CScriptComponent* m_CScriptComponent; // 0x30 }; // -------------------------------------------------------------------------------------------------- //