|
1 | | -/** |
| 1 | +/** |
2 | 2 | * ============================================================================= |
3 | 3 | * CS2Fixes |
4 | 4 | * Copyright (C) 2023-2025 Source2ZE |
|
37 | 37 | #include "virtual.h" |
38 | 38 | #undef schema |
39 | 39 |
|
| 40 | +class CBaseEntity; |
| 41 | + |
40 | 42 | struct SchemaKey |
41 | 43 | { |
42 | 44 | int32 offset; |
43 | 45 | bool networked; |
44 | 46 | }; |
45 | 47 |
|
46 | | -void EntityNetworkStateChanged(uintptr_t entityInstance, uint nOffset); |
47 | | -void ChainNetworkStateChanged(uintptr_t networkVarChainer, uint nLocalOffset); |
| 48 | +struct CNetworkStateChangedInfo |
| 49 | +{ |
| 50 | + CNetworkStateChangedInfo() = delete; |
| 51 | + |
| 52 | + CNetworkStateChangedInfo(uint32_t nOffset, uint32_t nArrayIndex, uint32_t nPathIndex) |
| 53 | + { |
| 54 | + m_vecOffsetData.EnsureCount(1); |
| 55 | + m_vecOffsetData[0] = nOffset; |
| 56 | + |
| 57 | + unk_30 = -1; |
| 58 | + |
| 59 | + unk_3c = 0; |
| 60 | + |
| 61 | + m_nArrayIndex = nArrayIndex; |
| 62 | + m_nPathIndex = nPathIndex; |
| 63 | + } |
| 64 | + |
| 65 | +private: |
| 66 | + int m_nSize; // 0x0 |
| 67 | + CUtlVector<uint32_t> m_vecOffsetData; // 0x8 |
| 68 | + char* m_pszFieldName{}; // 0x20 |
| 69 | + char* m_pszFileName{}; // 0x28 |
| 70 | + uint32_t unk_30 = -1; // 0x30 |
| 71 | + uint32_t m_nArrayIndex{}; // 0x34 |
| 72 | + uint32_t m_nPathIndex{}; // 0x38 |
| 73 | + uint16_t unk_3c{}; // 0x3c |
| 74 | +}; // Size: 0x3e |
| 75 | + |
| 76 | +void NetworkStateChanged(uintptr_t chainEntity, uint32_t offset, uint32_t nArrayIndex = -1, uint32_t nPathIndex = -1); |
| 77 | +void SetStateChanged(uintptr_t pEntity, uint32_t offset, uint32_t nArrayIndex = -1, uint32_t nPathIndex = -1); |
48 | 78 |
|
49 | 79 | constexpr uint32_t val_32_const = 0x811c9dc5; |
50 | 80 | constexpr uint32_t prime_32_const = 0x1000193; |
@@ -96,16 +126,17 @@ inline constexpr uint64_t hash_64_fnv1a_const(const char* const str, const uint6 |
96 | 126 | if (m_chain != 0 && m_key.networked) \ |
97 | 127 | { \ |
98 | 128 | DevMsg("Found chain offset %d for %s::%s\n", m_chain, ThisClassName, #varName); \ |
99 | | - ChainNetworkStateChanged((uintptr_t)(pThisClass) + m_chain, m_key.offset + extra_offset); \ |
| 129 | + ::NetworkStateChanged((uintptr_t)(pThisClass) + m_chain, m_key.offset + extra_offset); \ |
100 | 130 | } \ |
101 | 131 | else if (m_key.networked) \ |
102 | 132 | { \ |
103 | 133 | /* WIP: Works fine for most props, but inlined classes in the middle of a class will \ |
104 | 134 | need to have their this pointer corrected by the offset .*/ \ |
105 | 135 | if (!IsStruct) \ |
106 | | - EntityNetworkStateChanged((uintptr_t)pThisClass, m_key.offset + extra_offset); \ |
107 | | - else \ |
108 | | - CALL_VIRTUAL(void, 1, pThisClass, m_key.offset + extra_offset, 0xFFFFFFFF, 0xFFFFFFFF); \ |
| 136 | + ::SetStateChanged((uintptr_t)pThisClass, m_key.offset + extra_offset); \ |
| 137 | + /* Crash here if no VTable */ \ |
| 138 | + /*else \ |
| 139 | + CALL_VIRTUAL(void, 1, pThisClass, m_key.offset + extra_offset, 0xFFFFFFFF, 0xFFFFFFFF);*/ \ |
109 | 140 | } \ |
110 | 141 | *reinterpret_cast<std::add_pointer_t<type>>((uintptr_t)(pThisClass) + m_key.offset + extra_offset) = val; \ |
111 | 142 | } \ |
|
0 commit comments