From 65a608b478936d6204edc572db2dbcdca9cc5860 Mon Sep 17 00:00:00 2001 From: CPunch Date: Mon, 27 Feb 2023 16:07:37 -0600 Subject: [PATCH] Email: fix issue #186 --- src/Email.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/Email.cpp b/src/Email.cpp index be58012..ab65f00 100644 --- a/src/Email.cpp +++ b/src/Email.cpp @@ -252,11 +252,16 @@ static void emailSend(CNSocket* sock, CNPacketData* data) { if (attachment.ItemInven.iID == 0) continue; + sItemBase* item = &pkt->aItem[i].ItemInven; + sItemBase* real = &plr->Inven[attachment.iSlotNum]; + resp.aItem[i] = attachment; attachments.push_back(attachment.ItemInven); attSlots.push_back(attachment.iSlotNum); - // delete item - plr->Inven[attachment.iSlotNum] = { 0, 0, 0, 0 }; + if (real->iOpt == item->iOpt) // delete item (if they attached the whole stack) + *real = { 0, 0, 0, 0 }; + else // otherwise, decrement the item TODO: + real->iOpt -= item->iOpt; } int cost = pkt->iCash + 50 + 20 * attachments.size(); // attached taros + postage