mirror of
https://github.com/EQEmu/Server.git
synced 2026-05-31 13:16:39 +00:00
Start Trader with new unique_id
This commit is contained in:
+24
-23
@@ -6167,30 +6167,31 @@ namespace RoF2
|
||||
switch (action) {
|
||||
case structs::RoF2BazaarTraderBuyerActions::BeginTraderMode: {
|
||||
DECODE_LENGTH_EXACT(structs::BeginTrader_Struct);
|
||||
SETUP_DIRECT_DECODE(ClickTrader2_Struct, structs::BeginTrader_Struct);
|
||||
|
||||
unsigned char *eq_buffer = __packet->pBuffer;
|
||||
auto eq = (RoF2::structs::BeginTrader_Struct *) eq_buffer;
|
||||
|
||||
ClickTraderNew_Struct out{};
|
||||
out.action = TraderOn;
|
||||
for (auto i = 0; i < RoF2::invtype::BAZAAR_SIZE; i++) {
|
||||
BazaarTraderDetails btd{};
|
||||
btd.unique_id = eq->item_unique_ids[i].item_unique_id;
|
||||
btd.cost = eq->item_cost[i];
|
||||
out.items.push_back(btd);
|
||||
}
|
||||
|
||||
std::stringstream ss{};
|
||||
cereal::BinaryOutputArchive ar(ss);
|
||||
{
|
||||
ar(out);
|
||||
}
|
||||
|
||||
__packet->size = static_cast<uint32>(ss.str().length());
|
||||
__packet->pBuffer = new unsigned char[__packet->size]{};
|
||||
memcpy(__packet->pBuffer, ss.str().data(), __packet->size);
|
||||
safe_delete_array(eq_buffer);
|
||||
|
||||
LogTrading("(RoF2) BeginTraderMode action <green>[{}]", action);
|
||||
|
||||
emu->action = TraderOn;
|
||||
std::copy_n(eq->item_cost, RoF2::invtype::BAZAAR_SIZE, emu->item_cost);
|
||||
std::transform(
|
||||
std::begin(eq->items),
|
||||
std::end(eq->items),
|
||||
std::begin(emu->serial_number),
|
||||
[&](const structs::TraderItemSerial_Struct x) {
|
||||
return std::string(x.serial_number);
|
||||
});
|
||||
//std::ranges::copy(eq->items->serial_number, emu->serial_number);
|
||||
//std::copy_n(eq->items->serial_number, RoF2::invtype::BAZAAR_SIZE, emu->serial_number);
|
||||
// std::transform(
|
||||
// std::begin(eq->items),
|
||||
// std::end(eq->items),
|
||||
// std::begin(emu->serial_number),
|
||||
// [&](const structs::TraderItemSerial_Struct x) {
|
||||
// return Strings::ToUnsignedBigInt(x.serial_number,0);
|
||||
// }
|
||||
// );
|
||||
|
||||
FINISH_DIRECT_DECODE();
|
||||
break;
|
||||
}
|
||||
case structs::RoF2BazaarTraderBuyerActions::EndTraderMode: {
|
||||
|
||||
@@ -3554,19 +3554,21 @@ struct WhoAllPlayerPart4 {
|
||||
};
|
||||
|
||||
struct TraderItemSerial_Struct {
|
||||
char serial_number[17];
|
||||
char item_unique_id[17];
|
||||
uint8 unknown_018;
|
||||
|
||||
void operator=(const char* a) {
|
||||
//auto _tmp = fmt::format("{:016}", a);
|
||||
strn0cpy(this->serial_number, a, sizeof(this->serial_number));
|
||||
TraderItemSerial_Struct& operator=(const char* a) {
|
||||
strn0cpy(this->item_unique_id, a, sizeof(this->item_unique_id));
|
||||
unknown_018 = 0;
|
||||
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
|
||||
struct BeginTrader_Struct {
|
||||
/*0000*/ uint32 action;
|
||||
/*0004*/ TraderItemSerial_Struct items[200];
|
||||
/*3604*/ uint32 item_cost[200];
|
||||
/*0004*/ TraderItemSerial_Struct item_unique_ids[RoF2::invtype::BAZAAR_SIZE];
|
||||
/*3604*/ uint32 item_cost[RoF2::invtype::BAZAAR_SIZE];
|
||||
/*4404*/
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user