#pragma once
namespace fw {
namespace sdk {
class c_netvars {
public:
c_netvars();
template <typename t> t get(std::uint32_t hash) {
return m_data.m_list[hash];
}
private:
struct {
std::unordered_map<std::uint32_t, std::int16_t> m_list;
} m_data;
};
inline std::unique_ptr<c_netvars> netvars;
} // namespace sdk
} // namespace fw
#define NETVAR(type, func, name) \
ALWAYS_INLINE type &func { \
static const auto offset = \
fw::sdk::netvars->get<std::uintptr_t>(FNV1A(name)); \
return *reinterpret_cast<type *>(reinterpret_cast<std::uintptr_t>(this) + \
offset); \
}
#define ANETVAR(type, size, func, name) \
ALWAYS_INLINE type &func { \
static const auto offset = \
fw::sdk::netvars->get<std::uintptr_t>(FNV1A(name)); \
return *reinterpret_cast<std::array<type, size> *>( \
reinterpret_cast<std::uintptr_t>(this) + offset); \
}
#define PNETVAR(type, func, name) \
ALWAYS_INLINE type &func { \
static const auto offset = \
fw::sdk::netvars->get<std::uintptr_t>(FNV1A(name)); \
return reinterpret_cast<type *>(reinterpret_cast<std::uintptr_t>(this) + \
offset); \
}
#define NETVAR_OFFSET(type, func, name, add) \
ALWAYS_INLINE type &func { \
static const auto offset = \
fw::sdk::netvars->get<std::uintptr_t>(FNV1A(name)); \
return *reinterpret_cast<type *>(reinterpret_cast<std::uintptr_t>(this) + \
offset + add); \
}
#define ANETVAR_OFFSET(type, size, func, name, add) \
ALWAYS_INLINE type &func { \
static const auto offset = \
fw::sdk::netvars->get<std::uintptr_t>(FNV1A(name)); \
return *reinterpret_cast<std::array<type, size> *>( \
reinterpret_cast<std::uintptr_t>(this) + offset + add); \
}
#define PNETVAR_OFFSET(type, func, name, add) \
ALWAYS_INLINE type &func { \
static const auto offset = \
fw::sdk::netvars->get<std::uintptr_t>(FNV1A(name)); \
return reinterpret_cast<type *>(reinterpret_cast<std::uintptr_t>(this) + \
offset + add); \
}
#define OFFSET(type, func, offset) \
ALWAYS_INLINE type &func { \
return *reinterpret_cast<type *>(reinterpret_cast<std::uintptr_t>(this) + \
offset); \
}
#define POFFSET(type, func, offset) \
ALWAYS_INLINE type &func { \
return reinterpret_cast<type *>(reinterpret_cast<std::uintptr_t>(this) + \
offset); \
}
#define PPOFFSET(type, func, offset) \
ALWAYS_INLINE type &func { \
return **reinterpret_cast<type **>( \
reinterpret_cast<std::uintptr_t>(this) + offset); \
}
#define MPOFFSET(type, func, offset, modifier) \
ALWAYS_INLINE type &func { \
return **reinterpret_cast<type **>( \
reinterpret_cast<std::uintptr_t>(this) + offset * modifier); \
}