From 8216613d116e8b734c6cbfecc38639e55b76209a Mon Sep 17 00:00:00 2001 From: 8dcc <8dcc.git@gmail.com> Date: Thu, 20 Jul 2023 23:30:44 +0200 Subject: [PATCH] Add localplayer entity --- src/globals.c | 3 +++ src/hooks.c | 8 ++++++++ src/include/globals.h | 2 ++ 3 files changed, 13 insertions(+) diff --git a/src/globals.c b/src/globals.c index 7159519..e7cb219 100644 --- a/src/globals.c +++ b/src/globals.c @@ -10,6 +10,9 @@ DECL_INTF(cl_enginefunc_t, engine); DECL_INTF(cl_clientfunc_t, client); DECL_INTF(playermove_t, pmove); +/* Updated in CL_CreateMove hook */ +cl_entity_t* localplayer = NULL; + bool globals_init(void) { /* * Get handler for hw.so diff --git a/src/hooks.c b/src/hooks.c index 3bc6258..3cb14b6 100644 --- a/src/hooks.c +++ b/src/hooks.c @@ -16,5 +16,13 @@ bool hooks_init(void) { void h_CL_CreateMove(float frametime, usercmd_t* cmd, int active) { ORIGINAL(CL_CreateMove, frametime, cmd, active); + /* Declared in globals.c */ + localplayer = i_engine->GetLocalPlayer(); + +#ifdef DEBUG + printf("x: %f, y: %f, z: %f\n", localplayer->origin[0], + localplayer->origin[1], localplayer->origin[2]); +#endif + bhop(cmd); } diff --git a/src/include/globals.h b/src/include/globals.h index 163fb60..1b01967 100644 --- a/src/include/globals.h +++ b/src/include/globals.h @@ -29,6 +29,8 @@ DECL_INTF_EXTERN(cl_enginefunc_t, engine); DECL_INTF_EXTERN(cl_clientfunc_t, client); DECL_INTF_EXTERN(playermove_t, pmove); +extern cl_entity_t* localplayer; + /*----------------------------------------------------------------------------*/ bool globals_init(void);