extensions/sdktools/hooks.cpp
changeset 3619 0249ba510bfe
parent 3348 fcae86e8cb8f
child 3819 d17aed3d46bf
     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 +}