Added more parameters to PlayerRunCommand forward (bug 5346, r=asherkin).
This commit is contained in:
parent
cb3411481d
commit
74f49ec38f
@ -32,6 +32,8 @@
|
|||||||
#include "hooks.h"
|
#include "hooks.h"
|
||||||
#include "extension.h"
|
#include "extension.h"
|
||||||
|
|
||||||
|
#define FEATURECAP_PLAYERRUNCMD_11PARAMS "SDKTools PlayerRunCmd 11Params"
|
||||||
|
|
||||||
CHookManager g_Hooks;
|
CHookManager g_Hooks;
|
||||||
static bool PRCH_enabled = false;
|
static bool PRCH_enabled = false;
|
||||||
static bool PRCH_used = false;
|
static bool PRCH_used = false;
|
||||||
@ -53,8 +55,20 @@ void CHookManager::Initialize()
|
|||||||
}
|
}
|
||||||
|
|
||||||
plsys->AddPluginsListener(this);
|
plsys->AddPluginsListener(this);
|
||||||
|
sharesys->AddCapabilityProvider(myself, this, FEATURECAP_PLAYERRUNCMD_11PARAMS);
|
||||||
|
|
||||||
m_usercmdsFwd = forwards->CreateForward("OnPlayerRunCmd", ET_Event, 6, NULL, Param_Cell, Param_CellByRef, Param_CellByRef, Param_Array, Param_Array, Param_CellByRef);
|
m_usercmdsFwd = forwards->CreateForward("OnPlayerRunCmd", ET_Event, 11, NULL,
|
||||||
|
Param_Cell, // client
|
||||||
|
Param_CellByRef, // buttons
|
||||||
|
Param_CellByRef, // impulse
|
||||||
|
Param_Array, // Float:vel[3]
|
||||||
|
Param_Array, // Float:angles[3]
|
||||||
|
Param_CellByRef, // weapon
|
||||||
|
Param_CellByRef, // subtype
|
||||||
|
Param_CellByRef, // cmdnum
|
||||||
|
Param_CellByRef, // tickcount
|
||||||
|
Param_CellByRef, // seed
|
||||||
|
Param_Array); // mouse[2]
|
||||||
}
|
}
|
||||||
|
|
||||||
void CHookManager::Shutdown()
|
void CHookManager::Shutdown()
|
||||||
@ -62,6 +76,7 @@ void CHookManager::Shutdown()
|
|||||||
forwards->ReleaseForward(m_usercmdsFwd);
|
forwards->ReleaseForward(m_usercmdsFwd);
|
||||||
|
|
||||||
plsys->RemovePluginsListener(this);
|
plsys->RemovePluginsListener(this);
|
||||||
|
sharesys->DropCapabilityProvider(myself, this, FEATURECAP_PLAYERRUNCMD_11PARAMS);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CHookManager::OnClientPutInServer(int client)
|
void CHookManager::OnClientPutInServer(int client)
|
||||||
@ -151,6 +166,7 @@ void CHookManager::PlayerRunCmd(CUserCmd *ucmd, IMoveHelper *moveHelper)
|
|||||||
cell_t impulse = ucmd->impulse;
|
cell_t impulse = ucmd->impulse;
|
||||||
cell_t vel[3] = {sp_ftoc(ucmd->forwardmove), sp_ftoc(ucmd->sidemove), sp_ftoc(ucmd->upmove)};
|
cell_t vel[3] = {sp_ftoc(ucmd->forwardmove), sp_ftoc(ucmd->sidemove), sp_ftoc(ucmd->upmove)};
|
||||||
cell_t angles[3] = {sp_ftoc(ucmd->viewangles.x), sp_ftoc(ucmd->viewangles.y), sp_ftoc(ucmd->viewangles.z)};
|
cell_t angles[3] = {sp_ftoc(ucmd->viewangles.x), sp_ftoc(ucmd->viewangles.y), sp_ftoc(ucmd->viewangles.z)};
|
||||||
|
cell_t mouse[2] = {ucmd->mousedx, ucmd->mousedy};
|
||||||
|
|
||||||
m_usercmdsFwd->PushCell(client);
|
m_usercmdsFwd->PushCell(client);
|
||||||
m_usercmdsFwd->PushCellByRef(&ucmd->buttons);
|
m_usercmdsFwd->PushCellByRef(&ucmd->buttons);
|
||||||
@ -158,6 +174,11 @@ void CHookManager::PlayerRunCmd(CUserCmd *ucmd, IMoveHelper *moveHelper)
|
|||||||
m_usercmdsFwd->PushArray(vel, 3, SM_PARAM_COPYBACK);
|
m_usercmdsFwd->PushArray(vel, 3, SM_PARAM_COPYBACK);
|
||||||
m_usercmdsFwd->PushArray(angles, 3, SM_PARAM_COPYBACK);
|
m_usercmdsFwd->PushArray(angles, 3, SM_PARAM_COPYBACK);
|
||||||
m_usercmdsFwd->PushCellByRef(&ucmd->weaponselect);
|
m_usercmdsFwd->PushCellByRef(&ucmd->weaponselect);
|
||||||
|
m_usercmdsFwd->PushCellByRef(&ucmd->weaponsubtype);
|
||||||
|
m_usercmdsFwd->PushCellByRef(&ucmd->command_number);
|
||||||
|
m_usercmdsFwd->PushCellByRef(&ucmd->tick_count);
|
||||||
|
m_usercmdsFwd->PushCellByRef(&ucmd->random_seed);
|
||||||
|
m_usercmdsFwd->PushArray(mouse, 2, SM_PARAM_COPYBACK);
|
||||||
m_usercmdsFwd->Execute(&result);
|
m_usercmdsFwd->Execute(&result);
|
||||||
|
|
||||||
ucmd->impulse = impulse;
|
ucmd->impulse = impulse;
|
||||||
@ -167,6 +188,8 @@ void CHookManager::PlayerRunCmd(CUserCmd *ucmd, IMoveHelper *moveHelper)
|
|||||||
ucmd->viewangles.x = sp_ctof(angles[0]);
|
ucmd->viewangles.x = sp_ctof(angles[0]);
|
||||||
ucmd->viewangles.y = sp_ctof(angles[1]);
|
ucmd->viewangles.y = sp_ctof(angles[1]);
|
||||||
ucmd->viewangles.z = sp_ctof(angles[2]);
|
ucmd->viewangles.z = sp_ctof(angles[2]);
|
||||||
|
ucmd->mousedx = mouse[0];
|
||||||
|
ucmd->mousedy = mouse[1];
|
||||||
|
|
||||||
|
|
||||||
if (result == Pl_Handled)
|
if (result == Pl_Handled)
|
||||||
@ -222,3 +245,8 @@ void CHookManager::OnPluginUnloaded(IPlugin *plugin)
|
|||||||
|
|
||||||
PRCH_used = false;
|
PRCH_used = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FeatureStatus CHookManager::GetFeatureStatus(FeatureType type, const char *name)
|
||||||
|
{
|
||||||
|
return FeatureStatus_Available;
|
||||||
|
}
|
||||||
|
@ -40,7 +40,7 @@
|
|||||||
#include "usercmd.h"
|
#include "usercmd.h"
|
||||||
#include "extension.h"
|
#include "extension.h"
|
||||||
|
|
||||||
class CHookManager : IPluginsListener
|
class CHookManager : IPluginsListener, IFeatureProvider
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CHookManager();
|
CHookManager();
|
||||||
@ -52,6 +52,8 @@ public:
|
|||||||
public: //IPluginsListener
|
public: //IPluginsListener
|
||||||
void OnPluginLoaded(IPlugin *plugin);
|
void OnPluginLoaded(IPlugin *plugin);
|
||||||
void OnPluginUnloaded(IPlugin *plugin);
|
void OnPluginUnloaded(IPlugin *plugin);
|
||||||
|
public: //IFeatureProvider
|
||||||
|
virtual FeatureStatus GetFeatureStatus(FeatureType type, const char *name);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
IForward *m_usercmdsFwd;
|
IForward *m_usercmdsFwd;
|
||||||
|
@ -35,6 +35,8 @@
|
|||||||
#endif
|
#endif
|
||||||
#define _sdktools_hooks_included
|
#define _sdktools_hooks_included
|
||||||
|
|
||||||
|
#define FEATURECAP_PLAYERRUNCMD_11PARAMS "SDKTools PlayerRunCmd 11Params"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Called when a clients movement buttons are being processed
|
* @brief Called when a clients movement buttons are being processed
|
||||||
*
|
*
|
||||||
@ -44,6 +46,14 @@
|
|||||||
* @param vel Players desired velocity.
|
* @param vel Players desired velocity.
|
||||||
* @param angles Players desired view angles.
|
* @param angles Players desired view angles.
|
||||||
* @param weapon Entity index of the new weapon if player switches weapon, 0 otherwise.
|
* @param weapon Entity index of the new weapon if player switches weapon, 0 otherwise.
|
||||||
|
* @param subtype Weapon subtype when selected from a menu.
|
||||||
|
* @param cmdnum Command number. Increments from the first command sent.
|
||||||
|
* @param tickcount Tick count. A client's prediction based on the server's GetGameTickCount value.
|
||||||
|
* @param seed Random seed. Used to determine weapon recoil, spread, and other predicted elements.
|
||||||
|
* @param mouse Mouse direction (x, y).
|
||||||
* @return Plugin_Handled to block the commands from being processed, Plugin_Continue otherwise.
|
* @return Plugin_Handled to block the commands from being processed, Plugin_Continue otherwise.
|
||||||
|
*
|
||||||
|
* @note To see if all 11 params are avaliable, use FeatureType_Capability and
|
||||||
|
* FEATURECAP_PLAYERRUNCMD_11PARAMS.
|
||||||
*/
|
*/
|
||||||
forward Action:OnPlayerRunCmd(client, &buttons, &impulse, Float:vel[3], Float:angles[3], &weapon);
|
forward Action:OnPlayerRunCmd(client, &buttons, &impulse, Float:vel[3], Float:angles[3], &weapon, &subtype, &cmdnum, &tickcount, &seed, mouse[2]);
|
Loading…
Reference in New Issue
Block a user