From 90e7aa65a19316f0bd684303b314ad22b1362f09 Mon Sep 17 00:00:00 2001 From: connorr Date: Wed, 3 Jul 2013 00:19:12 +0200 Subject: [PATCH] Fix incorrect behavior of impulse forwards (bug 3243, r=Arkshine) Former-commit-id: 1aae4c3ec57c61ba3f32579e236b07da54ae14bf --- dlls/engine/amxxapi.cpp | 4 ++-- dlls/engine/engine.h | 2 +- dlls/engine/forwards.cpp | 32 ++++++++++++++------------------ 3 files changed, 17 insertions(+), 21 deletions(-) diff --git a/dlls/engine/amxxapi.cpp b/dlls/engine/amxxapi.cpp index 98d6179f..de1a6005 100755 --- a/dlls/engine/amxxapi.cpp +++ b/dlls/engine/amxxapi.cpp @@ -34,7 +34,7 @@ void OnAmxxAttach() PlayerPreThinkForward = 0; PlayerPostThinkForward = 0; ClientKillForward = 0; - CmdStartForward = 0; + ClientImpulseForward = 0; StartFrameForward = 0; MF_AddNatives(ent_Natives); MF_AddNewNatives(ent_NewNatives); @@ -54,7 +54,7 @@ void OnPluginsLoaded() PlayerPreThinkForward = MF_RegisterForward("client_PreThink", ET_STOP, FP_CELL, FP_DONE); // done PlayerPostThinkForward = MF_RegisterForward("client_PostThink", ET_STOP, FP_CELL, FP_DONE); // done ClientKillForward = MF_RegisterForward("client_kill", ET_STOP, FP_CELL, FP_DONE); // done - CmdStartForward = MF_RegisterForward("client_impulse", ET_STOP, FP_CELL, FP_CELL, FP_DONE); // done + ClientImpulseForward = MF_RegisterForward("client_impulse", ET_STOP, FP_CELL, FP_CELL, FP_DONE); // done StartFrameForward = MF_RegisterForward("server_frame", ET_IGNORE, FP_DONE); // done DispatchKeyForward = MF_RegisterForward("pfn_keyvalue", ET_STOP, FP_CELL, FP_DONE); // done PlaybackForward = MF_RegisterForward("pfn_playbackevent", ET_STOP, FP_CELL, FP_CELL, FP_CELL, FP_FLOAT, FP_ARRAY, FP_ARRAY, FP_FLOAT, FP_FLOAT, FP_CELL, FP_CELL, FP_CELL, FP_CELL, FP_DONE); // done diff --git a/dlls/engine/engine.h b/dlls/engine/engine.h index fd26160a..52126b43 100755 --- a/dlls/engine/engine.h +++ b/dlls/engine/engine.h @@ -27,7 +27,7 @@ extern int pfnThinkForward; extern int PlayerPreThinkForward; extern int PlayerPostThinkForward; extern int ClientKillForward; -extern int CmdStartForward; +extern int ClientImpulseForward; extern int StartFrameForward; extern int DispatchUseForward; extern int VexdTouchForward; diff --git a/dlls/engine/forwards.cpp b/dlls/engine/forwards.cpp index a74328fa..89874d7c 100755 --- a/dlls/engine/forwards.cpp +++ b/dlls/engine/forwards.cpp @@ -10,7 +10,7 @@ int pfnThinkForward = 0; int PlayerPreThinkForward = 0; int PlayerPostThinkForward = 0; int ClientKillForward = 0; -int CmdStartForward = 0; +int ClientImpulseForward = 0; int StartFrameForward = 0; int VexdTouchForward = 0; int VexdServerForward = 0; @@ -131,27 +131,23 @@ void CmdStart(const edict_t *player, const struct usercmd_s *_cmd, unsigned int if (Impulses[i]->Check == g_cmd->impulse) { retVal = MF_ExecuteForward(Impulses[i]->Forward, (cell)ENTINDEX(pEntity), (cell)origImpulse); - if (retVal & 2 /*PLUGIN_HANDLED_MAIN*/) - { - g_cmd->impulse=0; - RETURN_META(MRES_SUPERCEDE); - } - else if (retVal) - res = MRES_SUPERCEDE; + + // don't return SUPERCEDE in any way here, + // we don't want to break client_impulse forward and access to cmd with [g/s]et_usercmd + if (retVal) + g_cmd->impulse = 0; } } - if (CmdStartForward != -1) { - incmd = true; - retVal = MF_ExecuteForward(CmdStartForward, (cell)ENTINDEX(pEntity), (cell)origImpulse); - incmd = false; - if (retVal) { + + if (ClientImpulseForward != -1 && origImpulse != 0) + { + retVal = MF_ExecuteForward(ClientImpulseForward, (cell)ENTINDEX(pEntity), (cell)origImpulse); + + if (retVal) g_cmd->impulse = 0; - RETURN_META(MRES_SUPERCEDE); - } } - if (res == MRES_SUPERCEDE) - g_cmd->impulse=0; - RETURN_META(res); + + RETURN_META(MRES_IGNORED); } void ClientKill(edict_t *pEntity)