From 65803b44c1e182914bb0b53d142cf1e31ff88d21 Mon Sep 17 00:00:00 2001 From: komashchenko Date: Wed, 6 Aug 2025 21:40:42 +0300 Subject: [PATCH] Update CEntityInstance (#317) --- public/entity2/entityinstance.h | 93 +++++++++++++++++++++++++-------- 1 file changed, 72 insertions(+), 21 deletions(-) diff --git a/public/entity2/entityinstance.h b/public/entity2/entityinstance.h index 61e282aa..3d6a7b2c 100644 --- a/public/entity2/entityinstance.h +++ b/public/entity2/entityinstance.h @@ -18,6 +18,51 @@ struct CEntityPrecacheContext; struct ChangeAccessorFieldPathIndexInfo_t; struct datamap_t; +struct NetworkStateChangedData +{ + 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 + // 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_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_unk001(1), m_LocalOffsets(0, nLocalOffsets.size()), m_FieldOffset(-1), m_nArrayIndex(nArrayIndex), m_nPathIndex(nPathIndex), m_unk101(1) + { + for ( const uint32& nLocalOffset : nLocalOffsets ) + { + m_LocalOffsets.AddToTail( nLocalOffset ); + } + } + + uint32 m_unk001; // Perhaps it is an enum, default 1, when 0 adds FL_FULL_EDICT_CHANGED + CUtlVector m_LocalOffsets; + + // AMNOTE: Mostly unused/debug + CUtlString m_ClassName; + CUtlString m_FieldName; + int32 m_FieldOffset; + int32 m_nArrayIndex; + ChangeAccessorFieldPathIndex_t m_nPathIndex; + + int16 m_unk101; // default 0, if m_LocalOffsets has multiple values, it is set to 1 +}; + class CEntityInstance { public: @@ -30,6 +75,9 @@ public: 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 +85,7 @@ public: 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 +97,40 @@ public: 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; + + // 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 unk101() = 0; - virtual void unk102() = 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 unk201() = 0; + virtual void unk401() = 0; + virtual void unk402() = 0; + virtual void ReloadPrivateScripts() = 0; virtual datamap_t* GetDataDescMap() = 0; - virtual void unk301() = 0; + + virtual void unk501() = 0; + virtual SchemaMetaInfoHandle_t Schema_DynamicBinding() = 0; public: