[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.
This commit is contained in:
Mitch Freeman 2024-06-14 13:53:34 -03:00 committed by GitHub
parent 850053a136
commit b6b8491060
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 16 additions and 12 deletions

View File

@ -542,8 +542,8 @@ namespace RoF2
LogTrading(
"(RoF2) AddTraderToBazaarWindow action <green>[{}] trader_id <green>[{}] entity_id <green>[{}] zone_id <green>[{}]",
eq->action,
eq->entity_id,
eq->trader_id,
eq->entity_id,
eq->zone_id
);
dest->FastQueuePacket(&outapp);

View File

@ -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);

View File

@ -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);