Skip to content

Commit

Permalink
Fix clipsize being retained from stock items
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
nosoop committed Aug 18, 2023
1 parent 311a08a commit 9ac98cb
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions scripting/cwx.sp
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down

0 comments on commit 9ac98cb

Please sign in to comment.