Exposed third parameter of TF2's AddCond in TF2_AddCondition (bug 5641, r=psychonic).
authorFlaminSarge <laftrykung@yahoo.com>
Sat Mar 16 18:05:22 2013 -0400 (2013-03-16)
changeset 3818f25d64a5cd7a
parent 3817 87d44c16b4d2
child 3819 d17aed3d46bf
Exposed third parameter of TF2's AddCond in TF2_AddCondition (bug 5641, r=psychonic).
extensions/tf2/natives.cpp
plugins/include/tf2.inc
     1.1 --- a/extensions/tf2/natives.cpp	Sat Mar 16 14:11:56 2013 -0400
     1.2 +++ b/extensions/tf2/natives.cpp	Sat Mar 16 18:05:22 2013 -0400
     1.3 @@ -236,7 +236,7 @@
     1.4  {
     1.5  	static ICallWrapper *pWrapper = NULL;
     1.6  
     1.7 -	// CTFPlayerShared::AddCond(int, float)
     1.8 +	// CTFPlayerShared::AddCond(int, float, CBaseEntity *)
     1.9  	if (!pWrapper)
    1.10  	{
    1.11  		REGISTER_NATIVE_ADDR("AddCondition", 
    1.12 @@ -259,6 +259,13 @@
    1.13  		return pContext->ThrowNativeError("Client index %d is not valid", params[1]);
    1.14  	}
    1.15  
    1.16 +	CBaseEntity *pInflictor = NULL;
    1.17 +	// Compatibility fix for the new inflictor parameter; TF2 seems to only use player entities in it
    1.18 +	if (params[0] >= 4 && params[4] > 0 && !(pInflictor = UTIL_GetCBaseEntity(params[4], true)))
    1.19 +	{
    1.20 +		return pContext->ThrowNativeError("Inflictor index %d is not valid", params[4]);
    1.21 +	}
    1.22 +
    1.23  	void *obj = (void *)((uint8_t *)pEntity + playerSharedOffset->actual_offset);
    1.24  
    1.25  	unsigned char vstk[sizeof(void *) + sizeof(int) + sizeof(float) + sizeof(CBaseEntity *)];
    1.26 @@ -270,7 +277,7 @@
    1.27  	vptr += sizeof(int);
    1.28  	*(float *)vptr = *(float *)&params[3];
    1.29  	vptr += sizeof(float);
    1.30 -	*(CBaseEntity **)vptr = NULL;
    1.31 +	*(CBaseEntity **)vptr = pInflictor;
    1.32  
    1.33  	pWrapper->Execute(vstk, NULL);
    1.34  
     2.1 --- a/plugins/include/tf2.inc	Sat Mar 16 14:11:56 2013 -0400
     2.2 +++ b/plugins/include/tf2.inc	Sat Mar 16 18:05:22 2013 -0400
     2.3 @@ -202,10 +202,11 @@
     2.4   * @param client		Player's index.
     2.5   * @param condition		Integer identifier of condition to apply.
     2.6   * @param duration		Duration of condition (does not apply to all conditions).
     2.7 + * @param inflictor		Condition inflictor's index (0 for no inflictor).
     2.8   * @noreturn
     2.9   * @error				Invalid client index, client not in game, or no mod support.
    2.10   */
    2.11 -native TF2_AddCondition(client, TFCond:condition, Float:duration);
    2.12 +native TF2_AddCondition(client, TFCond:condition, Float:duration, inflictor=0);
    2.13  
    2.14  /**
    2.15   * Removes a condition from a player