Added more parameters to PlayerRunCommand forward (bug 5346, r=asherkin).
authorTony <aangione@gmail.com>
Tue Aug 21 00:42:46 2012 -0400 (2012-08-21)
changeset 36190249ba510bfe
parent 3618 aacb335fc248
child 3620 bb36770ded54
Added more parameters to PlayerRunCommand forward (bug 5346, r=asherkin).
extensions/sdktools/hooks.cpp
extensions/sdktools/hooks.h
plugins/include/sdktools_hooks.inc
     1.1 --- a/extensions/sdktools/hooks.cpp	Tue Aug 21 00:17:48 2012 -0400
     1.2 +++ b/extensions/sdktools/hooks.cpp	Tue Aug 21 00:42:46 2012 -0400
     1.3 @@ -32,6 +32,8 @@
     1.4  #include "hooks.h"
     1.5  #include "extension.h"
     1.6  
     1.7 +#define FEATURECAP_PLAYERRUNCMD_11PARAMS	"SDKTools PlayerRunCmd 11Params"
     1.8 +
     1.9  CHookManager g_Hooks;
    1.10  static bool PRCH_enabled = false;
    1.11  static bool PRCH_used = false;
    1.12 @@ -53,8 +55,20 @@
    1.13  	}
    1.14  
    1.15  	plsys->AddPluginsListener(this);
    1.16 +	sharesys->AddCapabilityProvider(myself, this, FEATURECAP_PLAYERRUNCMD_11PARAMS);
    1.17  
    1.18 -	m_usercmdsFwd = forwards->CreateForward("OnPlayerRunCmd", ET_Event, 6, NULL, Param_Cell, Param_CellByRef, Param_CellByRef, Param_Array, Param_Array, Param_CellByRef);
    1.19 +	m_usercmdsFwd = forwards->CreateForward("OnPlayerRunCmd", ET_Event, 11, NULL,
    1.20 +		Param_Cell,			// client
    1.21 +		Param_CellByRef,	// buttons
    1.22 +		Param_CellByRef,	// impulse
    1.23 +		Param_Array,		// Float:vel[3]
    1.24 +		Param_Array,		// Float:angles[3]
    1.25 +		Param_CellByRef,	// weapon
    1.26 +		Param_CellByRef,	// subtype
    1.27 +		Param_CellByRef,	// cmdnum
    1.28 +		Param_CellByRef,	// tickcount
    1.29 +		Param_CellByRef,	// seed
    1.30 +		Param_Array);		// mouse[2]
    1.31  }
    1.32  
    1.33  void CHookManager::Shutdown()
    1.34 @@ -62,6 +76,7 @@
    1.35  	forwards->ReleaseForward(m_usercmdsFwd);
    1.36  
    1.37  	plsys->RemovePluginsListener(this);
    1.38 +	sharesys->DropCapabilityProvider(myself, this, FEATURECAP_PLAYERRUNCMD_11PARAMS);
    1.39  }
    1.40  
    1.41  void CHookManager::OnClientPutInServer(int client)
    1.42 @@ -151,6 +166,7 @@
    1.43  	cell_t impulse = ucmd->impulse;
    1.44  	cell_t vel[3] = {sp_ftoc(ucmd->forwardmove), sp_ftoc(ucmd->sidemove), sp_ftoc(ucmd->upmove)};
    1.45  	cell_t angles[3] = {sp_ftoc(ucmd->viewangles.x), sp_ftoc(ucmd->viewangles.y), sp_ftoc(ucmd->viewangles.z)};
    1.46 +	cell_t mouse[2] = {ucmd->mousedx, ucmd->mousedy};
    1.47  
    1.48  	m_usercmdsFwd->PushCell(client);
    1.49  	m_usercmdsFwd->PushCellByRef(&ucmd->buttons);
    1.50 @@ -158,6 +174,11 @@
    1.51  	m_usercmdsFwd->PushArray(vel, 3, SM_PARAM_COPYBACK);
    1.52  	m_usercmdsFwd->PushArray(angles, 3, SM_PARAM_COPYBACK);
    1.53  	m_usercmdsFwd->PushCellByRef(&ucmd->weaponselect);
    1.54 +	m_usercmdsFwd->PushCellByRef(&ucmd->weaponsubtype);
    1.55 +	m_usercmdsFwd->PushCellByRef(&ucmd->command_number);
    1.56 +	m_usercmdsFwd->PushCellByRef(&ucmd->tick_count);
    1.57 +	m_usercmdsFwd->PushCellByRef(&ucmd->random_seed);
    1.58 +	m_usercmdsFwd->PushArray(mouse, 2, SM_PARAM_COPYBACK);
    1.59  	m_usercmdsFwd->Execute(&result);
    1.60  
    1.61  	ucmd->impulse = impulse;
    1.62 @@ -167,6 +188,8 @@
    1.63  	ucmd->viewangles.x = sp_ctof(angles[0]);
    1.64  	ucmd->viewangles.y = sp_ctof(angles[1]);
    1.65  	ucmd->viewangles.z = sp_ctof(angles[2]);
    1.66 +	ucmd->mousedx = mouse[0];
    1.67 +	ucmd->mousedy = mouse[1];
    1.68  
    1.69  
    1.70  	if (result == Pl_Handled)
    1.71 @@ -222,3 +245,8 @@
    1.72  
    1.73  	PRCH_used = false;
    1.74  }
    1.75 +
    1.76 +FeatureStatus CHookManager::GetFeatureStatus(FeatureType type, const char *name)
    1.77 +{
    1.78 +	return FeatureStatus_Available;
    1.79 +}
     2.1 --- a/extensions/sdktools/hooks.h	Tue Aug 21 00:17:48 2012 -0400
     2.2 +++ b/extensions/sdktools/hooks.h	Tue Aug 21 00:42:46 2012 -0400
     2.3 @@ -40,7 +40,7 @@
     2.4  #include "usercmd.h"
     2.5  #include "extension.h"
     2.6  
     2.7 -class CHookManager : IPluginsListener
     2.8 +class CHookManager : IPluginsListener, IFeatureProvider
     2.9  {
    2.10  public:
    2.11  	CHookManager();
    2.12 @@ -52,6 +52,8 @@
    2.13  public: //IPluginsListener
    2.14  	void OnPluginLoaded(IPlugin *plugin);
    2.15  	void OnPluginUnloaded(IPlugin *plugin);
    2.16 +public: //IFeatureProvider
    2.17 +	virtual FeatureStatus GetFeatureStatus(FeatureType type, const char *name);
    2.18  
    2.19  private:
    2.20  	IForward *m_usercmdsFwd;
     3.1 --- a/plugins/include/sdktools_hooks.inc	Tue Aug 21 00:17:48 2012 -0400
     3.2 +++ b/plugins/include/sdktools_hooks.inc	Tue Aug 21 00:42:46 2012 -0400
     3.3 @@ -35,6 +35,8 @@
     3.4  #endif
     3.5  #define _sdktools_hooks_included
     3.6  
     3.7 +#define FEATURECAP_PLAYERRUNCMD_11PARAMS	"SDKTools PlayerRunCmd 11Params"
     3.8 +
     3.9  /**
    3.10   * @brief Called when a clients movement buttons are being processed
    3.11   *
    3.12 @@ -44,6 +46,14 @@
    3.13   * @param vel		Players desired velocity.
    3.14   * @param angles	Players desired view angles.
    3.15   * @param weapon	Entity index of the new weapon if player switches weapon, 0 otherwise.
    3.16 + * @param subtype	Weapon subtype when selected from a menu.
    3.17 + * @param cmdnum	Command number. Increments from the first command sent.
    3.18 + * @param tickcount	Tick count. A client's prediction based on the server's GetGameTickCount value.
    3.19 + * @param seed		Random seed. Used to determine weapon recoil, spread, and other predicted elements.
    3.20 + * @param mouse		Mouse direction (x, y).
    3.21   * @return 			Plugin_Handled to block the commands from being processed, Plugin_Continue otherwise.
    3.22 + *
    3.23 + * @note			To see if all 11 params are avaliable, use FeatureType_Capability and
    3.24 + *					FEATURECAP_PLAYERRUNCMD_11PARAMS.
    3.25   */
    3.26 -forward Action:OnPlayerRunCmd(client, &buttons, &impulse, Float:vel[3], Float:angles[3], &weapon);
    3.27 \ No newline at end of file
    3.28 +forward Action:OnPlayerRunCmd(client, &buttons, &impulse, Float:vel[3], Float:angles[3], &weapon, &subtype, &cmdnum, &tickcount, &seed, mouse[2]);
    3.29 \ No newline at end of file