From 9ac98cb09509000233feaf6cd7fdfeeef8b929e8 Mon Sep 17 00:00:00 2001 From: nosoop Date: Fri, 18 Aug 2023 08:07:44 -0700 Subject: [PATCH] Fix clipsize being retained from stock items It looks like something in CTFPlayer::ManageRegularWeapons depends on the item definition being accurate for the clip size. There's probably a better way to handle this in ::ItemsMatch() now that it's clear what it actually does, so we should review that in the future. Fixes #56. --- scripting/cwx.sp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/scripting/cwx.sp b/scripting/cwx.sp index a95fb0b..e5191c1 100644 --- a/scripting/cwx.sp +++ b/scripting/cwx.sp @@ -482,6 +482,16 @@ MRESReturn OnManageRegularWeaponsPre(int client, Handle hParams) { continue; } + int currentitemdef = GetEntProp(storedItem, Prop_Send, "m_iItemDefinitionIndex"); + if (TF2Econ_GetItemLoadoutSlot(currentitemdef, playerClass) != -1) { + // only replace the itemdef if the existing one is not valid for the class + // this is because something something static attribute retention + + // we should probably just drop support for invalid weapons at this point; + // it's starting to be a headache to manage + continue; + } + // replace the itemdef and classname with ones actually valid for that class to skirt // around the ValidateWeapons checks char classname[64];