[Feature] Add RoF2 Bazaar Support (#4315)

* Add RoF2 Bazaar Support

Enable RoF2 bazaar features

* Add augments to Trader Items

* Cleanup

Cleanup of formatting and unused functions

* Update PlayerProfile for correct char_id in trader transactions.  Further cleanup.

* Add parcel delivery price functionality

Add parcel delivery price functionality via rules and new delivery cost struct.

* Add RoF support for bazaar window outside of bazaar with parcel delivery

* Further Testing and ActiveTransaction added

Further testing and a few fixes and messages added.  Add active transaction check to ensure two clients cannot purchase from the bazaar window at the same time

* Cleanup and Formatting updates

Cleanup and Formatting updates

* Update database manifest for the trader table against default peq trader table

* Logs and formatting

* Update bazaarsearch to be content_db aware

* Fix crash

* Simplify search

* Search fixes

* Push up more search logging

* More search fixes

* Formatting

* Update trader_repository.h

* Add Rule for Bazaar Parcel Delivery

Add a rule Bazaar:EnableParcelDelivery to enable/disable bazaar parcel delivery.  Default is True.

* Fix crash

* Update Bazaar Search

Adds/Tested bazaar search with move to content_db
- race, class, money, number of returned items, stats, name, slot, level, traders, local traders, specific trader.
Outstanding
- type, more stats to add (heroic, etc)

* Formatting

* Push

* Update bazaarsearch to include all stats that are available in RoF2

* Update BazaarSearch

Updates the bazaar search for item types.  They should be working as per RoF2+ types.

* Formatting

* Final updates to BazaarSearch

Add search by augmentation slots available on the item.
This enables all but Prestige, which I believe are not implemented yet.

* Add Titanium functionality correct ItemType Search

Add Titanium /trader /bazaar functionality.
Added itemtype=armor bazaar search.  It was missed in the search work

* Close off for loops

---------

Co-authored-by: Akkadius <akkadius1@gmail.com>
This commit is contained in:
Mitch Freeman
2024-05-26 17:38:25 -03:00
committed by GitHub
parent d767217461
commit fc79614fac
51 changed files with 4793 additions and 2258 deletions
+92 -4
View File
@@ -3915,10 +3915,98 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p)
}
break;
}
default: {
LogInfo("Unknown ZS Opcode [{}] size [{}]", (int)pack->opcode, pack->size);
break;
}
case ServerOP_TraderMessaging: {
auto in = (TraderMessaging_Struct *) pack->pBuffer;
for (auto const &c: entity_list.GetClientList()) {
if (c.second->ClientVersion() >= EQ::versions::ClientVersion::RoF2) {
auto outapp = new EQApplicationPacket(OP_BecomeTrader, sizeof(BecomeTrader_Struct));
auto out = (BecomeTrader_Struct *) outapp->pBuffer;
switch (in->action) {
case TraderOn: {
out->action = AddTraderToBazaarWindow;
break;
}
case TraderOff: {
out->action = RemoveTraderFromBazaarWindow;
break;
}
default: {
out->action = 0;
}
}
out->entity_id = in->entity_id;
out->zone_id = in->zone_id;
out->trader_id = in->trader_id;
strn0cpy(out->trader_name, in->trader_name, sizeof(out->trader_name));
c.second->QueuePacket(outapp);
safe_delete(outapp);
}
if (zone && zone->GetZoneID() == Zones::BAZAAR) {
if (in->action == TraderOn) {
c.second->SendBecomeTrader(TraderOn, in->entity_id);
}
else {
c.second->SendBecomeTrader(TraderOff, in->entity_id);
}
}
}
break;
}
case ServerOP_BazaarPurchase: {
auto in = (BazaarPurchaseMessaging_Struct *) pack->pBuffer;
auto trader_pc = entity_list.GetClientByCharID(in->trader_buy_struct.trader_id);
if (!trader_pc) {
LogTrading("Request trader_id <red>[{}] could not be found in zone_id <red>[{}]",
in->trader_buy_struct.trader_id,
zone->GetZoneID()
);
return;
}
auto item_sn = Strings::ToUnsignedBigInt(in->trader_buy_struct.serial_number);
auto outapp = std::make_unique<EQApplicationPacket>(OP_Trader, sizeof(TraderBuy_Struct));
auto data = (TraderBuy_Struct *) outapp->pBuffer;
memcpy(data, &in->trader_buy_struct, sizeof(TraderBuy_Struct));
if (trader_pc->ClientVersion() < EQ::versions::ClientVersion::RoF) {
data->price = in->trader_buy_struct.price * in->trader_buy_struct.quantity;
}
TraderRepository::UpdateQuantity(
database,
trader_pc->CharacterID(),
item_sn,
in->item_quantity_available - in->trader_buy_struct.quantity
);
TraderRepository::UpdateActiveTransaction(database, in->id, false);
trader_pc->RemoveItemBySerialNumber(item_sn, in->trader_buy_struct.quantity);
trader_pc->AddMoneyToPP(in->trader_buy_struct.price * in->trader_buy_struct.quantity, true);
trader_pc->QueuePacket(outapp.get());
if (player_event_logs.IsEventEnabled(PlayerEvent::TRADER_SELL)) {
auto e = PlayerEvent::TraderSellEvent{
.item_id = in->trader_buy_struct.item_id,
.item_name = in->trader_buy_struct.item_name,
.buyer_id = in->buyer_id,
.buyer_name = in->trader_buy_struct.buyer_name,
.price = in->trader_buy_struct.price,
.charges = in->trader_buy_struct.quantity,
.total_cost = (in->trader_buy_struct.price * in->trader_buy_struct.quantity),
.player_money_balance = trader_pc->GetCarriedMoney(),
};
RecordPlayerEventLogWithClient(trader_pc, PlayerEvent::TRADER_SELL, e);
}
break;
}
default: {
LogInfo("Unknown ZS Opcode [{}] size [{}]", (int) pack->opcode, pack->size);
break;
}
}
}