11/* *
22 * =============================================================================
33 * CS2Fixes
4- * Copyright (C) 2023 Source2ZE
4+ * Copyright (C) 2023-2024 Source2ZE
55 * =============================================================================
66 *
77 * This program is free software; you can redistribute it and/or modify it under
2020#include " schema.h"
2121
2222#include " ../common.h"
23- #include " cschemasystem .h"
23+ #include " schemasystem/schemasystem .h"
2424#include " tier1/utlmap.h"
2525#include " tier0/memdbgon.h"
2626#include " plat.h"
2727#include " entity/cbaseentity.h"
2828
29- extern CSchemaSystem *g_pSchemaSystem2;
3029extern CGlobalVars *gpGlobals;
3130
3231using SchemaKeyValueMap_t = CUtlMap<uint32_t , SchemaKey>;
@@ -35,10 +34,10 @@ using SchemaTableMap_t = CUtlMap<uint32_t, SchemaKeyValueMap_t*>;
3534
3635static bool IsFieldNetworked (SchemaClassFieldData_t& field)
3736{
38- for (int i = 0 ; i < field.m_metadata_size ; i++)
37+ for (int i = 0 ; i < field.m_nStaticMetadataCount ; i++)
3938 {
4039 static auto networkEnabled = hash_32_fnv1a_const (" MNetworkEnable" );
41- if (networkEnabled == hash_32_fnv1a_const (field.m_metadata [i].m_name ))
40+ if (networkEnabled == hash_32_fnv1a_const (field.m_pStaticMetadata [i].m_pszName ))
4241 return true ;
4342 }
4443
@@ -47,12 +46,12 @@ static bool IsFieldNetworked(SchemaClassFieldData_t& field)
4746
4847static bool InitSchemaFieldsForClass (SchemaTableMap_t *tableMap, const char * className, uint32_t classKey)
4948{
50- CSchemaSystemTypeScope* pType = g_pSchemaSystem2 ->FindTypeScopeForModule (MODULE_PREFIX " server" MODULE_EXT);
49+ CSchemaSystemTypeScope* pType = g_pSchemaSystem ->FindTypeScopeForModule (MODULE_PREFIX " server" MODULE_EXT);
5150
5251 if (!pType)
5352 return false ;
5453
55- SchemaClassInfoData_t *pClassInfo = pType->FindDeclaredClass (className);
54+ SchemaClassInfoData_t *pClassInfo = pType->FindDeclaredClass (className). Get () ;
5655
5756 if (!pClassInfo)
5857 {
@@ -63,8 +62,8 @@ static bool InitSchemaFieldsForClass(SchemaTableMap_t *tableMap, const char* cla
6362 return false ;
6463 }
6564
66- short fieldsSize = pClassInfo->GetFieldsSize () ;
67- SchemaClassFieldData_t* pFields = pClassInfo->GetFields () ;
65+ short fieldsSize = pClassInfo->m_nFieldCount ;
66+ SchemaClassFieldData_t* pFields = pClassInfo->m_pFields ;
6867
6968 SchemaKeyValueMap_t *keyValueMap = new SchemaKeyValueMap_t (0 , 0 , DefLessFunc (uint32_t ));
7069 keyValueMap->EnsureCapacity (fieldsSize);
@@ -75,38 +74,38 @@ static bool InitSchemaFieldsForClass(SchemaTableMap_t *tableMap, const char* cla
7574 SchemaClassFieldData_t& field = pFields[i];
7675
7776#ifdef _DEBUG
78- Message (" %s::%s found at -> 0x%X - %llx\n " , className, field.m_name , field.m_single_inheritance_offset , &field);
77+ Message (" %s::%s found at -> 0x%X - %llx\n " , className, field.m_pszName , field.m_nSingleInheritanceOffset , &field);
7978#endif
8079
81- keyValueMap->Insert (hash_32_fnv1a_const (field.m_name ), {field.m_single_inheritance_offset , IsFieldNetworked (field)});
80+ keyValueMap->Insert (hash_32_fnv1a_const (field.m_pszName ), {field.m_nSingleInheritanceOffset , IsFieldNetworked (field)});
8281 }
8382
8483 return true ;
8584}
8685
8786int16_t schema::FindChainOffset (const char * className)
8887{
89- CSchemaSystemTypeScope* pType = g_pSchemaSystem2 ->FindTypeScopeForModule (MODULE_PREFIX " server" MODULE_EXT);
88+ CSchemaSystemTypeScope* pType = g_pSchemaSystem ->FindTypeScopeForModule (MODULE_PREFIX " server" MODULE_EXT);
9089
9190 if (!pType)
9291 return false ;
9392
94- SchemaClassInfoData_t* pClassInfo = pType->FindDeclaredClass (className);
93+ SchemaClassInfoData_t* pClassInfo = pType->FindDeclaredClass (className). Get () ;
9594
9695 do
9796 {
98- SchemaClassFieldData_t* pFields = pClassInfo->GetFields () ;
99- short fieldsSize = pClassInfo->GetFieldsSize () ;
97+ SchemaClassFieldData_t* pFields = pClassInfo->m_pFields ;
98+ short fieldsSize = pClassInfo->m_nFieldCount ;
10099 for (int i = 0 ; i < fieldsSize; ++i)
101100 {
102101 SchemaClassFieldData_t& field = pFields[i];
103102
104- if (V_strcmp (field.m_name , " __m_pChainEntity" ) == 0 )
103+ if (V_strcmp (field.m_pszName , " __m_pChainEntity" ) == 0 )
105104 {
106- return field.m_single_inheritance_offset ;
105+ return field.m_nSingleInheritanceOffset ;
107106 }
108107 }
109- } while ((pClassInfo = pClassInfo->GetParent () ) != nullptr );
108+ } while ((pClassInfo = pClassInfo->m_pBaseClasses ? pClassInfo-> m_pBaseClasses -> m_pClass : nullptr ) != nullptr );
110109
111110 return 0 ;
112111}
@@ -140,4 +139,4 @@ void SetStateChanged(Z_CBaseEntity* pEntity, int offset)
140139
141140 pEntity->m_lastNetworkChange = gpGlobals->curtime ;
142141 pEntity->m_isSteadyState ().ClearAll ();
143- };
142+ };
0 commit comments