Use NetVars class statically.

Signed-off-by: aixxe <me@aixxe.net>
This commit is contained in:
aixxe 2016-12-21 15:13:40 +00:00
parent 712963fc37
commit d53dbcabfd
3 changed files with 5 additions and 9 deletions

View File

@ -41,8 +41,6 @@ CGlobalVarsBase* globalvars = nullptr;
CRC32_ProcessBufferFn CRC32_ProcessBuffer = NULL;
NetVars netvars;
std::unique_ptr<VMTHook> sdl_hook;
std::unique_ptr<VMTHook> panel_hook;
std::unique_ptr<VMTHook> clientdll_hook;

View File

@ -9,6 +9,4 @@
#include "Utilities/Linker.h"
#include "Utilities/FindPattern.h"
#include "Utilities/Interfaces.h"
#include "Utilities/NetVars.h"
extern NetVars netvars;
#include "Utilities/NetVars.h"

View File

@ -2,7 +2,7 @@
class NetVars {
private:
inline uintptr_t FindOffset(RecvTable* recv_table, const char* property_name, RecvProp** property_ptr = nullptr) {
static uintptr_t FindOffset(RecvTable* recv_table, const char* property_name, RecvProp** property_ptr = nullptr) {
for (int i = 0; i < recv_table->m_nProps; i++) {
RecvProp& recv_prop = recv_table->m_pProps[i];
@ -17,7 +17,7 @@ class NetVars {
continue;
}
if (uintptr_t offset = this->FindOffset(recv_prop.m_pDataTable, property_name)) {
if (uintptr_t offset = FindOffset(recv_prop.m_pDataTable, property_name)) {
if (property_ptr)
*property_ptr = &recv_table->m_pProps[i];
@ -28,10 +28,10 @@ class NetVars {
return 0;
}
public:
uintptr_t GetOffset(const char* class_name, const char* property_name, RecvProp** property_ptr = nullptr) {
static uintptr_t GetOffset(const char* class_name, const char* property_name, RecvProp** property_ptr = nullptr) {
for (ClientClass* class_ptr = clientdll->GetAllClasses(); class_ptr; class_ptr = class_ptr->m_pNext) {
if (strcmp(class_ptr->m_pNetworkName, class_name) == 0) {
return this->FindOffset(class_ptr->m_pRecvTable, property_name, property_ptr);
return FindOffset(class_ptr->m_pRecvTable, property_name, property_ptr);
}
}