forked from cutie-coders/1337
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnetvar_manager.cpp
More file actions
121 lines (94 loc) · 2.34 KB
/
Copy pathnetvar_manager.cpp
File metadata and controls
121 lines (94 loc) · 2.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
#include "netvar_manager.h"
#include "interfaces.h"
void CNetVarManager::Initialize()
{
m_tables.clear();
ClientClass* clientClass = interfaces.client->GetAllClasses();
if (!clientClass)
return;
while (clientClass)
{
RecvTable* recvTable = clientClass->m_pRecvTable;
m_tables.push_back(recvTable);
clientClass = clientClass->m_pNext;
}
}
int CNetVarManager::GetOffset(const char* tableName, const char* propName)
{
int offset = Get_Prop(tableName, propName);
if (!offset)
{
return 0;
}
return offset;
}
bool CNetVarManager::HookProp(const char* tableName, const char* propName, RecvVarProxyFn fun)
{
RecvProp* recvProp = 0;
Get_Prop(tableName, propName, &recvProp);
if (!recvProp)
return false;
recvProp->m_ProxyFn = fun;
return true;
}
int CNetVarManager::Get_Prop(const char* tableName, const char* propName, RecvProp** prop)
{
RecvTable* recvTable = GetTable(tableName);
if (!recvTable)
return 0;
int offset = Get_Prop(recvTable, propName, prop);
if (!offset)
return 0;
return offset;
}
int CNetVarManager::Get_Prop(RecvTable* recvTable, const char* propName, RecvProp** prop)
{
int extraOffset = 0;
for (int i = 0; i < recvTable->m_nProps; ++i)
{
RecvProp* recvProp = &recvTable->m_pProps[i];
RecvTable* child = recvProp->m_pDataTable;
if (child && (child->m_nProps > 0))
{
int tmp = Get_Prop(child, propName, prop);
if (tmp)
extraOffset += (recvProp->m_Offset + tmp);
}
if (_stricmp(recvProp->m_pVarName, propName))
continue;
if (prop)
*prop = recvProp;
return (recvProp->m_Offset + extraOffset);
}
return extraOffset;
}
RecvTable* CNetVarManager::GetTable(const char* tableName)
{
if (m_tables.empty())
return 0;
for(RecvTable* table : m_tables)
{
if (!table)
continue;
if (_stricmp(table->m_pNetTableName, tableName) == 0)
return table;
}
return 0;
}
void CNetVarManager::DumpTable(RecvTable* table, int depth)
{
std::string pre(str(""));
for (int i = 0; i < depth; i++)
pre.append(str("\t"));
for (int i = 0; i < table->m_nProps; i++)
{
RecvProp* prop = &table->m_pProps[i];
if (!prop)
continue;
std::string varName(prop->m_pVarName);
if (varName.find(str("baseclass")) == 0 || varName.find(str("0")) == 0 || varName.find(str("1")) == 0 || varName.find(str("2")) == 0)
continue;
if (prop->m_pDataTable)
DumpTable(prop->m_pDataTable, depth + 1);
}
}