Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature] Add RoF2 Bazaar Support #4315

Merged
merged 29 commits into from
May 26, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
5e9051e
Add RoF2 Bazaar Support
neckkola Mar 10, 2024
16fd6f8
Add augments to Trader Items
neckkola May 12, 2024
751576f
Cleanup
neckkola May 13, 2024
d64712e
Update PlayerProfile for correct char_id in trader transactions. Fur…
neckkola May 16, 2024
3397109
Add parcel delivery price functionality
neckkola May 18, 2024
b1f4c2d
Add RoF support for bazaar window outside of bazaar with parcel delivery
neckkola May 20, 2024
ea7ec81
Further Testing and ActiveTransaction added
neckkola May 21, 2024
58b4abe
Cleanup and Formatting updates
neckkola May 21, 2024
6760479
Update database manifest for the trader table against default peq tra…
neckkola May 22, 2024
fac3f59
Logs and formatting
Akkadius May 22, 2024
1443aec
Update bazaarsearch to be content_db aware
neckkola May 23, 2024
346415e
Fix crash
Akkadius May 23, 2024
a1f8f32
Simplify search
Akkadius May 23, 2024
ba2665e
Search fixes
Akkadius May 23, 2024
07733f2
Push up more search logging
Akkadius May 23, 2024
188950b
More search fixes
Akkadius May 23, 2024
257c5d4
Formatting
Akkadius May 23, 2024
b598d60
Update trader_repository.h
Akkadius May 23, 2024
800d6fb
Add Rule for Bazaar Parcel Delivery
neckkola May 24, 2024
d4e6413
Fix crash
Akkadius May 24, 2024
5513851
Update Bazaar Search
neckkola May 25, 2024
b1eb268
Formatting
neckkola May 25, 2024
f8ee361
Push
Akkadius May 25, 2024
46cc62c
Update bazaarsearch to include all stats that are available in RoF2
neckkola May 25, 2024
f7a5d04
Update BazaarSearch
neckkola May 26, 2024
63c3963
Formatting
neckkola May 26, 2024
b1201e2
Final updates to BazaarSearch
neckkola May 26, 2024
2954388
Add Titanium functionality correct ItemType Search
neckkola May 26, 2024
a5fe46c
Close off for loops
Akkadius May 26, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Search fixes
  • Loading branch information
Akkadius authored and neckkola committed May 26, 2024
commit ba2665e1a18969e04a157de7d60e5fd5be67c0cf
59 changes: 40 additions & 19 deletions common/repositories/trader_repository.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,27 @@ class TraderRepository : public BaseTraderRepository {
static std::vector<BazaarSearchResultsFromDB_Struct>
GetBazaarSearchResults(
SharedDatabase &db,
SharedDatabase &in_content_db,
BazaarSearchCriteria_Struct search,
uint32 char_zone_id
)
{

LogTrading(
"Searching for items with search criteria - item_name [{}] min_cost [{}] max_cost [{}] min_level [{}] max_level [{}] max_results [{}] prestige [{}] augment [{}] trader_entity_id [{}] trader_id [{}] search_scope [{}] char_zone_id [{}]",
search.item_name,
search.min_cost,
search.max_cost,
search.min_level,
search.max_level,
search.max_results,
search.prestige,
search.augment,
search.trader_entity_id,
search.trader_id,
search.search_scope,
char_zone_id
);

std::string search_criteria_trader("TRUE ");

if (search.search_scope == UFBazaarSearchScope) {
Expand Down Expand Up @@ -83,7 +99,8 @@ class TraderRepository : public BaseTraderRepository {
);

std::vector<BazaarSearchResultsFromDB_Struct> all_entries;
auto results = db.QueryDatabase(query);

auto results = db.QueryDatabase(query);

if (!results.Success()) {
return all_entries;
Expand All @@ -104,13 +121,12 @@ class TraderRepository : public BaseTraderRepository {
bool condition;
};

results = db.QueryDatabase(query);
for (auto row: results) {
BazaarSearchResultsFromDB_Struct r{};

r.item_id = Strings::ToInt(row[2]);

auto item = in_content_db.GetItem(r.item_id);
auto item = db.GetItem(r.item_id);
if (!item) {
continue;
}
Expand All @@ -131,8 +147,9 @@ class TraderRepository : public BaseTraderRepository {
r.trader_name = fmt::format("{:.63}\0", std::string(row[10]).c_str());

LogTradingDetail(
"Searching against item [{}] for trader [{}]",
"Searching against item [{}] ({}) for trader [{}]",
item->Name,
item->ID,
r.trader_name
);

Expand Down Expand Up @@ -179,24 +196,23 @@ class TraderRepository : public BaseTraderRepository {
{EQ::item::ItemType::ItemTypeFocusEffect, item->Focus.Effect > 0},
};

bool found = false;

bool met_filter = false;
bool has_filter = false;
for (auto &i: item_search_types) {
if (i.type == search.type && !i.condition) {
continue;
}
if (i.type == search.type && i.condition) {
found = true;
break;
if (i.type == search.type) {
has_filter = true;
if (i.condition) {
met_filter = true;
break;
}
}
}

if (!found) {
if (search.type && search.type != item->ItemType) {
continue;
}
if (has_filter && !met_filter) {
continue;
}

// TODO: Add catch-all item type filter for specific item types

// item additive searches
std::vector<AddititiveSearchCriteria> item_additive_searches = {
{
Expand Down Expand Up @@ -229,12 +245,17 @@ class TraderRepository : public BaseTraderRepository {
// },
};

bool should_add = false;
for (auto &i: item_additive_searches) {
if (i.should_check && !i.condition) {
if (i.should_check && i.condition) {
should_add = true;
continue;
}
}

if (!should_add) {
continue;
}

all_entries.push_back(r);
}
Expand Down
6 changes: 4 additions & 2 deletions zone/trading.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1297,7 +1297,9 @@ EQ::ItemInstance *Client::FindTraderItemBySerialNumber(int32 SerialNumber)
}
}
}
LogTrading("Client::FindTraderItemBySerialNumber Couldn't find item! Serial No. was [{}]", SerialNumber);

LogTrading("Couldn't find item! Serial No. was [{}]", SerialNumber);

return nullptr;
}

Expand Down Expand Up @@ -1769,7 +1771,7 @@ void Client::SendBazaarWelcome()

void Client::DoBazaarSearch(BazaarSearchCriteria_Struct search_criteria)
{
auto results = TraderRepository::GetBazaarSearchResults(database, content_db, search_criteria, GetZoneID());
auto results = TraderRepository::GetBazaarSearchResults(database, search_criteria, GetZoneID());

if (results.empty()) {
SendBazaarDone(GetID());
Expand Down