Comment_Review

Updates based on comment review.
This commit is contained in:
Mitch Freeman 2025-07-01 21:22:59 -03:00
parent 3676f16dc3
commit a0f701686b
15 changed files with 30 additions and 75 deletions

View File

@ -3813,7 +3813,7 @@ struct ClickTraderNew_Struct {
}
};
struct GetItems2_Struct {
struct GetBazaarItems_Struct {
uint64 items[EQ::invtype::BAZAAR_SIZE];
std::string serial_number[EQ::invtype::BAZAAR_SIZE];
uint32 charges[EQ::invtype::BAZAAR_SIZE];

View File

@ -247,7 +247,6 @@ namespace EQ
void SetSerialNumber(int32 id) { m_SerialNumber = id; }
const std::string &GetSerialNumber2() const { return m_unique_id; }
const std::string &GetUniqueID() const { return m_unique_id; }
//std::string &GetSerialNumber2() const { return m_serial_number2; }
void SetUniqueID(std::string sn) { m_unique_id = std::move(sn); }
void CreateUniqueID() const { m_unique_id = GenerateUniqueID(); }

View File

@ -6354,14 +6354,12 @@ namespace RoF2
IN_str(buyer_name);
IN_str(seller_name);
IN_str(item_name);
//IN_str(serial_number);
strn0cpy(emu->item_unique_id, eq->item_unique_id, sizeof(emu->item_unique_id));
FINISH_DIRECT_DECODE();
break;
}
default: {
//LogTradingDetail("(RoF2) Unhandled action <red>[{}]", action);
}
return;
}
@ -6475,12 +6473,6 @@ namespace RoF2
hdr.unknown000[16] = '\0';
}
// strn0cpy(
// hdr.unknown000,
// inst->GetSerialNumber2().empty() ? "0000000000000000" : inst->GetSerialNumber2().c_str(),
// sizeof(hdr.unknown000)
// );
//hdr.unknown000[16] = '\0';
hdr.stacksize = 1;

View File

@ -228,7 +228,6 @@ namespace Titanium
VARSTRUCT_ENCODE_TYPE(uint32, bufptr, row->trader_entity_id);
bufptr += 4;
VARSTRUCT_ENCODE_TYPE(int32, bufptr, row->item_id);
//FIX VARSTRUCT_ENCODE_TYPE(int32, bufptr, row->serial_number);
bufptr += 4;
if (row->stackable) {
strn0cpy(

View File

@ -338,7 +338,6 @@ namespace UF
bufptr += 64;
VARSTRUCT_ENCODE_TYPE(uint32, bufptr, 1);
VARSTRUCT_ENCODE_TYPE(int32, bufptr, row->item_id);
//FIX VARSTRUCT_ENCODE_TYPE(int32, bufptr, row->serial_number);
bufptr += 4;
if (row->stackable) {
strn0cpy(

View File

@ -187,7 +187,7 @@ public:
return false;
}
auto results = GetWhere(db, fmt::format("`char_id` = '{}' AND `char_entity_id` = '{}' LIMIT 1;", char_id, old_entity_id));
auto results = GetWhere(db, fmt::format("`char_id` = {} AND `char_entity_id` = {} LIMIT 1;", char_id, old_entity_id));
if (results.empty()) {
return false;

View File

@ -125,7 +125,7 @@ public:
items = GetWhere(
db,
fmt::format(
"character_id = '{}' AND item_id = '{}'",
"character_id = {} AND item_id = {}",
character_id,
item_id
)
@ -135,7 +135,7 @@ public:
items = GetWhere(
db,
fmt::format(
"character_id = '{}' AND item_id = '{}' AND item_charges = '{}'",
"character_id = {} AND item_id = {} AND item_charges = {}",
character_id,
item_id,
item_charges
@ -161,7 +161,7 @@ public:
auto query = fmt::format(
"SELECT t.character_id, t.item_id, t.item_unique.id, t.charges, t.item_cost, t.slot_id, t.entity_id FROM trader AS t "
"WHERE t.entity_id = '{}' AND t.item_id = '{}' AND t.item_cost = '{}' "
"WHERE t.entity_id = {} AND t.item_id = {} AND t.item_cost = {} "
"LIMIT 1;",
trader_id,
item_id,
@ -207,7 +207,7 @@ public:
std::vector<Trader> all_entries{};
const auto query = fmt::format(
"UPDATE trader t1 SET t1.`item_cost` = '{}', t1.`listing_date` = FROM_UNIXTIME({}) WHERE t1.`item_id` = "
"UPDATE trader t1 SET t1.`item_cost` = {}, t1.`listing_date` = FROM_UNIXTIME({}) WHERE t1.`item_id` = "
"(SELECT t2.`item_id` FROM trader t2 WHERE t2.`item_unique_id` = '{}')",
price,
time(nullptr),
@ -324,28 +324,6 @@ public:
{
std::vector<BazaarTraderSearch_Struct> all_entries{};
// auto query_2 = fmt::format(
// "WITH ranked_trader_items AS ("
// "SELECT trader.id, trader.character_id, trader.item_id, trader.item_unique_id, trader.augment_one, "
// "trader.augment_two, trader.augment_three, trader.augment_four, trader.augment_five, trader.augment_six, "
// "trader.item_charges, trader.item_cost, trader.slot_id, trader.char_entity_id, trader.char_zone_id, "
// "trader.char_zone_instance_id, trader.active_transaction, c.`name`, "
// "items.name AS n1, items.stackable, items.icon, {}, "
// "ROW_NUMBER() OVER (PARTITION BY trader.character_id) AS row_num "
// "FROM trader "
// "INNER JOIN character_data AS c ON trader.character_id = c.id "
// "JOIN peq642024_content.items AS items ON trader.item_id = items.id "
// "WHERE items.`name` LIKE '%{}%' AND {} AND {}"
// ") "
// "SELECT * FROM ranked_trader_items "
// "WHERE row_num <= '{}';",
// field_criteria_items,
// Strings::Escape(name),
// where_criteria_items,
// search_criteria_trader,
// max_results
// );
auto query = fmt::format(
"SELECT trader.id, trader.character_id, trader.item_id, trader.item_unique_id, trader.augment_one, "
"trader.augment_two, trader.augment_three, trader.augment_four, trader.augment_five, trader.augment_six, "
@ -385,10 +363,6 @@ public:
e.trader.char_zone_instance_id = row[15] ? static_cast<int32_t>(atoi(row[15])) : 0;
e.trader.active_transaction = row[16] ? static_cast<uint8_t>(strtoul(row[16], nullptr, 10)) : 0;
e.trader_name = row[17] ? row[17] : std::string("");
// e.name = row[18] ? row[18] : "";
// e.stackable = atoi(row[19]) ? true : false;
// e.icon = row[20] ? static_cast<int32_t>(atoi(row[20])) : 0;
// e.stats = row[21] ? static_cast<int32_t>(atoi(row[21])) : 0;
all_entries.push_back(e);
}
@ -401,7 +375,7 @@ public:
auto trader_query = fmt::format(
"SELECT t.id, t.character_id, t.char_zone_id, t.char_zone_instance_id "
"FROM trader AS t "
"WHERE t.character_id IN(SELECT c.id FROM character_data AS c WHERE c.account_id = '{}') "
"WHERE t.character_id IN(SELECT c.id FROM character_data AS c WHERE c.account_id = {}) "
"LIMIT 1;",
account_id
);
@ -409,7 +383,7 @@ public:
auto buyer_query = fmt::format(
"SELECT t.id, t.char_id, t.char_zone_id, t.char_zone_instance_id "
"FROM buyer AS t "
"WHERE t.char_id IN(SELECT c.id FROM character_data AS c WHERE c.account_id = '{}') "
"WHERE t.char_id IN(SELECT c.id FROM character_data AS c WHERE c.account_id = {}) "
"LIMIT 1;",
account_id
);
@ -440,4 +414,5 @@ public:
}
};
#endif //EQEMU_TRADER_REPOSITORY_H
#endif
//EQEMU_TRADER_REPOSITORY_H

View File

@ -12,4 +12,4 @@ OP_LoginExpansionPacketData=0x0031
OP_EnterChat=0x000f
OP_PollResponse=0x0011
OP_CancelOfflineTrader=0x0016
OP_CancelOfflineTraderResponse=0x0030
OP_CancelOfflineTraderResponse=0x0030

View File

@ -35,6 +35,7 @@
#include "wguild_mgr.h"
#include "../common/zone_store.h"
#include <set>
#include "../zone/string_ids.h"
uint32 numplayers = 0; //this really wants to be a member variable of ClientList...
@ -799,10 +800,10 @@ void ClientList::SendWhoAll(uint32 fromid,const char* to, int16 admin, Who_All_S
continue;
}
else if (cle->GetTrader()) {
rankstring = 12315;
rankstring = TRADER;
}
else if (cle->GetBuyer()) {
rankstring = 6056;
rankstring = BUYER;
}
else if (cle->GetGM()) {
if (cle->Admin() >= AccountStatus::GMImpossible) {

View File

@ -314,7 +314,6 @@ public:
void Trader_CustomerBrowsing(Client *Customer);
void TraderEndTrader();
//void TraderPriceUpdate(const EQApplicationPacket *app);
void TraderUpdateItem(const EQApplicationPacket *app);
void SendBazaarDone(uint32 trader_id);
void SendBulkBazaarTraders();
@ -351,7 +350,7 @@ public:
void SendTraderPacket(Client* trader, uint32 Unknown72 = 51);
void SendBuyerPacket(Client* Buyer);
void SendBuyerToBarterWindow(Client* buyer, uint32 action);
GetItems2_Struct* GetTraderItems();
GetBazaarItems_Struct* GetTraderItems();
void SendBazaarWelcome();
void SendBarterWelcome();
void DyeArmor(EQ::TintProfile* dye);

View File

@ -860,7 +860,7 @@ void Client::CompleteConnect()
}
auto offline_transactions_trader = CharacterOfflineTransactionsRepository::GetWhere(
database, fmt::format("`character_id` = '{}' AND `type` = '{}'", CharacterID(), TRADER_TRANSACTION)
database, fmt::format("`character_id` = {} AND `type` = {}", CharacterID(), TRADER_TRANSACTION)
);
if (offline_transactions_trader.size() > 0) {
Message(Chat::Yellow, "You sold the following items while in offline trader mode:");
@ -884,7 +884,7 @@ void Client::CompleteConnect()
}
auto offline_transactions_buyer = CharacterOfflineTransactionsRepository::GetWhere(
database, fmt::format("`character_id` = '{}' AND `type` = '{}'", CharacterID(), BUYER_TRANSACTION)
database, fmt::format("`character_id` = {} AND `type` = {}", CharacterID(), BUYER_TRANSACTION)
);
if (offline_transactions_buyer.size() > 0) {
Message(Chat::Yellow, "You bought the following items while in offline buyer mode:");
@ -903,7 +903,7 @@ void Client::CompleteConnect()
}
CharacterOfflineTransactionsRepository::DeleteWhere(
database, fmt::format("`character_id` = '{}' AND `type` = '{}'", CharacterID(), BUYER_TRANSACTION)
database, fmt::format("`character_id` = {} AND `type` = {}", CharacterID(), BUYER_TRANSACTION)
);
}
@ -15506,7 +15506,6 @@ void Client::Handle_OP_Trader(const EQApplicationPacket *app)
break;
}
default: {
//LogTradingDetail("Unknown size for OP_Trader: [{}]", app->size);
}
}
}

View File

@ -651,7 +651,6 @@ bool Client::SummonItem(uint32 item_id, int16 charges, uint32 aug1, uint32 aug2,
// put item into inventory
if (to_slot == EQ::invslot::slotCursor) {
PushItemOnCursor(*inst, true);
//SendItemPacket(EQ::invslot::slotCursor, inst, ItemPacketLimbo);
} else {
PutItemInInventory(to_slot, *inst, true);
}

View File

@ -416,6 +416,7 @@
#define MAX_ACTIVE_TASKS 6010 //Sorry %3, you already have the maximum number of active tasks.
#define TASK_REQUEST_COOLDOWN_TIMER 6011 //Sorry, %3, but you can't request another task for %4 minutes and %5 seconds.
#define FORAGE_MASTERY 6012 //Your forage mastery has enabled you to find something else!
#define BUYER 6056 //BUYER
#define BUYER_WELCOME 6065 //There are %1 Buyers waiting to purchase your loot. Type /barter to search for them, or use /buyer to set up your own Buy Lines.
#define BUYER_GREETING 6070 //%1 greets you, '%2'
#define GUILD_BANK_CANNOT_DEPOSIT 6097 // Cannot deposit this item. Containers must be empty, and only one of each LORE and no NO TRADE or TEMPORARY items may be deposited.
@ -543,6 +544,7 @@
#define GROUP_INVITEE_NOT_FOUND 12268 //You must target a player or use /invite <name> to invite someone to your group.
#define GROUP_INVITEE_SELF 12270 //12270 You cannot invite yourself.
#define ALREADY_IN_PARTY 12272 //That person is already in your party.
#define TRADER 12315 //TRADER
#define TALKING_TO_SELF 12323 //Talking to yourself again?
#define SPLIT_NO_GROUP 12328 //You are not in a group! Keep it all.
#define NO_LONGER_HIDDEN 12337 //You are no longer hidden.

View File

@ -1085,10 +1085,8 @@ EQ::ItemInstance *Client::FindTraderItemByUniqueID(std::string &unique_id)
// we already have the parent bag and a contents iterator..why not just iterate the bag!??
slot_id = EQ::InventoryProfile::CalcSlotId(i, x);
item = GetInv().GetItem(slot_id);
if (item) {
if (item->GetUniqueID().compare(unique_id) == 0) {
return item;
}
if (item && item->GetUniqueID().compare(unique_id) == 0) {
return item;
}
}
}
@ -1136,10 +1134,8 @@ std::vector<EQ::ItemInstance *> Client::FindTraderItemsByUniqueID(const char* un
// we already have the parent bag and a contents iterator..why not just iterate the bag!??
slot_id = EQ::InventoryProfile::CalcSlotId(i, x);
item = GetInv().GetItem(slot_id);
if (item) {
if (item->GetUniqueID().compare(unique_id) == 0) {
items.push_back(item);
}
if (item && item->GetUniqueID().compare(unique_id) == 0) {
items.push_back(item);
}
}
}
@ -1149,11 +1145,11 @@ std::vector<EQ::ItemInstance *> Client::FindTraderItemsByUniqueID(const char* un
return items;
}
GetItems2_Struct *Client::GetTraderItems()
GetBazaarItems_Struct *Client::GetTraderItems()
{
const EQ::ItemInstance *item = nullptr;
int16 slot_id = INVALID_INDEX;
auto gis = new GetItems2_Struct{0};
auto gis = new GetBazaarItems_Struct{0};
uint8 ndx = 0;
for (int16 i = EQ::invslot::GENERAL_BEGIN; i <= EQ::invslot::GENERAL_END; i++) {
@ -1309,7 +1305,7 @@ void Client::FindAndNukeTraderItem(std::string &item_unique_id, int16 quantity,
std::vector<TraderRepository::Trader> delete_queue{};
for (int i = 0; i < item_limit; i++) {
if (test_slot && trader_items.at(i).item_unique_id.compare(item_unique_id) == 0) {
if (test_slot && i < trader_items.size() && trader_items.at(i).item_unique_id.compare(item_unique_id) == 0) {
delete_queue.push_back(trader_items.at(i));
NukeTraderItem(
slot_id,
@ -1322,7 +1318,7 @@ void Client::FindAndNukeTraderItem(std::string &item_unique_id, int16 quantity,
);
test_slot = false;
}
else if (trader_items.at(i).item_id > 0) {
else if (i < trader_items.size() && trader_items.at(i).item_id > 0) {
count++;
}
}
@ -1766,10 +1762,6 @@ static void UpdateTraderCustomerPriceChanged(
// RoF+ use Item IDs for now
tdis->item_id = trader_items.at(i).item_id;
}
//FIX else {
// tdis->item_id = trader_items.at(i).item_sn;
// }
//tdis->item_id = trader_items.at(i).item_sn;
LogTrading("Telling customer to remove item [{}] with [{}] charges and S/N [{}]",
item_id, charges, trader_items.at(i).item_unique_id);

View File

@ -314,7 +314,7 @@ std::unique_ptr<EQ::ItemInstance> ZoneDatabase::LoadSingleTraderItem(uint32 char
auto results = TraderRepository::GetWhere(
database,
fmt::format(
"`character_id` = '{}' AND `item_unique_id` = '{}' ORDER BY slot_id",
"`character_id` = {} AND `item_unique_id` = '{}' ORDER BY slot_id",
character_id,
unique_item_id
)
@ -358,7 +358,6 @@ std::unique_ptr<EQ::ItemInstance> ZoneDatabase::LoadSingleTraderItem(uint32 char
inst->SetCharges(charges);
inst->SetUniqueID(unique_item_id);
//FIX inst->SetMerchantSlot(serial_number);
inst->SetPrice(cost);
if (inst->IsStackable()) {
@ -383,7 +382,7 @@ void ZoneDatabase::UpdateTraderItemPrice(int character_id, uint32 item_id, uint3
auto results = TraderRepository::DeleteWhere(
database,
fmt::format(
"`character_id` = '{}' AND `item_id` = {}",
"`character_id` = {} AND `item_id` = {}",
character_id,
item_id
)