forked from Panguins/OneTap
-
Notifications
You must be signed in to change notification settings - Fork 0
/
netvars.h
46 lines (40 loc) · 1.32 KB
/
netvars.h
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
#pragma once
#include "sdk.h"
#include "fnv.h"
#include <vector>
#define NETVAR( funcname, type, table, name ) \
__forceinline auto& funcname( ) { \
static std::ptrdiff_t offset = g_netvars.get_netvar( fnv( table ), fnv( name ) ); \
if ( !offset ) \
{ \
offset = g_netvars.get_netvar( fnv( table ), fnv( name ) ); \
} \
return *reinterpret_cast< type* >( uintptr_t( this ) + offset ); \
}
#define PNETVAR( funcname, type, table, name ) \
__forceinline auto* funcname( ) { \
static std::ptrdiff_t offset = g_netvars.get_netvar( fnv( table ), fnv( name ) ); \
if ( !offset ) \
{ \
offset = g_netvars.get_netvar( fnv( table ), fnv( name ) ); \
} \
return reinterpret_cast< type* >( uintptr_t( this ) + offset ); \
}
#define NETVAR_OFFSET( funcname, type, table, name, extra ) \
__forceinline auto& funcname( ) { \
static std::ptrdiff_t offset = g_netvars.get_netvar( fnv( table ), fnv( name ) ); \
return *reinterpret_cast< type* >( uintptr_t( this ) + offset + extra ); \
}
class c_netvars
{
public:
void init( );
std::ptrdiff_t get_netvar( hash_t table, hash_t hash ) const;
RecvProp* get_prop( hash_t table, hash_t name ) const;
public:
std::ptrdiff_t get_entry( hash_t hash, RecvTable* table ) const;
RecvTable* get_table( hash_t hash ) const;
private:
std::vector< RecvTable* > m_tables;
};
extern c_netvars g_netvars;