From a62aba3fc37991067ae8d2332df71d59cf5a3513 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 28 Aug 2025 22:50:26 +0000 Subject: [PATCH] Enhance SummonItemIntoInventory to support stacking Co-authored-by: Valorith <76063792+Valorith@users.noreply.github.com> --- zone/inventory.cpp | 44 +++++++++++++++++++++++++------------------- 1 file changed, 25 insertions(+), 19 deletions(-) diff --git a/zone/inventory.cpp b/zone/inventory.cpp index 1c2b62c4f..847368d1b 100644 --- a/zone/inventory.cpp +++ b/zone/inventory.cpp @@ -4607,26 +4607,32 @@ void Client::SummonItemIntoInventory( return; } - const bool is_arrow = inst->GetItem()->ItemType == EQ::item::ItemTypeArrow; - const int16 slot_id = m_inv.FindFreeSlot( - inst->IsClassBag(), - true, - inst->GetItem()->Size, - is_arrow - ); + // Try stacking first if the item is stackable, then fall back to finding a free slot + if (!PutItemInInventoryWithStacking(inst)) { + // PutItemInInventoryWithStacking failed, fall back to original behavior + const bool is_arrow = inst->GetItem()->ItemType == EQ::item::ItemTypeArrow; + const int16 slot_id = m_inv.FindFreeSlot( + inst->IsClassBag(), + true, + inst->GetItem()->Size, + is_arrow + ); - SummonItem( - item_id, - charges, - aug1, - aug2, - aug3, - aug4, - aug5, - aug6, - is_attuned, - slot_id - ); + SummonItem( + item_id, + charges, + aug1, + aug2, + aug3, + aug4, + aug5, + aug6, + is_attuned, + slot_id + ); + } + + safe_delete(inst); } bool Client::HasItemOnCorpse(uint32 item_id)