diff --git a/common/CMakeLists.txt b/common/CMakeLists.txt index 1a9028eb7..45af7b94d 100644 --- a/common/CMakeLists.txt +++ b/common/CMakeLists.txt @@ -842,6 +842,11 @@ ENDIF (UNIX) IF (EQEMU_BUILD_PCH) TARGET_PRECOMPILE_HEADERS(common PRIVATE pch/std-pch.h) + # Avoid PCH/__OPTIMIZE__ mismatch when compiling certain patch sources with -O0 + # These files are compiled with -O0 on UNIX (see COMPILE_FLAGS above), which + # disables the __OPTIMIZE__ predefined macro. Disabling PCH for them prevents + # Clang from erroring due to macro state differences between the PCH and TU. + SET_SOURCE_FILES_PROPERTIES("patches/sod.cpp" "patches/sof.cpp" "patches/rof.cpp" "patches/rof2.cpp" "patches/uf.cpp" PROPERTIES SKIP_PRECOMPILE_HEADERS ON) ENDIF () SET(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin) 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)