diff --git a/src/hooks.c b/src/hooks.c index 192e1ef..affa7e4 100644 --- a/src/hooks.c +++ b/src/hooks.c @@ -12,6 +12,7 @@ DECL_HOOK(CL_CreateMove); DECL_HOOK(HUD_Redraw); DECL_HOOK(StudioRenderModel); DECL_HOOK(CalcRefdef); +DECL_HOOK(HUD_PostRunCmd); /* OpenGL hooks */ DECL_HOOK(glColor4f); @@ -29,6 +30,7 @@ bool hooks_init(void) { HOOK(i_client, HUD_Redraw); HOOK(i_studiomodelrenderer, StudioRenderModel); HOOK(i_client, CalcRefdef); + HOOK(i_client, HUD_PostRunCmd); /* OpenGL hooks */ GL_HOOK(glColor4f); @@ -87,6 +89,8 @@ 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); @@ -96,6 +100,21 @@ void h_CalcRefdef(ref_params_t* params) { /*----------------------------------------------------------------------------*/ +void h_HUD_PostRunCmd(struct local_state_s* from, struct local_state_s* to, + struct usercmd_s* cmd, int runfuncs, double time, + unsigned int random_seed) { + ORIGINAL(HUD_PostRunCmd, from, to, cmd, runfuncs, time, random_seed); + + /* Store attack information to check if we can shoot */ + if (runfuncs) { + g_flNextAttack = to->client.m_flNextAttack; + g_flNextPrimaryAttack = + to->weapondata[to->client.m_iId].m_flNextPrimaryAttack; + } +} + +/*----------------------------------------------------------------------------*/ + void h_glColor4f(GLfloat r, GLfloat g, GLfloat b, GLfloat a) { /* This visible_mode variable is changed inside the chams() function, which * is called from the StudioRenderModel hook. diff --git a/src/include/hooks.h b/src/include/hooks.h index 5106775..564b1b9 100644 --- a/src/include/hooks.h +++ b/src/include/hooks.h @@ -96,6 +96,9 @@ 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*); +DECL_HOOK_EXTERN(void, HUD_PostRunCmd, struct local_state_s*, + struct local_state_s*, struct usercmd_s*, int, double, + unsigned int); /* OpenGL hooks */ DECL_HOOK_EXTERN(void, glColor4f, GLfloat, GLfloat, GLfloat, GLfloat);