From 428e01c18c80daeaf9d40f292974fe15d8eb398a Mon Sep 17 00:00:00 2001 From: Ben Lubar Date: Wed, 8 May 2024 08:13:36 -0500 Subject: [PATCH] fix an issue where opening a box that is stacked on top of another box would make the game's UI think the player obtained both the contents of the top box and the bottom box --- .../client/swarm/gameui/swarm/vitemshowcase.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/game/client/swarm/gameui/swarm/vitemshowcase.cpp b/src/game/client/swarm/gameui/swarm/vitemshowcase.cpp index 7dd003319..f610b7a5e 100644 --- a/src/game/client/swarm/gameui/swarm/vitemshowcase.cpp +++ b/src/game/client/swarm/gameui/swarm/vitemshowcase.cpp @@ -441,6 +441,7 @@ void ItemShowcase::ShowItems( SteamInventoryResult_t hResult, int iStart, int iC delete pInstance; continue; } + const ReactiveDropInventory::ItemDef_t *pDef = ReactiveDropInventory::GetItemDef( pInstance->ItemDefID ); if ( !pDef || pDef->GameOnly ) { @@ -448,8 +449,24 @@ void ItemShowcase::ShowItems( SteamInventoryResult_t hResult, int iStart, int iC continue; } + if ( const ReactiveDropInventory::ItemInstance_t *pPrev = ReactiveDropInventory::GetLocalItemCache( pInstance->ItemID ) ) + { + if ( pPrev->Quantity > pInstance->Quantity ) + { + // we consumed items from a stack + delete pInstance; + continue; + } + else if ( pPrev->Quantity < pInstance->Quantity && pDef->AutoStack ) + { + // we added items to a stack + pInstance->Quantity -= pPrev->Quantity; + } + } + if ( pDef->AutoStack ) { + // replace previous versions of this item's state in the queue bool bFound = false; FOR_EACH_VEC( pItemShowcase->m_Queue, i ) {