From d0b8fb87f29c6fe5a100c4f1f85cad2b349d9619 Mon Sep 17 00:00:00 2001 From: okfok <44704482+okfok@users.noreply.github.com> Date: Wed, 27 Apr 2022 15:35:22 +0300 Subject: Core/ItemHandler: fix selling items over gold limit (#27930) * Core/ItemHandler: fix selling items over gold limit * Core/ItemHandler: fix selling items over gold limit codestyle edit * Core/ItemHandler: move code, fix condition * codestyle --- src/server/game/Handlers/ItemHandler.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/server/game/Handlers/ItemHandler.cpp b/src/server/game/Handlers/ItemHandler.cpp index be942a06389..407f501438e 100644 --- a/src/server/game/Handlers/ItemHandler.cpp +++ b/src/server/game/Handlers/ItemHandler.cpp @@ -442,6 +442,14 @@ void WorldSession::HandleSellItemOpcode(WorldPacket& recvData) { if (pProto->SellPrice > 0) { + uint32 money = pProto->SellPrice * count; + if (_player->GetMoney() >= MAX_MONEY_AMOUNT - money) // prevent exceeding gold limit + { + _player->SendEquipError(EQUIP_ERR_TOO_MUCH_GOLD, nullptr, nullptr); + _player->SendSellError(SELL_ERR_UNK, creature, itemguid, 0); + return; + } + if (count < pItem->GetCount()) // need split items { Item* pNewItem = pItem->CloneItem(count, _player); @@ -470,7 +478,6 @@ void WorldSession::HandleSellItemOpcode(WorldPacket& recvData) _player->AddItemToBuyBackSlot(pItem); } - uint32 money = pProto->SellPrice * count; _player->ModifyMoney(money); _player->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_MONEY_FROM_VENDORS, money); } -- cgit v1.2.3