From 8f79ce25de07c9e50f3e4f3f09db2094d5b4436b Mon Sep 17 00:00:00 2001 From: Mitch Freeman <65987027+neckkola@users.noreply.github.com> Date: Sat, 12 Apr 2025 16:00:15 -0300 Subject: [PATCH] Added checks for same item with price change. Client treats them all the same so all need to be updated. Also repaired max stacksize of 32767 on RoF2 --- zone/trading.cpp | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/zone/trading.cpp b/zone/trading.cpp index 3297a5bf8..f2c10f14d 100644 --- a/zone/trading.cpp +++ b/zone/trading.cpp @@ -1458,21 +1458,18 @@ void Client::BuyTraderItem(const EQApplicationPacket *app) } uint64 total_transaction_value = static_cast(in->price) * static_cast(quantity); - if (total_transaction_value > MAX_TRANSACTION_VALUE) { - Message(Chat::Red,"That would exceed the single transaction limit of %u platinum.", MAX_TRANSACTION_VALUE / 1000); + if (total_transaction_value > RoF2::constants::MAX_BAZAAR_TRANSACTION) { + Message( + Chat::Red, + "That would exceed the single transaction limit of %u platinum.", + RoF2::constants::MAX_BAZAAR_TRANSACTION / 1000 + ); TradeRequestFailed(app); return; } - // This cannot overflow assuming MAX_TRANSACTION_VALUE, checked above, is the default of 2000000000 - uint32 total_cost = in->price * quantity; + uint64 total_cost = in->price * quantity; if (!TakeMoneyFromPP(total_cost)) { - RecordPlayerEventLog( - PlayerEvent::POSSIBLE_HACK, - PlayerEvent::PossibleHackEvent{ - .message = "Attempted to buy something in bazaar but did not have enough money." - } - ); MessageString(Chat::Red, INSUFFICIENT_FUNDS); TradeRequestFailed(app); return; @@ -1488,6 +1485,7 @@ void Client::BuyTraderItem(const EQApplicationPacket *app) trader->AddMoneyToPP(total_cost, true); if (!PutItemInInventoryWithStacking(inst_copy.get())) { + AddMoneyToPP(total_cost, true); trader->TakeMoneyFromPP(total_cost, true); trader->PutItemInInventoryWithStacking(buy_inst); MessageString(Chat::Red, HOW_CAN_YOU_BUY_MORE, trader->GetCleanName()); @@ -2482,11 +2480,11 @@ void Client::SendTraderMode(BazaarTraderBarterActions status) void Client::TraderUpdateItem(const EQApplicationPacket *app) { - auto in = reinterpret_cast(app->pBuffer); - uint32 new_price = in->new_price; - auto inst = FindTraderItemByUniqueID(in->item_unique_id); + auto in = reinterpret_cast(app->pBuffer); + uint32 new_price = in->new_price; + auto inst = FindTraderItemByUniqueID(in->item_unique_id); + auto customer = entity_list.GetClientByID(GetCustomerID()); - auto customer = entity_list.GetClientByID(GetCustomerID()); if (new_price == 0) { auto result = TraderRepository::DeleteWhere(database, fmt::format("`item_unique_id` = '{}'", in->item_unique_id)); if (!result) {