From 0625638e316954b90e27d2358361a74fa82ff1e7 Mon Sep 17 00:00:00 2001 From: 8dcc <8dcc.git@gmail.com> Date: Sun, 30 Jul 2023 20:05:22 +0200 Subject: [PATCH] Hook CalcRefdef, store punchAngles --- src/hooks.c | 9 +++++++++ src/include/hooks.h | 1 + src/include/sdk.h | 2 +- 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/hooks.c b/src/hooks.c index 1a36830..192e1ef 100644 --- a/src/hooks.c +++ b/src/hooks.c @@ -11,6 +11,7 @@ DECL_HOOK(CL_CreateMove); DECL_HOOK(HUD_Redraw); DECL_HOOK(StudioRenderModel); +DECL_HOOK(CalcRefdef); /* OpenGL hooks */ DECL_HOOK(glColor4f); @@ -27,6 +28,7 @@ bool hooks_init(void) { HOOK(i_client, CL_CreateMove); HOOK(i_client, HUD_Redraw); HOOK(i_studiomodelrenderer, StudioRenderModel); + HOOK(i_client, CalcRefdef); /* OpenGL hooks */ GL_HOOK(glColor4f); @@ -85,6 +87,13 @@ void h_StudioRenderModel(void* this_ptr) { ORIGINAL(StudioRenderModel, this_ptr); } +void h_CalcRefdef(ref_params_t* params) { + /* Store punch angles for CreateMove */ + vec_copy(g_punchAngles, params->punchangle); + + ORIGINAL(CalcRefdef, params); +} + /*----------------------------------------------------------------------------*/ void h_glColor4f(GLfloat r, GLfloat g, GLfloat b, GLfloat a) { diff --git a/src/include/hooks.h b/src/include/hooks.h index ab709d5..5106775 100644 --- a/src/include/hooks.h +++ b/src/include/hooks.h @@ -95,6 +95,7 @@ void hooks_restore(void); DECL_HOOK_EXTERN(void, CL_CreateMove, float, usercmd_t*, int); DECL_HOOK_EXTERN(int, HUD_Redraw, float, int); DECL_HOOK_EXTERN(void, StudioRenderModel, void*); +DECL_HOOK_EXTERN(void, CalcRefdef, ref_params_t*); /* OpenGL hooks */ DECL_HOOK_EXTERN(void, glColor4f, GLfloat, GLfloat, GLfloat, GLfloat); diff --git a/src/include/sdk.h b/src/include/sdk.h index 99e5626..7c9152f 100644 --- a/src/include/sdk.h +++ b/src/include/sdk.h @@ -62,7 +62,7 @@ typedef struct cl_clientfuncs_s { void (*CL_CameraOffset)(float* ofs); struct kbutton_s* (*KB_Find)(const char* name); void (*CAM_Think)(void); - void (*V_CalcRefdef)(struct ref_params_s* pparams); + void (*CalcRefdef)(struct ref_params_s* pparams); int (*HUD_AddEntity)(int type, struct cl_entity_s* ent, const char* modelname);