diff options
| author | JustSomePwner <crotchyalt@gmail.com> | 2018-08-30 14:01:54 +0200 |
|---|---|---|
| committer | JustSomePwner <crotchyalt@gmail.com> | 2018-08-30 14:01:54 +0200 |
| commit | 7ccb819f867493f8ec202ea3b39c94c198c64584 (patch) | |
| tree | 94622e61af0ff359e3d6689cf274d74f60b2492a /tf2/netvars.h | |
| parent | 564d979b79e8a5aaa5014eba0ecd36c61575934f (diff) | |
first
Diffstat (limited to 'tf2/netvars.h')
| -rw-r--r-- | tf2/netvars.h | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/tf2/netvars.h b/tf2/netvars.h new file mode 100644 index 0000000..54b92be --- /dev/null +++ b/tf2/netvars.h @@ -0,0 +1,44 @@ +#pragma once
+#include <vector>
+
+#include "dt_recv.h"
+#include "util.hpp"
+#include "fnv.hpp"
+
+class RecvTable;
+
+#define NETVAR( funcname, name, table, extra, type ) \
+__forceinline auto& funcname( ) { \
+ static std::ptrdiff_t offset = g_netvars.get_netvar( fnv( table ), fnv( name ) ); \
+ return get< type >( offset + extra ); \
+}
+
+#define PNETVAR( funcname, name, table, extra, type ) \
+__forceinline type* funcname( ) { \
+ static std::ptrdiff_t offset = g_netvars.get_netvar( fnv( table ), fnv( name ) ); \
+ return reinterpret_cast< type* >( uintptr_t( this ) + offset + extra ); \
+}
+
+#define OFFSET( funcname, offset, type ) \
+__forceinline auto& funcname( ) { \
+ return get< type >( offset ); \
+}
+
+NAMESPACE_REGION( tf2 )
+
+class c_netvars {
+public:
+ void init( );
+ //search through the netvar list
+ 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;
+};
+
+END_REGION
+
+extern tf2::c_netvars g_netvars;
\ No newline at end of file |
