From b6b8491060fddde255de889a1ff1ed089c706bff Mon Sep 17 00:00:00 2001 From: Mitch Freeman <65987027+neckkola@users.noreply.github.com> Date: Fri, 14 Jun 2024 13:53:34 -0300 Subject: [PATCH] [Bug Fix] Fix for players having empty bazaar window dropdown list, even though trader is tagged as a trader. (#4391) * Potential fix for players having empty bazaar window dropdown list, even though trader is tagged as a trader. * Update the truncate of the trader table to avoid inappropriate deletions if an instance of bazaar was started. --- common/patches/rof2.cpp | 2 +- zone/trading.cpp | 19 +++++++++++++++---- zone/zone.cpp | 7 ------- 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/common/patches/rof2.cpp b/common/patches/rof2.cpp index d853156f4..5d8ebcd3e 100644 --- a/common/patches/rof2.cpp +++ b/common/patches/rof2.cpp @@ -542,8 +542,8 @@ namespace RoF2 LogTrading( "(RoF2) AddTraderToBazaarWindow action [{}] trader_id [{}] entity_id [{}] zone_id [{}]", eq->action, - eq->entity_id, eq->trader_id, + eq->entity_id, eq->zone_id ); dest->FastQueuePacket(&outapp); diff --git a/zone/trading.cpp b/zone/trading.cpp index a498ace09..33b9ac31b 100644 --- a/zone/trading.cpp +++ b/zone/trading.cpp @@ -1049,6 +1049,10 @@ void Client::TraderStartTrader(const EQApplicationPacket *app) //Check inventory for no-trade items for (auto const &i: inv->serial_number) { + if (i <= 0) { + continue; + } + auto inst = FindTraderItemBySerialNumber(i); if (inst) { if (inst->GetItem() && inst->GetItem()->NoDrop == 0) { @@ -1067,7 +1071,16 @@ void Client::TraderStartTrader(const EQApplicationPacket *app) } for (uint32 i = 0; i < max_items; i++) { + if (inv->serial_number[i] <= 0) { + continue; + } + auto inst = FindTraderItemBySerialNumber(inv->serial_number[i]); + if (!inst) { + trade_items_valid = false; + break; + } + auto it = std::find(std::begin(in->serial_number), std::end(in->serial_number), inv->serial_number[i]); if (inst && it != std::end(in->serial_number)) { inst->SetPrice(in->item_cost[i]); @@ -1106,18 +1119,16 @@ void Client::TraderStartTrader(const EQApplicationPacket *app) trade_items_valid = false; continue; } - else if (!in->serial_number[i]) { - break; - } } if (!trade_items_valid) { - Message(Chat::Red, "You are not able to become a trader at this time."); + Message(Chat::Red, "You are not able to become a trader at this time. Invalid item found."); TraderEndTrader(); safe_delete(inv); return; } + TraderRepository::DeleteWhere(database, fmt::format("`char_id` = '{}';", CharacterID())); TraderRepository::ReplaceMany(database, trader_items); safe_delete(inv); diff --git a/zone/zone.cpp b/zone/zone.cpp index 88edb4757..1cb26640c 100644 --- a/zone/zone.cpp +++ b/zone/zone.cpp @@ -1194,13 +1194,6 @@ bool Zone::Init(bool is_static) { LoadZoneObjects(); LoadZoneDoors(); LoadZoneBlockedSpells(); - - //clear trader items if we are loading the bazaar - if (strncasecmp(short_name, "bazaar", 6) == 0) { - TraderRepository::Truncate(database); - database.DeleteBuyLines(0); - } - LoadVeteranRewards(); LoadAlternateCurrencies(); LoadNPCEmotes(&npc_emote_list);