From 6e05648d06db66343354e79e8b78ba27fb2f9bc8 Mon Sep 17 00:00:00 2001 From: sruon Date: Sat, 31 Jan 2026 22:44:26 -0700 Subject: [PATCH] Unlock items on synthesis failure for recipes that cant lose items --- src/map/utils/synthutils.cpp | 37 ++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/src/map/utils/synthutils.cpp b/src/map/utils/synthutils.cpp index a0010070d34..e39e18758d2 100644 --- a/src/map/utils/synthutils.cpp +++ b/src/map/utils/synthutils.cpp @@ -986,6 +986,43 @@ void doSynthFail(CCharEntity* PChar) { handleMaterialLoss(PChar); } + else + { + // Recipe cannot lose ingredients, unlock everything. + uint8 invSlotID = PChar->CraftContainer->getInvSlotID(1); + uint8 nextSlotID = 0; + uint8 totalCount = 0; + + for (uint8 slotID = 1; slotID <= 8; ++slotID) + { + if (slotID != 8) + { + nextSlotID = PChar->CraftContainer->getInvSlotID(slotID + 1); + } + + totalCount++; + + if (invSlotID != nextSlotID) + { + if (auto* PItem = PChar->getStorage(LOC_INVENTORY)->GetItem(invSlotID)) + { + PItem->setSubType(ITEM_UNLOCKED); + PItem->setReserve(PItem->getReserve() - totalCount); + PChar->pushPacket(PItem, ItemLockFlg::Normal); + } + + invSlotID = nextSlotID; + totalCount = 0; + } + + nextSlotID = 0; + + if (invSlotID == 0xFF) + { + break; + } + } + } // Push "Synthesis failed" messages. uint16 currentZone = PChar->loc.zone->GetID();