Skip to content

Commit

Permalink
Revert "Prevent player loadout from being used if expecting a custom …
Browse files Browse the repository at this point in the history
…item"

This appears to be causing crashes within
CTFGameStats::Event_PlayerLoadoutChanged, have to figure out why.

Apparently even a nullptr would be prefered here.

This reverts commit 4ba9a96.
  • Loading branch information
nosoop committed Mar 19, 2021
1 parent 4ba9a96 commit 19ffe17
Showing 1 changed file with 1 addition and 23 deletions.
24 changes: 1 addition & 23 deletions scripting/cwx.sp
Original file line number Diff line number Diff line change
Expand Up @@ -231,9 +231,6 @@ Action OnPlayerLoadoutUpdated(UserMsg msg_id, BfRead msg, const int[] players,
/**
* Item persistence - we return our item's CEconItemView instance when the game looks up our
* inventory item. This prevents our custom item from being invalidated when touch resupply.
*
* The game expects there to be a valid CEconItemView pointer in certain areas of the code, so
* avoid returning a nullptr.
*/
MRESReturn OnGetLoadoutItemPost(int client, Handle hReturn, Handle hParams) {
// TODO: work around invalid class items being invalidated
Expand All @@ -246,26 +243,7 @@ MRESReturn OnGetLoadoutItemPost(int client, Handle hReturn, Handle hParams) {

int storedItem = g_CurrentLoadoutEntity[client][playerClass][loadoutSlot];
if (!IsValidEntity(storedItem) || !HasEntProp(storedItem, Prop_Send, "m_Item")) {
// the loadout entity we keep track of isn't valid, so we may need to make one
// we expect to have to equip something new at this point

if (!g_CurrentLoadout[client][playerClass][loadoutSlot][0]) {
// we don't have a custom item; let the game process it
return MRES_Ignored;
}

/**
* we have a custom item we'd like to spawn in, don't return a loadout item, otherwise
* we may equip / unequip a weapon that has side effects (e.g. Gunslinger)
*
* we'll initialize our custom item later in `OnPlayerLoadoutUpdated`
*/
static int s_DefaultItem = INVALID_ENT_REFERENCE;
if (!IsValidEntity(s_DefaultItem)) {
s_DefaultItem = TF2_SpawnWearable();
RemoveEntity(s_DefaultItem);
}
storedItem = s_DefaultItem;
return MRES_Ignored;
}

Address pStoredItemView = GetEntityAddress(storedItem)
Expand Down

0 comments on commit 19ffe17

Please sign in to comment.