From aa096fe6886681d3338573cd3af779b57a5b56ab Mon Sep 17 00:00:00 2001 From: salmonik Date: Sun, 30 Aug 2026 03:32:59 +0200 Subject: init --- src/hl2h.h | 133 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 133 insertions(+) create mode 100644 src/hl2h.h (limited to 'src/hl2h.h') diff --git a/src/hl2h.h b/src/hl2h.h new file mode 100644 index 0000000..6d3ebe7 --- /dev/null +++ b/src/hl2h.h @@ -0,0 +1,133 @@ +#ifndef HL2H_H +#define HL2H_H + +#include +#include +#include +#include +#include + +#include +#include +#include + +// --------------------------------------------------------------------------- +// logging +// --------------------------------------------------------------------------- + +void logf(const char *fmt, ...); + +// --------------------------------------------------------------------------- +// module discovery +// --------------------------------------------------------------------------- + +struct Module { + struct Range { + uintptr_t lo, hi; + bool file; + }; + std::vector ranges; + std::string path; + bool valid() const { return !ranges.empty(); } + bool contains(uintptr_t p) const { + for (auto &r : ranges) + if (p >= r.lo && p < r.hi) + return true; + return false; + } +}; +extern Module g_client, g_engine; + +// --------------------------------------------------------------------------- +// game interfaces +// --------------------------------------------------------------------------- + +using CreateInterfaceFn = void *(*)(const char *, int *); + +struct GameInterfaces { + void *client = nullptr; + void *entitylist = nullptr; + void *engine = nullptr; +}; +extern GameInterfaces g_iface; + +#define VTABLE(obj) (*(void ***)(obj)) +template inline Fn vfunc(void *obj, size_t idx) { + return reinterpret_cast(VTABLE(obj)[idx]); +} + +// --------------------------------------------------------------------------- +// netvars +// --------------------------------------------------------------------------- + +struct NetVars { + int flags = -1; + int velocity = -1; + int movetype = -1; + bool ok() const { return flags >= 0 && velocity >= 0 && movetype >= 0; } +}; +extern NetVars g_net; + +// --------------------------------------------------------------------------- +// CInput +// --------------------------------------------------------------------------- + +extern uintptr_t g_input; + +// --------------------------------------------------------------------------- +// CUserCmd +// --------------------------------------------------------------------------- + +struct CUserCmd { + void *vtable; + int command_number; + int tick_count; + float viewangles[3]; + float forwardmove; + float sidemove; + float upmove; + int buttons; + uint8_t impulse; + int weaponselect; + int weaponsubtype; + int random_seed; + short mousedx; + short mousedy; + bool hasbeenpredicted; +}; + +// --------------------------------------------------------------------------- +// engine constants +// --------------------------------------------------------------------------- + +enum { IN_ATTACK = 1 << 0, IN_JUMP = 1 << 1, IN_DUCK = 1 << 2, IN_USE = 1 << 5 }; +enum { FL_ONGROUND = 1 << 0, FL_INWATER = 1 << 9 }; +enum { MOVETYPE_NOCLIP = 8, MOVETYPE_LADDER = 9 }; + +// --------------------------------------------------------------------------- +// vector math +// --------------------------------------------------------------------------- + +struct Vector { float x, y, z; }; +struct QAngle { float x, y, z; }; +QAngle vector_angles(const Vector &forward); +Vector angle_forward_vector(const QAngle &angles); +float getfov(const QAngle &my_view, const QAngle &aim_ang); + +// --------------------------------------------------------------------------- +// cross-file declarations +// --------------------------------------------------------------------------- + +void note_modified(const CUserCmd *cmd, int flags, const float *vel); +CUserCmd *get_usercmd(int seq); +void fix_verified_crc(int seq, uint32_t crc); +uint32_t usercmd_checksum(const CUserCmd *c); +bool find_input_global(); +void resolve_netvars(); +void find_modules(); +void install_menu(); +void init_conmsg(); +void init_x11(); +bool middle_mouse_down(); + +#endif -- cgit v1.2.3