mirror of
https://github.com/EQEmu/Server.git
synced 2026-05-31 09:06:46 +00:00
Trader Direct purchase updated and tested
This commit is contained in:
+4
-5
@@ -187,11 +187,11 @@ Bazaar::GetSearchResults(
|
||||
);
|
||||
}
|
||||
else {
|
||||
search_criteria_trader.append(fmt::format(" AND trader.char_id = {}", search.trader_id));
|
||||
search_criteria_trader.append(fmt::format(" AND trader.character_id = {}", search.trader_id));
|
||||
}
|
||||
}
|
||||
else {
|
||||
search_criteria_trader.append(fmt::format(" AND trader.char_id = {}", search.trader_id));
|
||||
search_criteria_trader.append(fmt::format(" AND trader.character_id = {}", search.trader_id));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -297,8 +297,8 @@ Bazaar::GetSearchResults(
|
||||
|
||||
BazaarSearchResultsFromDB_Struct r{};
|
||||
r.count = 1;
|
||||
r.trader_id = t.trader.char_id;
|
||||
r.serial_number = t.trader.item_sn;
|
||||
r.trader_id = t.trader.character_id;
|
||||
r.item_unique_id = t.trader.item_unique_id;
|
||||
r.cost = t.trader.item_cost;
|
||||
r.slot_id = t.trader.slot_id;
|
||||
r.charges = t.trader.item_charges;
|
||||
@@ -307,7 +307,6 @@ Bazaar::GetSearchResults(
|
||||
r.trader_zone_id = t.trader.char_zone_id;
|
||||
r.trader_zone_instance_id = t.trader.char_zone_instance_id;
|
||||
r.trader_entity_id = t.trader.char_entity_id;
|
||||
r.serial_number_RoF = t.trader.item_sn;
|
||||
r.item_name = fmt::format("{:.63}\0", item_results.at(t.trader.item_id).name);
|
||||
r.trader_name = fmt::format("{:.63}\0", t.trader_name);
|
||||
r.item_stat = item_results.at(t.trader.item_id).stats;
|
||||
|
||||
@@ -7189,7 +7189,7 @@ ALTER TABLE `character_parcels_containers`
|
||||
ManifestEntry{
|
||||
.version = 9329,
|
||||
.description = "2025_03_27_implement_item_unique_unique_id.sql",
|
||||
.check = "SHOW COLUMNS FROM `inventory` LIKE 'serial_number'",
|
||||
.check = "SHOW COLUMNS FROM `inventory` LIKE 'item_unique_id'",
|
||||
.condition = "empty",
|
||||
.match = "",
|
||||
.sql = R"(
|
||||
@@ -7220,6 +7220,23 @@ ALTER TABLE `inventory_snapshots`
|
||||
DROP PRIMARY KEY,
|
||||
ADD PRIMARY KEY (`time_index`, `character_id`, `slot_id`) USING BTREE;
|
||||
|
||||
ALTER TABLE `trader`
|
||||
CHANGE COLUMN `char_id` `character_id` INT(11) UNSIGNED NOT NULL DEFAULT '0' AFTER `id`,
|
||||
ADD COLUMN `item_unique_id` VARCHAR(16) NULL DEFAULT NULL AFTER `item_id`,
|
||||
CHANGE COLUMN `aug_slot_1` `augment_one` INT(10) UNSIGNED NOT NULL DEFAULT '0' AFTER `item_unique_id`,
|
||||
CHANGE COLUMN `aug_slot_2` `augment_two` INT(10) UNSIGNED NOT NULL DEFAULT '0' AFTER `augment_one`,
|
||||
CHANGE COLUMN `aug_slot_3` `augment_three` INT(10) UNSIGNED NOT NULL DEFAULT '0' AFTER `augment_two`,
|
||||
CHANGE COLUMN `aug_slot_4` `augment_four` INT(10) UNSIGNED NOT NULL DEFAULT '0' AFTER `augment_three`,
|
||||
CHANGE COLUMN `aug_slot_5` `augment_five` INT(10) UNSIGNED NOT NULL DEFAULT '0' AFTER `augment_four`,
|
||||
CHANGE COLUMN `aug_slot_6` `augment_six` INT(10) UNSIGNED NOT NULL DEFAULT '0' AFTER `augment_five`,
|
||||
DROP COLUMN `item_sn`,
|
||||
DROP INDEX `idx_trader_item_sn`,
|
||||
DROP INDEX `charid_slotid`,
|
||||
ADD INDEX `charid_slotid` (`character_id`, `slot_id`) USING BTREE,
|
||||
DROP INDEX `idx_trader_char`,
|
||||
ADD INDEX `idx_trader_char` (`character_id`, `char_zone_id`, `char_zone_instance_id`) USING BTREE,
|
||||
ADD UNIQUE INDEX `idx_item_unique_id` (`item_unique_id`);
|
||||
|
||||
)",
|
||||
.content_schema_update = false
|
||||
},
|
||||
|
||||
+13
-14
@@ -3093,7 +3093,7 @@ struct BazaarSearchCriteria_Struct {
|
||||
struct BazaarInspect_Struct {
|
||||
uint32 action;
|
||||
char player_name[64];
|
||||
char serial_number[16];
|
||||
char item_unique_id[17];
|
||||
uint32 item_id;
|
||||
uint32 trader_id;
|
||||
};
|
||||
@@ -3730,7 +3730,7 @@ struct Trader_Struct {
|
||||
};
|
||||
|
||||
struct TraderItems_Struct {
|
||||
std::string serial_number;
|
||||
std::string item_unique_id;
|
||||
uint32 item_id;
|
||||
uint64 item_cost;
|
||||
|
||||
@@ -3738,7 +3738,7 @@ struct TraderItems_Struct {
|
||||
void serialize(Archive &archive)
|
||||
{
|
||||
archive(
|
||||
CEREAL_NVP(serial_number),
|
||||
CEREAL_NVP(item_unique_id),
|
||||
CEREAL_NVP(item_id),
|
||||
CEREAL_NVP(item_cost)
|
||||
);
|
||||
@@ -3850,7 +3850,7 @@ struct TraderBuy_Struct {
|
||||
/*084*/ char seller_name[64];
|
||||
/*148*/ char unknown_148[32];
|
||||
/*180*/ char item_name[64];
|
||||
/*244*/ char serial_number[17];
|
||||
/*244*/ char item_unique_id[17];
|
||||
/*261*/ char unknown_261[3];
|
||||
/*264*/ uint32 item_id;
|
||||
/*268*/ uint32 price;
|
||||
@@ -3869,12 +3869,12 @@ struct TraderItemUpdate_Struct{
|
||||
};
|
||||
|
||||
struct TraderPriceUpdate_Struct {
|
||||
/*000*/ uint32 Action;
|
||||
/*004*/ uint32 SubAction;
|
||||
/*008*/ char serial_number[16];
|
||||
/*012*/ uint32 Unknown012;
|
||||
/*016*/ uint32 NewPrice;
|
||||
/*020*/ uint32 Unknown016;
|
||||
/*000*/ uint32 action;
|
||||
/*002*/ uint32 sub_action;
|
||||
/*004*/ char item_unique_id[17];
|
||||
/*021*/ char unknown_021[3];
|
||||
/*024*/ uint32 unknown_024;
|
||||
/*028*/ uint32 new_price;
|
||||
};
|
||||
|
||||
struct MoneyUpdate_Struct{
|
||||
@@ -3889,6 +3889,7 @@ struct TraderDelItem_Struct{
|
||||
uint32 trader_id;
|
||||
uint32 item_id;
|
||||
uint32 unknown_012;
|
||||
char item_unique_id[17];
|
||||
};
|
||||
|
||||
struct TraderClick_Struct{
|
||||
@@ -6494,7 +6495,7 @@ struct BazaarSearchResultsFromDB_Struct {
|
||||
uint32 count;
|
||||
uint32 trader_id;
|
||||
uint32 item_id;
|
||||
std::string serial_number;
|
||||
std::string item_unique_id;
|
||||
uint32 charges;
|
||||
uint32 cost;
|
||||
uint32 slot_id;
|
||||
@@ -6506,7 +6507,6 @@ struct BazaarSearchResultsFromDB_Struct {
|
||||
uint32 item_stat;
|
||||
bool stackable;
|
||||
std::string item_name;
|
||||
std::string serial_number_RoF;
|
||||
std::string trader_name;
|
||||
|
||||
template<class Archive>
|
||||
@@ -6516,7 +6516,7 @@ struct BazaarSearchResultsFromDB_Struct {
|
||||
CEREAL_NVP(count),
|
||||
CEREAL_NVP(trader_id),
|
||||
CEREAL_NVP(item_id),
|
||||
CEREAL_NVP(serial_number),
|
||||
CEREAL_NVP(item_unique_id),
|
||||
CEREAL_NVP(charges),
|
||||
CEREAL_NVP(cost),
|
||||
CEREAL_NVP(slot_id),
|
||||
@@ -6528,7 +6528,6 @@ struct BazaarSearchResultsFromDB_Struct {
|
||||
CEREAL_NVP(item_stat),
|
||||
CEREAL_NVP(stackable),
|
||||
CEREAL_NVP(item_name),
|
||||
CEREAL_NVP(serial_number_RoF),
|
||||
CEREAL_NVP(trader_name)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -159,7 +159,7 @@ EQ::ItemInstance::ItemInstance(const ItemInstance& copy)
|
||||
m_timers = copy.m_timers;
|
||||
|
||||
if (copy.GetUniqueID().empty()) {
|
||||
LogError("Creating Serial Number as part of Clone command");
|
||||
LogError("Creating unique item ID as part of clone process for item id {}", copy.GetID());
|
||||
copy.CreateUniqueID();
|
||||
}
|
||||
m_unique_id = copy.m_unique_id;
|
||||
|
||||
@@ -168,6 +168,14 @@ namespace EQ
|
||||
|
||||
int16 GetCharges() const { return m_charges; }
|
||||
void SetCharges(int16 charges) { m_charges = charges; }
|
||||
int16 GetQuantityFromCharges() const
|
||||
{
|
||||
if (GetCharges() > 0 || IsStackable() || GetItem()->MaxCharges > 0) {
|
||||
return GetCharges();
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
uint32 GetPrice() const { return m_price; }
|
||||
void SetPrice(uint32 price) { m_price = price; }
|
||||
|
||||
+35
-48
@@ -480,7 +480,7 @@ namespace RoF2
|
||||
|
||||
for (auto i: results) {
|
||||
VARSTRUCT_ENCODE_TYPE(uint32, bufptr, i.trader_id); //trader ID
|
||||
VARSTRUCT_ENCODE_STRING(bufptr, i.serial_number_RoF.c_str()); //serial
|
||||
VARSTRUCT_ENCODE_STRING(bufptr, i.item_unique_id.c_str()); //serial
|
||||
VARSTRUCT_ENCODE_TYPE(uint32, bufptr, i.cost); //cost
|
||||
VARSTRUCT_ENCODE_TYPE(uint32, bufptr, i.stackable ? i.charges : i.count); //quantity
|
||||
VARSTRUCT_ENCODE_TYPE(uint32, bufptr, i.item_id); //ID
|
||||
@@ -757,7 +757,7 @@ namespace RoF2
|
||||
ar(bl);
|
||||
|
||||
//packet size
|
||||
auto packet_size = bl.item_name.length() + 1 + 34;
|
||||
uint32 packet_size = bl.item_name.length() + 1 + 34;
|
||||
for (auto const &b: bl.trade_items) {
|
||||
packet_size += b.item_name.length() + 1;
|
||||
packet_size += 12;
|
||||
@@ -4130,17 +4130,19 @@ namespace RoF2
|
||||
auto buffer = new char[4404]{}; // 4404 is the fixed size of the packet for 200 item limit of RoF2
|
||||
auto pos = buffer;
|
||||
|
||||
auto pos_unique_id = buffer + 4;
|
||||
auto pos_cost = buffer + 3604;
|
||||
VARSTRUCT_ENCODE_TYPE(uint32, pos, structs::RoF2BazaarTraderBuyerActions::ListTraderItems);
|
||||
for (auto const &t: tcm.items) {
|
||||
strn0cpy(pos, t.serial_number.data(), t.serial_number.length() + 1);
|
||||
pos += 3600;
|
||||
VARSTRUCT_ENCODE_TYPE(uint32, pos, t.item_cost);
|
||||
pos -= 3604 - 18;
|
||||
strn0cpy(pos_unique_id, t.item_unique_id.data(), t.item_unique_id.length() + 1);
|
||||
*(uint32 *) pos_cost = t.item_cost;
|
||||
pos_unique_id += 18;
|
||||
pos_cost += 4;
|
||||
}
|
||||
|
||||
for (int i = tcm.items.size(); i < EQ::invtype::BAZAAR_SIZE; i++) {
|
||||
strn0cpy(pos, "0000000000000000", 18);
|
||||
pos += 18;
|
||||
strn0cpy(pos_unique_id, "0000000000000000", 18);
|
||||
pos_unique_id += 18;
|
||||
}
|
||||
|
||||
safe_delete_array(in->pBuffer);
|
||||
@@ -4160,7 +4162,7 @@ namespace RoF2
|
||||
}
|
||||
case PriceUpdate: {
|
||||
SETUP_DIRECT_ENCODE(TraderPriceUpdate_Struct, structs::TraderPriceUpdate_Struct);
|
||||
switch (emu->SubAction) {
|
||||
switch (emu->sub_action) {
|
||||
case BazaarPriceChange_AddItem: {
|
||||
auto outapp = std::make_unique<EQApplicationPacket>(
|
||||
OP_Trader,
|
||||
@@ -4168,7 +4170,7 @@ namespace RoF2
|
||||
);
|
||||
|
||||
auto data = (structs::TraderStatus_Struct *) outapp->pBuffer;
|
||||
data->action = emu->Action;
|
||||
data->action = emu->action;
|
||||
data->sub_action = BazaarPriceChange_AddItem;
|
||||
LogTrading(
|
||||
"(RoF2) PriceUpdate action <green>[{}] AddItem subaction <yellow>[{}]",
|
||||
@@ -4186,7 +4188,7 @@ namespace RoF2
|
||||
);
|
||||
|
||||
auto data = (structs::TraderStatus_Struct *) outapp->pBuffer;
|
||||
data->action = emu->Action;
|
||||
data->action = emu->action;
|
||||
data->sub_action = BazaarPriceChange_RemoveItem;
|
||||
LogTrading(
|
||||
"(RoF2) PriceUpdate action <green>[{}] RemoveItem subaction <yellow>[{}]",
|
||||
@@ -4204,7 +4206,7 @@ namespace RoF2
|
||||
);
|
||||
|
||||
auto data = (structs::TraderStatus_Struct *) outapp->pBuffer;
|
||||
data->action = emu->Action;
|
||||
data->action = emu->action;
|
||||
data->sub_action = BazaarPriceChange_UpdatePrice;
|
||||
LogTrading(
|
||||
"(RoF2) PriceUpdate action <green>[{}] UpdatePrice subaction <yellow>[{}]",
|
||||
@@ -4229,7 +4231,7 @@ namespace RoF2
|
||||
"(RoF2) BuyTraderItem action <green>[{}] item_id <green>[{}] item_sn <green>[{}] buyer <green>[{}]",
|
||||
action,
|
||||
eq->item_id,
|
||||
eq->serial_number,
|
||||
eq->item_unique_id,
|
||||
eq->buyer_name
|
||||
);
|
||||
dest->FastQueuePacket(&in);
|
||||
@@ -4268,8 +4270,7 @@ namespace RoF2
|
||||
OUT_str(buyer_name);
|
||||
OUT_str(seller_name);
|
||||
OUT_str(item_name);
|
||||
OUT_str(serial_number);
|
||||
//strn0cpy(eq->serial_number, emu->serial_number.c_str(), sizeof(eq->serial_number));
|
||||
OUT_str(item_unique_id);
|
||||
|
||||
FINISH_ENCODE();
|
||||
}
|
||||
@@ -4279,15 +4280,13 @@ namespace RoF2
|
||||
ENCODE_LENGTH_EXACT(TraderDelItem_Struct);
|
||||
SETUP_DIRECT_ENCODE(TraderDelItem_Struct, structs::TraderDelItem_Struct);
|
||||
LogTrading(
|
||||
"(RoF2) trader_id <green>[{}] item_id <green>[{}]",
|
||||
"(RoF2) trader_id <green>[{}] item_unique_id <green>[{}]",
|
||||
emu->trader_id,
|
||||
emu->item_id
|
||||
emu->item_unique_id
|
||||
);
|
||||
|
||||
eq->TraderID = emu->trader_id;
|
||||
auto serial = fmt::format("{:016}\n", emu->item_id);
|
||||
strn0cpy(eq->SerialNumber, serial.c_str(), sizeof(eq->SerialNumber));
|
||||
LogTrading("(RoF2) TraderID <green>[{}], SerialNumber: <green>[{}]", emu->trader_id, emu->item_id);
|
||||
eq->trader_id = emu->trader_id;
|
||||
strn0cpy(eq->item_unique_id, emu->item_unique_id, sizeof(eq->item_unique_id));
|
||||
|
||||
FINISH_ENCODE();
|
||||
}
|
||||
@@ -4334,8 +4333,7 @@ namespace RoF2
|
||||
OUT_str(buyer_name);
|
||||
OUT_str(seller_name);
|
||||
OUT_str(item_name);
|
||||
OUT_str(serial_number);
|
||||
//strn0cpy(eq->serial_number, emu->serial_number.c_str(), sizeof(eq->serial_number));
|
||||
OUT_str(item_unique_id);
|
||||
|
||||
FINISH_ENCODE();
|
||||
break;
|
||||
@@ -6174,6 +6172,10 @@ namespace RoF2
|
||||
ClickTraderNew_Struct out{};
|
||||
out.action = TraderOn;
|
||||
for (auto i = 0; i < RoF2::invtype::BAZAAR_SIZE; i++) {
|
||||
if (eq->item_cost[i] == 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
BazaarTraderDetails btd{};
|
||||
btd.unique_id = eq->item_unique_ids[i].item_unique_id;
|
||||
btd.cost = eq->item_cost[i];
|
||||
@@ -6214,13 +6216,9 @@ namespace RoF2
|
||||
SETUP_DIRECT_DECODE(TraderPriceUpdate_Struct, structs::TraderPriceUpdate_Struct);
|
||||
LogTrading("(RoF2) PriceUpdate action <green>[{}]", action);
|
||||
|
||||
emu->Action = PriceUpdate;
|
||||
strn0cpy(emu->serial_number, eq->serial_number, sizeof(emu->serial_number));
|
||||
//FIXemu->serial_number = Strings::ToUnsignedBigInt(eq->serial_number, 0);
|
||||
// if (emu->SerialNumber == 0) {
|
||||
// LogTrading("(RoF2) Price change with invalid serial number <red>[{}]", eq->serial_number);
|
||||
// }
|
||||
emu->NewPrice = eq->new_price;
|
||||
emu->action = PriceUpdate;
|
||||
strn0cpy(emu->item_unique_id, eq->item_unique_id, sizeof(emu->item_unique_id));
|
||||
emu->new_price = eq->new_price;
|
||||
|
||||
FINISH_DIRECT_DECODE();
|
||||
break;
|
||||
@@ -6310,23 +6308,13 @@ namespace RoF2
|
||||
IN(item_id);
|
||||
IN(trader_id);
|
||||
emu->action = BazaarInspect;
|
||||
strn0cpy(emu->serial_number, eq->serial_number, sizeof(emu->serial_number));
|
||||
//FIX emu->serial_number = Strings::ToUnsignedInt(eq->serial_number, 0);
|
||||
// if (emu->serial_number == 0) {
|
||||
// LogTrading(
|
||||
// "(RoF2) trader_id = <green>[{}] requested a BazaarInspect with an invalid serial number of <red>[{}]",
|
||||
// eq->trader_id,
|
||||
// eq->serial_number
|
||||
// );
|
||||
// FINISH_DIRECT_DECODE();
|
||||
// return;
|
||||
// }
|
||||
strn0cpy(emu->item_unique_id, eq->item_unique_id, sizeof(emu->item_unique_id));
|
||||
|
||||
// LogTrading("(RoF2) BazaarInspect action <green>[{}] item_id <green>[{}] serial_number <green>[{}]",
|
||||
// action,
|
||||
// eq->item_id,
|
||||
// eq->serial_number
|
||||
// );
|
||||
LogTrading("(RoF2) BazaarInspect action <green>[{}] item_id <green>[{}] serial_number <green>[{}]",
|
||||
action,
|
||||
eq->item_id,
|
||||
eq->item_unique_id
|
||||
);
|
||||
FINISH_DIRECT_DECODE();
|
||||
break;
|
||||
}
|
||||
@@ -6363,8 +6351,7 @@ namespace RoF2
|
||||
IN_str(seller_name);
|
||||
IN_str(item_name);
|
||||
//IN_str(serial_number);
|
||||
strn0cpy(emu->serial_number, eq->serial_number, sizeof(emu->serial_number));
|
||||
//FIX emu->serial_number = eq->serial_number;
|
||||
strn0cpy(emu->item_unique_id, eq->item_unique_id, sizeof(emu->item_unique_id));
|
||||
|
||||
FINISH_DIRECT_DECODE();
|
||||
break;
|
||||
|
||||
@@ -3311,7 +3311,7 @@ struct BazaarInspect_Struct {
|
||||
uint32 action;
|
||||
uint32 unknown_004;
|
||||
uint32 trader_id;
|
||||
char serial_number[17];
|
||||
char item_unique_id[17];
|
||||
char unknown_029[3];
|
||||
uint32 item_id;
|
||||
uint32 unknown_036;
|
||||
@@ -3594,11 +3594,11 @@ struct BazaarWindowRemoveTrader_Struct {
|
||||
};
|
||||
|
||||
struct TraderPriceUpdate_Struct {
|
||||
uint32 action;
|
||||
char serial_number[17];
|
||||
char unknown_021[3];
|
||||
uint32 unknown_024;
|
||||
uint32 new_price;
|
||||
/*000*/ uint32 action;
|
||||
/*004*/ char item_unique_id[17];
|
||||
/*021*/ char unknown_021[3];
|
||||
/*024*/ uint32 unknown_024;
|
||||
/*028*/ uint32 new_price;
|
||||
};
|
||||
|
||||
struct Trader_ShowItems_Struct {
|
||||
@@ -3625,7 +3625,7 @@ struct TraderBuy_Struct {
|
||||
/*084*/ char seller_name[64];
|
||||
/*148*/ char unknown_148[32];
|
||||
/*180*/ char item_name[64];
|
||||
/*244*/ char serial_number[17];
|
||||
/*244*/ char item_unique_id[17];
|
||||
/*261*/ char unknown_261[3];
|
||||
/*264*/ uint32 item_id;
|
||||
/*268*/ uint32 price;
|
||||
@@ -3651,10 +3651,10 @@ struct MoneyUpdate_Struct{
|
||||
};
|
||||
|
||||
struct TraderDelItem_Struct{
|
||||
/*000*/ uint32 Unknown000;
|
||||
/*004*/ uint32 TraderID;
|
||||
/*008*/ char SerialNumber[17];
|
||||
/*024*/ uint32 Unknown012;
|
||||
/*000*/ uint32 unknown_000;
|
||||
/*004*/ uint32 trader_id;
|
||||
/*008*/ char item_unique_id[17];
|
||||
/*025*/ uint32 unknown_025;
|
||||
/*028*/
|
||||
};
|
||||
|
||||
|
||||
@@ -20,15 +20,15 @@ class BaseTraderRepository {
|
||||
public:
|
||||
struct Trader {
|
||||
uint64_t id;
|
||||
uint32_t char_id;
|
||||
uint32_t character_id;
|
||||
uint32_t item_id;
|
||||
uint32_t aug_slot_1;
|
||||
uint32_t aug_slot_2;
|
||||
uint32_t aug_slot_3;
|
||||
uint32_t aug_slot_4;
|
||||
uint32_t aug_slot_5;
|
||||
uint32_t aug_slot_6;
|
||||
std::string item_sn;
|
||||
std::string item_unique_id;
|
||||
uint32_t augment_one;
|
||||
uint32_t augment_two;
|
||||
uint32_t augment_three;
|
||||
uint32_t augment_four;
|
||||
uint32_t augment_five;
|
||||
uint32_t augment_six;
|
||||
int32_t item_charges;
|
||||
uint32_t item_cost;
|
||||
uint8_t slot_id;
|
||||
@@ -48,15 +48,15 @@ public:
|
||||
{
|
||||
return {
|
||||
"id",
|
||||
"char_id",
|
||||
"character_id",
|
||||
"item_id",
|
||||
"aug_slot_1",
|
||||
"aug_slot_2",
|
||||
"aug_slot_3",
|
||||
"aug_slot_4",
|
||||
"aug_slot_5",
|
||||
"aug_slot_6",
|
||||
"item_sn",
|
||||
"item_unique_id",
|
||||
"augment_one",
|
||||
"augment_two",
|
||||
"augment_three",
|
||||
"augment_four",
|
||||
"augment_five",
|
||||
"augment_six",
|
||||
"item_charges",
|
||||
"item_cost",
|
||||
"slot_id",
|
||||
@@ -72,15 +72,15 @@ public:
|
||||
{
|
||||
return {
|
||||
"id",
|
||||
"char_id",
|
||||
"character_id",
|
||||
"item_id",
|
||||
"aug_slot_1",
|
||||
"aug_slot_2",
|
||||
"aug_slot_3",
|
||||
"aug_slot_4",
|
||||
"aug_slot_5",
|
||||
"aug_slot_6",
|
||||
"item_sn",
|
||||
"item_unique_id",
|
||||
"augment_one",
|
||||
"augment_two",
|
||||
"augment_three",
|
||||
"augment_four",
|
||||
"augment_five",
|
||||
"augment_six",
|
||||
"item_charges",
|
||||
"item_cost",
|
||||
"slot_id",
|
||||
@@ -130,15 +130,15 @@ public:
|
||||
Trader e{};
|
||||
|
||||
e.id = 0;
|
||||
e.char_id = 0;
|
||||
e.character_id = 0;
|
||||
e.item_id = 0;
|
||||
e.aug_slot_1 = 0;
|
||||
e.aug_slot_2 = 0;
|
||||
e.aug_slot_3 = 0;
|
||||
e.aug_slot_4 = 0;
|
||||
e.aug_slot_5 = 0;
|
||||
e.aug_slot_6 = 0;
|
||||
e.item_sn = "";
|
||||
e.item_unique_id = "";
|
||||
e.augment_one = 0;
|
||||
e.augment_two = 0;
|
||||
e.augment_three = 0;
|
||||
e.augment_four = 0;
|
||||
e.augment_five = 0;
|
||||
e.augment_six = 0;
|
||||
e.item_charges = 0;
|
||||
e.item_cost = 0;
|
||||
e.slot_id = 0;
|
||||
@@ -184,15 +184,15 @@ public:
|
||||
Trader e{};
|
||||
|
||||
e.id = row[0] ? strtoull(row[0], nullptr, 10) : 0;
|
||||
e.char_id = row[1] ? static_cast<uint32_t>(strtoul(row[1], nullptr, 10)) : 0;
|
||||
e.character_id = row[1] ? static_cast<uint32_t>(strtoul(row[1], nullptr, 10)) : 0;
|
||||
e.item_id = row[2] ? static_cast<uint32_t>(strtoul(row[2], nullptr, 10)) : 0;
|
||||
e.aug_slot_1 = row[3] ? static_cast<uint32_t>(strtoul(row[3], nullptr, 10)) : 0;
|
||||
e.aug_slot_2 = row[4] ? static_cast<uint32_t>(strtoul(row[4], nullptr, 10)) : 0;
|
||||
e.aug_slot_3 = row[5] ? static_cast<uint32_t>(strtoul(row[5], nullptr, 10)) : 0;
|
||||
e.aug_slot_4 = row[6] ? static_cast<uint32_t>(strtoul(row[6], nullptr, 10)) : 0;
|
||||
e.aug_slot_5 = row[7] ? static_cast<uint32_t>(strtoul(row[7], nullptr, 10)) : 0;
|
||||
e.aug_slot_6 = row[8] ? static_cast<uint32_t>(strtoul(row[8], nullptr, 10)) : 0;
|
||||
e.item_sn = row[9] ? row[9] : "";
|
||||
e.item_unique_id = row[3] ? row[3] : "";
|
||||
e.augment_one = row[4] ? static_cast<uint32_t>(strtoul(row[4], nullptr, 10)) : 0;
|
||||
e.augment_two = row[5] ? static_cast<uint32_t>(strtoul(row[5], nullptr, 10)) : 0;
|
||||
e.augment_three = row[6] ? static_cast<uint32_t>(strtoul(row[6], nullptr, 10)) : 0;
|
||||
e.augment_four = row[7] ? static_cast<uint32_t>(strtoul(row[7], nullptr, 10)) : 0;
|
||||
e.augment_five = row[8] ? static_cast<uint32_t>(strtoul(row[8], nullptr, 10)) : 0;
|
||||
e.augment_six = row[9] ? static_cast<uint32_t>(strtoul(row[9], nullptr, 10)) : 0;
|
||||
e.item_charges = row[10] ? static_cast<int32_t>(atoi(row[10])) : 0;
|
||||
e.item_cost = row[11] ? static_cast<uint32_t>(strtoul(row[11], nullptr, 10)) : 0;
|
||||
e.slot_id = row[12] ? static_cast<uint8_t>(strtoul(row[12], nullptr, 10)) : 0;
|
||||
@@ -234,15 +234,15 @@ public:
|
||||
|
||||
auto columns = Columns();
|
||||
|
||||
v.push_back(columns[1] + " = " + std::to_string(e.char_id));
|
||||
v.push_back(columns[1] + " = " + std::to_string(e.character_id));
|
||||
v.push_back(columns[2] + " = " + std::to_string(e.item_id));
|
||||
v.push_back(columns[3] + " = " + std::to_string(e.aug_slot_1));
|
||||
v.push_back(columns[4] + " = " + std::to_string(e.aug_slot_2));
|
||||
v.push_back(columns[5] + " = " + std::to_string(e.aug_slot_3));
|
||||
v.push_back(columns[6] + " = " + std::to_string(e.aug_slot_4));
|
||||
v.push_back(columns[7] + " = " + std::to_string(e.aug_slot_5));
|
||||
v.push_back(columns[8] + " = " + std::to_string(e.aug_slot_6));
|
||||
v.push_back(columns[9] + " = '" + Strings::Escape(e.item_sn) + "'");
|
||||
v.push_back(columns[3] + " = '" + Strings::Escape(e.item_unique_id) + "'");
|
||||
v.push_back(columns[4] + " = " + std::to_string(e.augment_one));
|
||||
v.push_back(columns[5] + " = " + std::to_string(e.augment_two));
|
||||
v.push_back(columns[6] + " = " + std::to_string(e.augment_three));
|
||||
v.push_back(columns[7] + " = " + std::to_string(e.augment_four));
|
||||
v.push_back(columns[8] + " = " + std::to_string(e.augment_five));
|
||||
v.push_back(columns[9] + " = " + std::to_string(e.augment_six));
|
||||
v.push_back(columns[10] + " = " + std::to_string(e.item_charges));
|
||||
v.push_back(columns[11] + " = " + std::to_string(e.item_cost));
|
||||
v.push_back(columns[12] + " = " + std::to_string(e.slot_id));
|
||||
@@ -273,15 +273,15 @@ public:
|
||||
std::vector<std::string> v;
|
||||
|
||||
v.push_back(std::to_string(e.id));
|
||||
v.push_back(std::to_string(e.char_id));
|
||||
v.push_back(std::to_string(e.character_id));
|
||||
v.push_back(std::to_string(e.item_id));
|
||||
v.push_back(std::to_string(e.aug_slot_1));
|
||||
v.push_back(std::to_string(e.aug_slot_2));
|
||||
v.push_back(std::to_string(e.aug_slot_3));
|
||||
v.push_back(std::to_string(e.aug_slot_4));
|
||||
v.push_back(std::to_string(e.aug_slot_5));
|
||||
v.push_back(std::to_string(e.aug_slot_6));
|
||||
v.push_back("'" + Strings::Escape(e.item_sn) + "'");
|
||||
v.push_back("'" + Strings::Escape(e.item_unique_id) + "'");
|
||||
v.push_back(std::to_string(e.augment_one));
|
||||
v.push_back(std::to_string(e.augment_two));
|
||||
v.push_back(std::to_string(e.augment_three));
|
||||
v.push_back(std::to_string(e.augment_four));
|
||||
v.push_back(std::to_string(e.augment_five));
|
||||
v.push_back(std::to_string(e.augment_six));
|
||||
v.push_back(std::to_string(e.item_charges));
|
||||
v.push_back(std::to_string(e.item_cost));
|
||||
v.push_back(std::to_string(e.slot_id));
|
||||
@@ -320,15 +320,15 @@ public:
|
||||
std::vector<std::string> v;
|
||||
|
||||
v.push_back(std::to_string(e.id));
|
||||
v.push_back(std::to_string(e.char_id));
|
||||
v.push_back(std::to_string(e.character_id));
|
||||
v.push_back(std::to_string(e.item_id));
|
||||
v.push_back(std::to_string(e.aug_slot_1));
|
||||
v.push_back(std::to_string(e.aug_slot_2));
|
||||
v.push_back(std::to_string(e.aug_slot_3));
|
||||
v.push_back(std::to_string(e.aug_slot_4));
|
||||
v.push_back(std::to_string(e.aug_slot_5));
|
||||
v.push_back(std::to_string(e.aug_slot_6));
|
||||
v.push_back("'" + Strings::Escape(e.item_sn) + "'");
|
||||
v.push_back("'" + Strings::Escape(e.item_unique_id) + "'");
|
||||
v.push_back(std::to_string(e.augment_one));
|
||||
v.push_back(std::to_string(e.augment_two));
|
||||
v.push_back(std::to_string(e.augment_three));
|
||||
v.push_back(std::to_string(e.augment_four));
|
||||
v.push_back(std::to_string(e.augment_five));
|
||||
v.push_back(std::to_string(e.augment_six));
|
||||
v.push_back(std::to_string(e.item_charges));
|
||||
v.push_back(std::to_string(e.item_cost));
|
||||
v.push_back(std::to_string(e.slot_id));
|
||||
@@ -371,15 +371,15 @@ public:
|
||||
Trader e{};
|
||||
|
||||
e.id = row[0] ? strtoull(row[0], nullptr, 10) : 0;
|
||||
e.char_id = row[1] ? static_cast<uint32_t>(strtoul(row[1], nullptr, 10)) : 0;
|
||||
e.character_id = row[1] ? static_cast<uint32_t>(strtoul(row[1], nullptr, 10)) : 0;
|
||||
e.item_id = row[2] ? static_cast<uint32_t>(strtoul(row[2], nullptr, 10)) : 0;
|
||||
e.aug_slot_1 = row[3] ? static_cast<uint32_t>(strtoul(row[3], nullptr, 10)) : 0;
|
||||
e.aug_slot_2 = row[4] ? static_cast<uint32_t>(strtoul(row[4], nullptr, 10)) : 0;
|
||||
e.aug_slot_3 = row[5] ? static_cast<uint32_t>(strtoul(row[5], nullptr, 10)) : 0;
|
||||
e.aug_slot_4 = row[6] ? static_cast<uint32_t>(strtoul(row[6], nullptr, 10)) : 0;
|
||||
e.aug_slot_5 = row[7] ? static_cast<uint32_t>(strtoul(row[7], nullptr, 10)) : 0;
|
||||
e.aug_slot_6 = row[8] ? static_cast<uint32_t>(strtoul(row[8], nullptr, 10)) : 0;
|
||||
e.item_sn = row[9] ? row[9] : "";
|
||||
e.item_unique_id = row[3] ? row[3] : "";
|
||||
e.augment_one = row[4] ? static_cast<uint32_t>(strtoul(row[4], nullptr, 10)) : 0;
|
||||
e.augment_two = row[5] ? static_cast<uint32_t>(strtoul(row[5], nullptr, 10)) : 0;
|
||||
e.augment_three = row[6] ? static_cast<uint32_t>(strtoul(row[6], nullptr, 10)) : 0;
|
||||
e.augment_four = row[7] ? static_cast<uint32_t>(strtoul(row[7], nullptr, 10)) : 0;
|
||||
e.augment_five = row[8] ? static_cast<uint32_t>(strtoul(row[8], nullptr, 10)) : 0;
|
||||
e.augment_six = row[9] ? static_cast<uint32_t>(strtoul(row[9], nullptr, 10)) : 0;
|
||||
e.item_charges = row[10] ? static_cast<int32_t>(atoi(row[10])) : 0;
|
||||
e.item_cost = row[11] ? static_cast<uint32_t>(strtoul(row[11], nullptr, 10)) : 0;
|
||||
e.slot_id = row[12] ? static_cast<uint8_t>(strtoul(row[12], nullptr, 10)) : 0;
|
||||
@@ -413,15 +413,15 @@ public:
|
||||
Trader e{};
|
||||
|
||||
e.id = row[0] ? strtoull(row[0], nullptr, 10) : 0;
|
||||
e.char_id = row[1] ? static_cast<uint32_t>(strtoul(row[1], nullptr, 10)) : 0;
|
||||
e.character_id = row[1] ? static_cast<uint32_t>(strtoul(row[1], nullptr, 10)) : 0;
|
||||
e.item_id = row[2] ? static_cast<uint32_t>(strtoul(row[2], nullptr, 10)) : 0;
|
||||
e.aug_slot_1 = row[3] ? static_cast<uint32_t>(strtoul(row[3], nullptr, 10)) : 0;
|
||||
e.aug_slot_2 = row[4] ? static_cast<uint32_t>(strtoul(row[4], nullptr, 10)) : 0;
|
||||
e.aug_slot_3 = row[5] ? static_cast<uint32_t>(strtoul(row[5], nullptr, 10)) : 0;
|
||||
e.aug_slot_4 = row[6] ? static_cast<uint32_t>(strtoul(row[6], nullptr, 10)) : 0;
|
||||
e.aug_slot_5 = row[7] ? static_cast<uint32_t>(strtoul(row[7], nullptr, 10)) : 0;
|
||||
e.aug_slot_6 = row[8] ? static_cast<uint32_t>(strtoul(row[8], nullptr, 10)) : 0;
|
||||
e.item_sn = row[9] ? row[9] : "";
|
||||
e.item_unique_id = row[3] ? row[3] : "";
|
||||
e.augment_one = row[4] ? static_cast<uint32_t>(strtoul(row[4], nullptr, 10)) : 0;
|
||||
e.augment_two = row[5] ? static_cast<uint32_t>(strtoul(row[5], nullptr, 10)) : 0;
|
||||
e.augment_three = row[6] ? static_cast<uint32_t>(strtoul(row[6], nullptr, 10)) : 0;
|
||||
e.augment_four = row[7] ? static_cast<uint32_t>(strtoul(row[7], nullptr, 10)) : 0;
|
||||
e.augment_five = row[8] ? static_cast<uint32_t>(strtoul(row[8], nullptr, 10)) : 0;
|
||||
e.augment_six = row[9] ? static_cast<uint32_t>(strtoul(row[9], nullptr, 10)) : 0;
|
||||
e.item_charges = row[10] ? static_cast<int32_t>(atoi(row[10])) : 0;
|
||||
e.item_cost = row[11] ? static_cast<uint32_t>(strtoul(row[11], nullptr, 10)) : 0;
|
||||
e.slot_id = row[12] ? static_cast<uint8_t>(strtoul(row[12], nullptr, 10)) : 0;
|
||||
@@ -505,15 +505,15 @@ public:
|
||||
std::vector<std::string> v;
|
||||
|
||||
v.push_back(std::to_string(e.id));
|
||||
v.push_back(std::to_string(e.char_id));
|
||||
v.push_back(std::to_string(e.character_id));
|
||||
v.push_back(std::to_string(e.item_id));
|
||||
v.push_back(std::to_string(e.aug_slot_1));
|
||||
v.push_back(std::to_string(e.aug_slot_2));
|
||||
v.push_back(std::to_string(e.aug_slot_3));
|
||||
v.push_back(std::to_string(e.aug_slot_4));
|
||||
v.push_back(std::to_string(e.aug_slot_5));
|
||||
v.push_back(std::to_string(e.aug_slot_6));
|
||||
v.push_back("'" + Strings::Escape(e.item_sn) + "'");
|
||||
v.push_back("'" + Strings::Escape(e.item_unique_id) + "'");
|
||||
v.push_back(std::to_string(e.augment_one));
|
||||
v.push_back(std::to_string(e.augment_two));
|
||||
v.push_back(std::to_string(e.augment_three));
|
||||
v.push_back(std::to_string(e.augment_four));
|
||||
v.push_back(std::to_string(e.augment_five));
|
||||
v.push_back(std::to_string(e.augment_six));
|
||||
v.push_back(std::to_string(e.item_charges));
|
||||
v.push_back(std::to_string(e.item_cost));
|
||||
v.push_back(std::to_string(e.slot_id));
|
||||
@@ -545,15 +545,15 @@ public:
|
||||
std::vector<std::string> v;
|
||||
|
||||
v.push_back(std::to_string(e.id));
|
||||
v.push_back(std::to_string(e.char_id));
|
||||
v.push_back(std::to_string(e.character_id));
|
||||
v.push_back(std::to_string(e.item_id));
|
||||
v.push_back(std::to_string(e.aug_slot_1));
|
||||
v.push_back(std::to_string(e.aug_slot_2));
|
||||
v.push_back(std::to_string(e.aug_slot_3));
|
||||
v.push_back(std::to_string(e.aug_slot_4));
|
||||
v.push_back(std::to_string(e.aug_slot_5));
|
||||
v.push_back(std::to_string(e.aug_slot_6));
|
||||
v.push_back("'" + Strings::Escape(e.item_sn) + "'");
|
||||
v.push_back("'" + Strings::Escape(e.item_unique_id) + "'");
|
||||
v.push_back(std::to_string(e.augment_one));
|
||||
v.push_back(std::to_string(e.augment_two));
|
||||
v.push_back(std::to_string(e.augment_three));
|
||||
v.push_back(std::to_string(e.augment_four));
|
||||
v.push_back(std::to_string(e.augment_five));
|
||||
v.push_back(std::to_string(e.augment_six));
|
||||
v.push_back(std::to_string(e.item_charges));
|
||||
v.push_back(std::to_string(e.item_cost));
|
||||
v.push_back(std::to_string(e.slot_id));
|
||||
|
||||
@@ -58,9 +58,9 @@ public:
|
||||
|
||||
if (RuleB(Bazaar, UseAlternateBazaarSearch)) {
|
||||
results = db.QueryDatabase(fmt::format(
|
||||
"SELECT DISTINCT(t.char_id), t.char_zone_id, t.char_zone_instance_id, t.char_entity_id, c.name "
|
||||
"SELECT DISTINCT(t.character_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 "
|
||||
"JOIN character_data AS c ON t.character_id = c.id "
|
||||
"WHERE t.char_zone_instance_id = {} "
|
||||
"ORDER BY t.char_zone_instance_id ASC "
|
||||
"LIMIT {}",
|
||||
@@ -69,13 +69,14 @@ public:
|
||||
);
|
||||
}
|
||||
else {
|
||||
results = db.QueryDatabase(fmt::format(
|
||||
"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 ASC "
|
||||
"LIMIT {}",
|
||||
max_results)
|
||||
results = db.QueryDatabase(
|
||||
fmt::format(
|
||||
"SELECT DISTINCT(t.character_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.character_id = c.id "
|
||||
"ORDER BY t.char_zone_instance_id ASC "
|
||||
"LIMIT {}",
|
||||
max_results)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -101,7 +102,7 @@ public:
|
||||
{
|
||||
WelcomeData_Struct e{};
|
||||
|
||||
auto results = db.QueryDatabase("SELECT COUNT(DISTINCT char_id), count(char_id) FROM trader;");
|
||||
auto results = db.QueryDatabase("SELECT COUNT(DISTINCT character_id), count(character_id) FROM trader;");
|
||||
|
||||
if (!results.RowCount()) {
|
||||
return e;
|
||||
@@ -113,15 +114,15 @@ public:
|
||||
return e;
|
||||
}
|
||||
|
||||
static int UpdateItem(Database &db, uint32 char_id, uint32 new_price, uint32 item_id, uint32 item_charges)
|
||||
static int UpdateItem(Database &db, uint32 character_id, uint32 new_price, uint32 item_id, uint32 item_charges)
|
||||
{
|
||||
std::vector<BaseTraderRepository::Trader> items{};
|
||||
if (item_charges == 0) {
|
||||
items = GetWhere(
|
||||
db,
|
||||
fmt::format(
|
||||
"char_id = '{}' AND item_id = '{}'",
|
||||
char_id,
|
||||
"character_id = '{}' AND item_id = '{}'",
|
||||
character_id,
|
||||
item_id
|
||||
)
|
||||
);
|
||||
@@ -130,8 +131,8 @@ public:
|
||||
items = GetWhere(
|
||||
db,
|
||||
fmt::format(
|
||||
"char_id = '{}' AND item_id = '{}' AND item_charges = '{}'",
|
||||
char_id,
|
||||
"character_id = '{}' AND item_id = '{}' AND item_charges = '{}'",
|
||||
character_id,
|
||||
item_id,
|
||||
item_charges
|
||||
)
|
||||
@@ -155,8 +156,8 @@ public:
|
||||
Trader item{};
|
||||
|
||||
auto query = fmt::format(
|
||||
"SELECT t.char_id, t.item_id, t.serialnumber, 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 = {} "
|
||||
"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 = '{}' "
|
||||
"LIMIT 1;",
|
||||
trader_id,
|
||||
item_id,
|
||||
@@ -168,41 +169,59 @@ public:
|
||||
return item;
|
||||
}
|
||||
|
||||
auto row = results.begin();
|
||||
item.char_id = Strings::ToInt(row[0]);
|
||||
item.item_id = Strings::ToInt(row[1]);
|
||||
item.item_sn = Strings::ToInt(row[2]);
|
||||
item.item_charges = Strings::ToInt(row[3]);
|
||||
item.item_cost = Strings::ToInt(row[4]);
|
||||
item.slot_id = Strings::ToInt(row[5]);
|
||||
auto row = results.begin();
|
||||
item.character_id = Strings::ToInt(row[0]);
|
||||
item.item_id = Strings::ToInt(row[1]);
|
||||
item.item_unique_id = row[2] ? row[2] : "";
|
||||
item.item_charges = Strings::ToInt(row[3]);
|
||||
item.item_cost = Strings::ToInt(row[4]);
|
||||
item.slot_id = Strings::ToInt(row[5]);
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
static int UpdateQuantity(Database &db, uint32 char_id, const std::string &serial_number, int16 quantity)
|
||||
static int UpdateQuantity(Database &db, const std::string &item_unique_id, int16 quantity)
|
||||
{
|
||||
const auto trader_item = GetWhere(
|
||||
db,
|
||||
fmt::format("char_id = '{}' AND item_sn = '{}' ", char_id, serial_number)
|
||||
fmt::format("`item_unique_id` = '{}' ", item_unique_id)
|
||||
);
|
||||
|
||||
if (trader_item.empty() || trader_item.size() > 1) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
auto m = trader_item[0];
|
||||
auto m = trader_item[0];
|
||||
m.item_charges = quantity;
|
||||
m.listing_date = time(nullptr);
|
||||
|
||||
return UpdateOne(db, m);
|
||||
}
|
||||
|
||||
static Trader GetItemBySerialNumber(Database &db, std::string &serial_number, uint32 trader_id)
|
||||
static int UpdatePrice(Database &db, const std::string &item_unique_id, uint32 price)
|
||||
{
|
||||
const auto trader_item = GetWhere(
|
||||
db,
|
||||
fmt::format("`item_unique_id` = '{}' ", item_unique_id)
|
||||
);
|
||||
|
||||
if (trader_item.empty() || trader_item.size() > 1) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
auto m = trader_item[0];
|
||||
m.item_cost = price;
|
||||
m.listing_date = time(nullptr);
|
||||
|
||||
return ReplaceOne(db, m);
|
||||
}
|
||||
|
||||
static Trader GetItemBySerialNumber(Database &db, std::string &item_unique_id, uint32 trader_id)
|
||||
{
|
||||
Trader e{};
|
||||
const auto trader_item = GetWhere(
|
||||
db,
|
||||
fmt::format("`char_id` = '{}' AND `item_sn` = '{}' LIMIT 1", trader_id, serial_number)
|
||||
fmt::format("`character_id` = '{}' AND `item_unique_id` = '{}' LIMIT 1", trader_id, item_unique_id)
|
||||
);
|
||||
|
||||
if (trader_item.empty()) {
|
||||
@@ -240,21 +259,16 @@ public:
|
||||
return DeleteWhere(db, fmt::format("`id` IN({})", Strings::Implode(",", delete_ids)));
|
||||
}
|
||||
|
||||
static DistinctTraders_Struct GetTraderByInstanceAndSerialnumber(
|
||||
Database &db,
|
||||
uint32 instance_id,
|
||||
std::string &serial_number
|
||||
)
|
||||
static DistinctTraders_Struct GetTraderByItemUniqueNumber(Database &db, std::string &item_unique_id)
|
||||
{
|
||||
DistinctTraders_Struct trader{};
|
||||
|
||||
auto query = fmt::format(
|
||||
"SELECT t.id, t.char_id, c.name "
|
||||
"SELECT t.id, t.character_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
|
||||
"JOIN character_data AS c ON c.id = t.character_id "
|
||||
"WHERE t.item_unique_id = '{}' LIMIT 1",
|
||||
item_unique_id
|
||||
);
|
||||
|
||||
auto results = db.QueryDatabase(query);
|
||||
@@ -264,7 +278,6 @@ public:
|
||||
}
|
||||
|
||||
auto row = results.begin();
|
||||
std::string name = row[2];
|
||||
trader.trader_id = Strings::ToUnsignedInt(row[1]);
|
||||
trader.trader_name = row[2] ? row[2] : "";
|
||||
|
||||
@@ -279,8 +292,12 @@ public:
|
||||
std::vector<BazaarTraderSearch_Struct> all_entries{};
|
||||
|
||||
auto query = fmt::format(
|
||||
"SELECT trader.*, c.`name` FROM `trader` INNER JOIN character_data AS c ON trader.char_id = c.id "
|
||||
"WHERE {} ORDER BY trader.char_id ASC",
|
||||
"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` FROM `trader` "
|
||||
"INNER JOIN character_data AS c ON trader.character_id = c.id "
|
||||
"WHERE {} ORDER BY trader.character_id ASC",
|
||||
search_criteria_trader
|
||||
);
|
||||
|
||||
@@ -295,15 +312,15 @@ public:
|
||||
BazaarTraderSearch_Struct e{};
|
||||
|
||||
e.trader.id = row[0] ? strtoull(row[0], nullptr, 10) : 0;
|
||||
e.trader.char_id = row[1] ? static_cast<uint32_t>(strtoul(row[1], nullptr, 10)) : 0;
|
||||
e.trader.character_id = row[1] ? static_cast<uint32_t>(strtoul(row[1], nullptr, 10)) : 0;
|
||||
e.trader.item_id = row[2] ? static_cast<uint32_t>(strtoul(row[2], nullptr, 10)) : 0;
|
||||
e.trader.aug_slot_1 = row[3] ? static_cast<uint32_t>(strtoul(row[3], nullptr, 10)) : 0;
|
||||
e.trader.aug_slot_2 = row[4] ? static_cast<uint32_t>(strtoul(row[4], nullptr, 10)) : 0;
|
||||
e.trader.aug_slot_3 = row[5] ? static_cast<uint32_t>(strtoul(row[5], nullptr, 10)) : 0;
|
||||
e.trader.aug_slot_4 = row[6] ? static_cast<uint32_t>(strtoul(row[6], nullptr, 10)) : 0;
|
||||
e.trader.aug_slot_5 = row[7] ? static_cast<uint32_t>(strtoul(row[7], nullptr, 10)) : 0;
|
||||
e.trader.aug_slot_6 = row[8] ? static_cast<uint32_t>(strtoul(row[8], nullptr, 10)) : 0;
|
||||
e.trader.item_sn = row[9] ? row[9] : std::string("");
|
||||
e.trader.item_unique_id = row[3] ? row[3] : std::string("");
|
||||
e.trader.augment_one = row[4] ? static_cast<uint32_t>(strtoul(row[4], nullptr, 10)) : 0;
|
||||
e.trader.augment_two = row[5] ? static_cast<uint32_t>(strtoul(row[5], nullptr, 10)) : 0;
|
||||
e.trader.augment_three = row[6] ? static_cast<uint32_t>(strtoul(row[6], nullptr, 10)) : 0;
|
||||
e.trader.augment_four = row[7] ? static_cast<uint32_t>(strtoul(row[7], nullptr, 10)) : 0;
|
||||
e.trader.augment_five = row[8] ? static_cast<uint32_t>(strtoul(row[8], nullptr, 10)) : 0;
|
||||
e.trader.augment_six = row[9] ? static_cast<uint32_t>(strtoul(row[9], nullptr, 10)) : 0;
|
||||
e.trader.item_charges = row[10] ? static_cast<int32_t>(atoi(row[10])) : 0;
|
||||
e.trader.item_cost = row[11] ? static_cast<uint32_t>(strtoul(row[11], nullptr, 10)) : 0;
|
||||
e.trader.slot_id = row[12] ? static_cast<uint8_t>(strtoul(row[12], nullptr, 10)) : 0;
|
||||
|
||||
Reference in New Issue
Block a user