mirror of
https://github.com/EQEmu/Server.git
synced 2026-05-19 13:28:25 +00:00
[Feature] Add Alternate Bazaar Search Approach (#4600)
* Add Alternate Bazaar Search This adds an alternate bazaar search allowing multinstance bazaar searching and traders above 600. Allows searches based on Bazaar Shard * Update worldserver.cpp --------- Co-authored-by: Mitch Freeman <neckkola@gmail.com> Co-authored-by: Akkadius <akkadius1@gmail.com>
This commit is contained in:
+24
-1
@@ -31,6 +31,7 @@ Bazaar::GetSearchResults(
|
||||
char_zone_instance_id
|
||||
);
|
||||
|
||||
bool convert = false;
|
||||
std::string search_criteria_trader("TRUE ");
|
||||
|
||||
if (search.search_scope == NonRoFBazaarSearchScope) {
|
||||
@@ -51,8 +52,24 @@ Bazaar::GetSearchResults(
|
||||
);
|
||||
}
|
||||
else if (search.trader_id > 0) {
|
||||
search_criteria_trader.append(fmt::format(" AND trader.char_id = {}", search.trader_id));
|
||||
if (RuleB(Bazaar, UseAlternateBazaarSearch)) {
|
||||
if (search.trader_id >= TraderRepository::TRADER_CONVERT_ID) {
|
||||
convert = true;
|
||||
search_criteria_trader.append(fmt::format(
|
||||
" AND trader.char_zone_id = {} AND trader.char_zone_instance_id = {}",
|
||||
Zones::BAZAAR,
|
||||
search.trader_id - TraderRepository::TRADER_CONVERT_ID)
|
||||
);
|
||||
}
|
||||
else {
|
||||
search_criteria_trader.append(fmt::format(" AND trader.char_id = {}", search.trader_id));
|
||||
}
|
||||
}
|
||||
else {
|
||||
search_criteria_trader.append(fmt::format(" AND trader.char_id = {}", search.trader_id));
|
||||
}
|
||||
}
|
||||
|
||||
if (search.min_cost != 0) {
|
||||
search_criteria_trader.append(fmt::format(" AND trader.item_cost >= {}", search.min_cost * 1000));
|
||||
}
|
||||
@@ -355,6 +372,12 @@ Bazaar::GetSearchResults(
|
||||
}
|
||||
|
||||
LogTradingDetail("Found item [{}] meeting search criteria.", r.item_name);
|
||||
if (RuleB(Bazaar, UseAlternateBazaarSearch)) {
|
||||
if (convert || (r.trader_zone_id == Zones::BAZAAR && r.trader_zone_instance_id != char_zone_instance_id)) {
|
||||
r.trader_id = TraderRepository::TRADER_CONVERT_ID + r.trader_zone_instance_id;
|
||||
}
|
||||
}
|
||||
|
||||
all_entries.push_back(r);
|
||||
}
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
|
||||
class TraderRepository : public BaseTraderRepository {
|
||||
public:
|
||||
static constexpr uint32 TRADER_CONVERT_ID = 4000000000;
|
||||
|
||||
struct DistinctTraders_Struct {
|
||||
uint32 trader_id;
|
||||
@@ -40,7 +41,11 @@ public:
|
||||
int32 char_zone_instance_id
|
||||
);
|
||||
|
||||
static BulkTraders_Struct GetDistinctTraders(Database &db, uint32 char_zone_instance_id, uint32 max_results)
|
||||
static BulkTraders_Struct GetDistinctTraders(
|
||||
Database &db,
|
||||
uint32 char_zone_instance_id,
|
||||
uint32 max_results = std::numeric_limits<uint32>::max()
|
||||
)
|
||||
{
|
||||
BulkTraders_Struct all_entries{};
|
||||
std::vector<DistinctTraders_Struct> distinct_traders;
|
||||
@@ -49,7 +54,9 @@ public:
|
||||
"SELECT DISTINCT(t.char_id), t.char_zone_id, t.char_zone_instance_id, t.char_entity_id, c.name "
|
||||
"FROM trader AS t "
|
||||
"JOIN character_data AS c ON t.char_id = c.id "
|
||||
"ORDER BY t.char_zone_instance_id = {} DESC LIMIT {};",
|
||||
"WHERE t.char_zone_instance_id = {} "
|
||||
"ORDER BY t.char_zone_instance_id ASC "
|
||||
"LIMIT {}",
|
||||
char_zone_instance_id,
|
||||
max_results)
|
||||
);
|
||||
@@ -227,6 +234,37 @@ public:
|
||||
|
||||
return DeleteWhere(db, fmt::format("`id` IN({})", Strings::Implode(",", delete_ids)));
|
||||
}
|
||||
|
||||
static DistinctTraders_Struct GetTraderByInstanceAndSerialnumber(
|
||||
Database &db,
|
||||
uint32 instance_id,
|
||||
const char *serial_number
|
||||
)
|
||||
{
|
||||
DistinctTraders_Struct trader{};
|
||||
|
||||
auto query = fmt::format(
|
||||
"SELECT t.id, t.char_id, c.name "
|
||||
"FROM trader AS t "
|
||||
"JOIN character_data AS c ON c.id = t.char_id "
|
||||
"WHERE t.char_zone_id = 151 AND t.char_zone_instance_id = {} AND t.item_sn = {} LIMIT 1",
|
||||
instance_id,
|
||||
serial_number
|
||||
);
|
||||
|
||||
auto results = db.QueryDatabase(query);
|
||||
|
||||
if (results.RowCount() == 0) {
|
||||
return trader;
|
||||
}
|
||||
|
||||
auto row = results.begin();
|
||||
std::string name = row[2];
|
||||
trader.trader_id = Strings::ToUnsignedInt(row[1]);
|
||||
trader.trader_name = row[2] ? row[2] : "";
|
||||
|
||||
return trader;
|
||||
}
|
||||
};
|
||||
|
||||
#endif //EQEMU_TRADER_REPOSITORY_H
|
||||
|
||||
@@ -830,6 +830,7 @@ RULE_REAL(Bazaar, ParcelDeliveryCostMod, 0.20, "Cost of parcel delivery for a ba
|
||||
RULE_INT(Bazaar, VoucherDeliveryCost, 200, "Number of vouchers for direct delivery for a bazaar purchase. Default is 200 vouchers. RoF+ Only.")
|
||||
RULE_BOOL(Bazaar, EnableParcelDelivery, true, "Enable bazaar purchases via parcel delivery. Default is True.")
|
||||
RULE_INT(Bazaar, MaxBuyerInventorySearchResults, 200, "Maximum number of search results when a Buyer searches the global item list. Default is 200. RoF+ Only.")
|
||||
RULE_BOOL(Bazaar, UseAlternateBazaarSearch, false, "Allows the bazaar search window to search across bazaar shards. Default is false.")
|
||||
RULE_CATEGORY_END()
|
||||
|
||||
RULE_CATEGORY(Mail)
|
||||
|
||||
Reference in New Issue
Block a user