From f26b7a4adc83ff6bd390948ac0593b05a54cefec Mon Sep 17 00:00:00 2001 From: Drajor Date: Wed, 8 Mar 2017 06:22:17 +1000 Subject: [PATCH] Hacky fix for quantity wrapping when stacked items are sold that have a quantity greater than 255. A better solution will need to implemented long term --- zone/client_packet.cpp | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/zone/client_packet.cpp b/zone/client_packet.cpp index d7d8bdd0e..d4404247e 100644 --- a/zone/client_packet.cpp +++ b/zone/client_packet.cpp @@ -12567,8 +12567,25 @@ void Client::Handle_OP_ShopPlayerSell(const EQApplicationPacket *app) // Now remove the item from the player, this happens regardless of outcome if (!inst->IsStackable()) this->DeleteItemInInventory(mp->itemslot, 0, false); - else - this->DeleteItemInInventory(mp->itemslot, mp->quantity, false); + else { + // HACK: DeleteItemInInventory uses int8 for quantity type. There is no consistent use of types in code in this path so for now iteratively delete from inventory. + if (mp->quantity > 255) { + uint32 temp = mp->quantity; + while (temp > 255 && temp != 0) { + // Delete chunks of 255 + this->DeleteItemInInventory(mp->itemslot, 255, false); + temp -= 255; + } + if (temp != 0) { + // Delete remaining + this->DeleteItemInInventory(mp->itemslot, temp, false); + } + } + else { + this->DeleteItemInInventory(mp->itemslot, mp->quantity, false); + } + } + //This forces the price to show up correctly for charged items. if (inst->IsCharged())