Skip to content

Commit 94366fc

Browse files
komashchenkoGAMMACASE
authored andcommitted
Update CEntityInstance (#317)
1 parent c97deff commit 94366fc

File tree

1 file changed

+72
-21
lines changed

1 file changed

+72
-21
lines changed

public/entity2/entityinstance.h

Lines changed: 72 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,51 @@ struct CEntityPrecacheContext;
1818
struct ChangeAccessorFieldPathIndexInfo_t;
1919
struct datamap_t;
2020

21+
struct NetworkStateChangedData
22+
{
23+
inline NetworkStateChangedData() : m_unk001(1), m_FieldOffset(-1), m_nArrayIndex(-1), m_nPathIndex(ChangeAccessorFieldPathIndex_t()), m_unk101(0) { }
24+
inline explicit NetworkStateChangedData( bool bFullChanged ) :
25+
m_unk001(static_cast<uint32>(!bFullChanged)), m_FieldOffset(-1),
26+
m_nArrayIndex(-1), m_nPathIndex(ChangeAccessorFieldPathIndex_t()),
27+
m_unk101(0)
28+
{ }
29+
30+
// nLocalOffset is the flattened field offset
31+
// calculated taking into account embedded structures
32+
// if PathIndex is specified, then the offset must start from the last object in the chain
33+
// nArrayIndex is the index of the array element
34+
// if the field is a CNetworkUtlVectorBase, otherwise pass -1
35+
// nPathIndex is the value to specify
36+
// if the path to the field goes through one or more pointers, otherwise pass -1
37+
// this value is usually a member of the CNetworkVarChainer and belongs to the last object in the chain
38+
inline NetworkStateChangedData( uint32 nLocalOffset, int32 nArrayIndex = -1, ChangeAccessorFieldPathIndex_t nPathIndex = ChangeAccessorFieldPathIndex_t() ) :
39+
m_unk001(1), m_LocalOffsets(0, 1), m_FieldOffset(-1), m_nArrayIndex(nArrayIndex), m_nPathIndex(nPathIndex), m_unk101(0)
40+
{
41+
m_LocalOffsets.AddToHead(nLocalOffset);
42+
}
43+
44+
inline NetworkStateChangedData(const std::initializer_list< uint32 > nLocalOffsets, int32 nArrayIndex = -1, ChangeAccessorFieldPathIndex_t nPathIndex = ChangeAccessorFieldPathIndex_t()) :
45+
m_unk001(1), m_LocalOffsets(0, nLocalOffsets.size()), m_FieldOffset(-1), m_nArrayIndex(nArrayIndex), m_nPathIndex(nPathIndex), m_unk101(1)
46+
{
47+
for ( const uint32& nLocalOffset : nLocalOffsets )
48+
{
49+
m_LocalOffsets.AddToTail( nLocalOffset );
50+
}
51+
}
52+
53+
uint32 m_unk001; // Perhaps it is an enum, default 1, when 0 adds FL_FULL_EDICT_CHANGED
54+
CUtlVector<uint32> m_LocalOffsets;
55+
56+
// AMNOTE: Mostly unused/debug
57+
CUtlString m_ClassName;
58+
CUtlString m_FieldName;
59+
int32 m_FieldOffset;
60+
int32 m_nArrayIndex;
61+
ChangeAccessorFieldPathIndex_t m_nPathIndex;
62+
63+
int16 m_unk101; // default 0, if m_LocalOffsets has multiple values, it is set to 1
64+
};
65+
2166
class CEntityInstance
2267
{
2368
public:
@@ -30,14 +75,17 @@ class CEntityInstance
3075
virtual void Precache( const CEntityPrecacheContext* pContext ) = 0;
3176
virtual void AddedToEntityDatabase() = 0;
3277
virtual void Spawn( const CEntityKeyValues* pKeyValues ) = 0;
78+
79+
virtual void unk001() = 0;
80+
3381
virtual void PostDataUpdate( /*DataUpdateType_t*/int updateType ) = 0;
3482
virtual void OnDataUnchangedInPVS() = 0;
3583
virtual void Activate( /*ActivateType_t*/int activateType ) = 0;
3684
virtual void UpdateOnRemove() = 0;
3785
virtual void OnSetDormant( /*EntityDormancyType_t*/int prevDormancyType, /*EntityDormancyType_t*/int newDormancyType ) = 0;
3886

3987
virtual void* ScriptEntityIO() = 0;
40-
virtual int ScriptAcceptInput( const CUtlSymbolLarge &sInputName, CEntityInstance* pActivator, CEntityInstance* pCaller, const variant_t &value, int nOutputID ) = 0;
88+
virtual int ScriptAcceptInput( const CUtlSymbolLarge &sInputName, CEntityInstance* pActivator, CEntityInstance* pCaller, const variant_t &value, int nOutputID, void* pUnk1, void* pUnk2 ) = 0;
4189

4290
virtual void PreDataUpdate( /*DataUpdateType_t*/int updateType ) = 0;
4391

@@ -49,37 +97,40 @@ class CEntityInstance
4997
virtual void OnSave() = 0;
5098
virtual void OnRestore() = 0;
5199

52-
virtual void unk001() = 0;
100+
virtual void unk101() = 0;
101+
53102
virtual int ObjectCaps() = 0;
54103
virtual CEntityIndex RequiredEdictIndex() = 0;
55-
56-
// marks an entire entity for transmission over the network
57-
virtual void NetworkStateChanged() = 0;
58-
104+
59105
// marks a field for transmission over the network
60-
// nOffset is the flattened field offset
61-
// calculated taking into account embedded structures
62-
// if PathIndex is specified, then the offset must start from the last object in the chain
63-
// nItem is the index of the array element
64-
// if the field is a CNetworkUtlVectorBase, otherwise pass -1
65-
// PathIndex is the value to specify
66-
// if the path to the field goes through one or more pointers, otherwise pass -1
67-
// this value is usually a member of the CNetworkVarChainer and belongs to the last object in the chain
68-
virtual void NetworkStateChanged( uint nOffset, int nItem = -1, ChangeAccessorFieldPathIndex_t PathIndex = ChangeAccessorFieldPathIndex_t() ) = 0;
69-
70-
virtual void LogFieldInfo( const char* pszFieldName, const char* pszInfo ) = 0;
106+
virtual void NetworkStateChanged( const NetworkStateChangedData& data ) = 0;
107+
108+
// AMNOTE: NetworkState related methods
109+
virtual void unk201( const void* data ) = 0;
110+
virtual void unk202( const void* data ) = 0;
111+
112+
// Toggles network update state, if set to false would skip network updates
113+
virtual void NetworkUpdateState( bool state ) = 0;
114+
virtual void NetworkStateChangedLog( const char* pszFieldName, const char* pszInfo ) = 0;
115+
71116
virtual bool FullEdictChanged() = 0;
72-
virtual void unk101() = 0;
73-
virtual void unk102() = 0;
117+
118+
virtual void unk301() = 0;
119+
virtual void unk302() = 0;
120+
74121
virtual ChangeAccessorFieldPathIndex_t AddChangeAccessorPath( const CFieldPath& path ) = 0;
75122
virtual void AssignChangeAccessorPathIds() = 0;
76123
virtual ChangeAccessorFieldPathIndexInfo_t* GetChangeAccessorPathInfo_1() = 0;
77124
virtual ChangeAccessorFieldPathIndexInfo_t* GetChangeAccessorPathInfo_2() = 0;
78125

79-
virtual void unk201() = 0;
126+
virtual void unk401() = 0;
127+
virtual void unk402() = 0;
128+
80129
virtual void ReloadPrivateScripts() = 0;
81130
virtual datamap_t* GetDataDescMap() = 0;
82-
virtual void unk301() = 0;
131+
132+
virtual void unk501() = 0;
133+
83134
virtual SchemaMetaInfoHandle_t<CSchemaClassInfo> Schema_DynamicBinding() = 0;
84135

85136
public:

0 commit comments

Comments
 (0)