Skip to content

Commit

Permalink
Ensure set_turn_to_ice only checks weapons/wearables (#25)
Browse files Browse the repository at this point in the history
The `weapon` parameter in OnTakeDamage is a `CBaseEntity*`, so attempting to
use attribute hooks on it may fail.
  • Loading branch information
M60TM authored Dec 1, 2023
1 parent 9b7c45f commit 3e8c280
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions scripting/tf2attribute_support.sp
Original file line number Diff line number Diff line change
Expand Up @@ -1151,8 +1151,11 @@ MRESReturn OnPlayerKilledPre(int client, Handle hParams) {
int weapon = DHookGetParamObjectPtrVar(hParams, 1, offs_CTakeDamageInfo_hWeapon,
ObjectValueType_Ehandle);

g_bShouldTurnToIce[client] = IsValidEntity(weapon)
&& TF2Attrib_HookValueInt(0, "set_turn_to_ice", weapon);
if (!IsValidEntity(weapon) || !weapon) {
return MRES_Ignored;
} else if (TF2Util_IsEntityWeapon(weapon) || TF2Util_IsEntityWearable(weapon)) {
g_bShouldTurnToIce[client] = TF2Attrib_HookValueInt(0, "set_turn_to_ice", weapon) != 0;
}

return MRES_Ignored;
}
Expand Down

0 comments on commit 3e8c280

Please sign in to comment.