From c5f09e846d358a62a966c2e5dd9133809dbf873b Mon Sep 17 00:00:00 2001 From: Emagi Date: Tue, 6 May 2025 09:06:58 -0400 Subject: [PATCH] Added quantity checks to trading so you can't trade over your item count --- source/WorldServer/Commands/Commands.cpp | 2 ++ source/WorldServer/Trade.cpp | 7 ++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/source/WorldServer/Commands/Commands.cpp b/source/WorldServer/Commands/Commands.cpp index bf53cdb..02b4620 100644 --- a/source/WorldServer/Commands/Commands.cpp +++ b/source/WorldServer/Commands/Commands.cpp @@ -9979,6 +9979,8 @@ void Commands::Command_TradeAddItem(Client* client, Seperator* sep) client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can't trade NO-TRADE items."); else if (result == 3) client->SimpleMessage(CHANNEL_COLOR_YELLOW, "You can't trade HEIRLOOM items."); + else if (result == 253) + client->Message(CHANNEL_COLOR_YELLOW, "You do not have enough quantity..."); else if (result == 254) client->Message(CHANNEL_COLOR_YELLOW, "You are trading with an older client with a %u trade slot restriction...", client->GetPlayer()->trade->MaxSlots()); else if (result == 255) diff --git a/source/WorldServer/Trade.cpp b/source/WorldServer/Trade.cpp index da9159e..5f28dfc 100644 --- a/source/WorldServer/Trade.cpp +++ b/source/WorldServer/Trade.cpp @@ -44,7 +44,9 @@ int8 Trade::AddItemToTrade(Entity* character, Item* item, int8 quantity, int8 sl LogWrite(PLAYER__ERROR, 0, "Trade", "Player (%s) adding item (%u) to slot %u of the trade window", character->GetName(), item->details.item_id, slot); if (slot == 255) slot = GetNextFreeSlot(character); - + if(!quantity) + quantity = 1; + if (slot < 0) { LogWrite(PLAYER__ERROR, 0, "Trade", "Player (%s) tried to add an item to an invalid trade slot (%u)", character->GetName(), slot); return 255; @@ -52,6 +54,9 @@ int8 Trade::AddItemToTrade(Entity* character, Item* item, int8 quantity, int8 sl else if(slot >= trade_max_slots) { return 254; } + else if(quantity > item->details.count) { + return 253; + } Entity* other = GetTradee(character); int8 result = CheckItem(character, item, other);