Exposed third parameter of TF2's AddCond in TF2_AddCondition (bug 5641, r=psychonic).

This commit is contained in:
FlaminSarge 2013-03-16 18:05:22 -04:00
parent c8fb05dd4b
commit 2e158a72e2
2 changed files with 11 additions and 3 deletions

View File

@ -236,7 +236,7 @@ cell_t TF2_AddCondition(IPluginContext *pContext, const cell_t *params)
{
static ICallWrapper *pWrapper = NULL;
// CTFPlayerShared::AddCond(int, float)
// CTFPlayerShared::AddCond(int, float, CBaseEntity *)
if (!pWrapper)
{
REGISTER_NATIVE_ADDR("AddCondition",
@ -259,6 +259,13 @@ cell_t TF2_AddCondition(IPluginContext *pContext, const cell_t *params)
return pContext->ThrowNativeError("Client index %d is not valid", params[1]);
}
CBaseEntity *pInflictor = NULL;
// Compatibility fix for the new inflictor parameter; TF2 seems to only use player entities in it
if (params[0] >= 4 && params[4] > 0 && !(pInflictor = UTIL_GetCBaseEntity(params[4], true)))
{
return pContext->ThrowNativeError("Inflictor index %d is not valid", params[4]);
}
void *obj = (void *)((uint8_t *)pEntity + playerSharedOffset->actual_offset);
unsigned char vstk[sizeof(void *) + sizeof(int) + sizeof(float) + sizeof(CBaseEntity *)];
@ -270,7 +277,7 @@ cell_t TF2_AddCondition(IPluginContext *pContext, const cell_t *params)
vptr += sizeof(int);
*(float *)vptr = *(float *)&params[3];
vptr += sizeof(float);
*(CBaseEntity **)vptr = NULL;
*(CBaseEntity **)vptr = pInflictor;
pWrapper->Execute(vstk, NULL);

View File

@ -202,10 +202,11 @@ native TF2_RegeneratePlayer(client);
* @param client Player's index.
* @param condition Integer identifier of condition to apply.
* @param duration Duration of condition (does not apply to all conditions).
* @param inflictor Condition inflictor's index (0 for no inflictor).
* @noreturn
* @error Invalid client index, client not in game, or no mod support.
*/
native TF2_AddCondition(client, TFCond:condition, Float:duration);
native TF2_AddCondition(client, TFCond:condition, Float:duration, inflictor=0);
/**
* Removes a condition from a player