Skip to content

Commit

Permalink
Core/ItemHandler: fix selling items over gold limit (#27930)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
okfok committed Apr 27, 2022
1 parent 0d86727 commit d0b8fb8
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/server/game/Handlers/ItemHandler.cpp
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
}
Expand Down

0 comments on commit d0b8fb8

Please sign in to comment.