Merge origin/codex/bazaar-offline-trading-rework: resolve inventory.cpp transaction conflict

This commit is contained in:
copilot-swe-agent[bot] 2026-03-20 02:42:02 +00:00
commit 4bb92a8cd6
5 changed files with 18 additions and 31 deletions

View File

@ -81,7 +81,7 @@ public:
return -1; return -1;
} }
auto &row = results.begin(); auto row = results.begin();
const int64 count = Strings::ToBigInt(row[0]); const int64 count = Strings::ToBigInt(row[0]);
if (count > std::numeric_limits<int>::max()) { if (count > std::numeric_limits<int>::max()) {

View File

@ -961,14 +961,14 @@ bool Strings::IsValidJson(const std::string &json)
return result; return result;
} }
std::string Strings::Implode(const std::string& glue, std::unordered_set<std::string> src) std::string Strings::Implode(const std::string& glue, const std::unordered_set<std::string>& src)
{ {
if (src.empty()) { if (src.empty()) {
return {}; return {};
} }
std::ostringstream output; std::ostringstream output;
std::unordered_set<std::string>::iterator src_iter; std::unordered_set<std::string>::const_iterator src_iter;
for (src_iter = src.begin(); src_iter != src.end(); src_iter++) { for (src_iter = src.begin(); src_iter != src.end(); src_iter++) {
output << *src_iter << glue; output << *src_iter << glue;

View File

@ -77,7 +77,7 @@ public:
static std::string Escape(const std::string &s); static std::string Escape(const std::string &s);
static std::string GetBetween(const std::string &s, std::string start_delim, std::string stop_delim); static std::string GetBetween(const std::string &s, std::string start_delim, std::string stop_delim);
static std::string Implode(const std::string& glue, std::vector<std::string> src); static std::string Implode(const std::string& glue, std::vector<std::string> src);
static std::string Implode(const std::string& glue, std::unordered_set<std::string> src); static std::string Implode(const std::string& glue, const std::unordered_set<std::string>& src);
static std::string Join(const std::vector<std::string> &ar, const std::string &delim); static std::string Join(const std::vector<std::string> &ar, const std::string &delim);
static std::string Join(const std::vector<uint32_t> &ar, const std::string &delim); static std::string Join(const std::vector<uint32_t> &ar, const std::string &delim);
static std::string MillisecondsToTime(int duration); static std::string MillisecondsToTime(int duration);

View File

@ -4700,16 +4700,14 @@ bool Client::PutItemInInventoryWithStacking(EQ::ItemInstance *inst)
int32 quantity; int32 quantity;
}; };
std::vector<temp> queue; std::vector<temp> queue;
auto quantity = inst->GetCharges(); std::vector<int16> empty_bag_slots;
auto quantity = inst->GetCharges();
for (int i = EQ::invslot::GENERAL_BEGIN; i <= EQ::invslot::GENERAL_END; i++) { for (int i = EQ::invslot::GENERAL_BEGIN; i <= EQ::invslot::GENERAL_END; i++) {
auto inv_inst = GetInv().GetItem(i); auto inv_inst = GetInv().GetItem(i);
if (!inv_inst) { if (!inv_inst) {
LogError("Found a slot {} in general inventory", i); continue;
inst->SetCharges(quantity);
PutItemInInventory(i, *inst, true);
return true;
} }
int16 base_slot_id = EQ::InventoryProfile::CalcSlotId(i, EQ::invbag::SLOT_BEGIN); int16 base_slot_id = EQ::InventoryProfile::CalcSlotId(i, EQ::invbag::SLOT_BEGIN);
@ -4722,10 +4720,8 @@ bool Client::PutItemInInventoryWithStacking(EQ::ItemInstance *inst)
auto bag_inst = GetInv().GetItem(base_slot_id + bag_slot); auto bag_inst = GetInv().GetItem(base_slot_id + bag_slot);
if (!bag_inst && inv_inst->GetItem()->BagSize >= inst->GetItem()->Size) { if (!bag_inst && inv_inst->GetItem()->BagSize >= inst->GetItem()->Size) {
LogError("Found a parent {} base_slot_id {} bag_slot {} in bag", i, base_slot_id, bag_slot); empty_bag_slots.push_back(base_slot_id + bag_slot);
inst->SetCharges(quantity); continue;
PutItemInInventory(base_slot_id + bag_slot, *inst, true);
return true;
} }
if (bag_inst && bag_inst->IsStackable() && bag_inst->GetID() == inst->GetID()) { if (bag_inst && bag_inst->IsStackable() && bag_inst->GetID() == inst->GetID()) {
@ -4736,12 +4732,6 @@ bool Client::PutItemInInventoryWithStacking(EQ::ItemInstance *inst)
temp tmp = {temp_slot, quantity}; temp tmp = {temp_slot, quantity};
queue.push_back(tmp); queue.push_back(tmp);
quantity = 0; quantity = 0;
LogError(
"Found an item parent {} base_slot_id {} bag_slot {} in bag with ENOUGH space",
i,
base_slot_id,
bag_slot
);
break; break;
} }
@ -4749,12 +4739,6 @@ bool Client::PutItemInInventoryWithStacking(EQ::ItemInstance *inst)
temp tmp = {temp_slot, stack_size - bag_inst_quantity}; temp tmp = {temp_slot, stack_size - bag_inst_quantity};
queue.push_back(tmp); queue.push_back(tmp);
quantity -= stack_size - bag_inst_quantity; quantity -= stack_size - bag_inst_quantity;
LogError(
"Found an item parent {} base_slot_id {} bag_slot {} in bag with SOME space",
i,
base_slot_id,
bag_slot
);
} }
} }
} }
@ -4780,7 +4764,6 @@ bool Client::PutItemInInventoryWithStacking(EQ::ItemInstance *inst)
success = false; success = false;
break; break;
} }
LogError("Write out data. Item {} quantity {} slot {}", bag_inst->GetItem()->Name, i.quantity, i.slot_id);
} }
if (!success) { if (!success) {
@ -4792,18 +4775,23 @@ bool Client::PutItemInInventoryWithStacking(EQ::ItemInstance *inst)
} }
if (quantity == 0) { if (quantity == 0) {
LogError("Quantity was zero. All items placed in inventory.");
return true; return true;
} }
inst->SetCharges(quantity); inst->SetCharges(quantity);
for (auto slot_id : empty_bag_slots) {
if (PutItemInInventory(slot_id, *inst, true)) {
return true;
}
}
if (free_id != INVALID_INDEX && if (free_id != INVALID_INDEX &&
!EQ::ValueWithin(free_id, EQ::invslot::EQUIPMENT_BEGIN, EQ::invslot::EQUIPMENT_END) && !EQ::ValueWithin(free_id, EQ::invslot::EQUIPMENT_BEGIN, EQ::invslot::EQUIPMENT_END) &&
PutItemInInventory(free_id, *inst, true)) { PutItemInInventory(free_id, *inst, true)) {
return true; return true;
} }
LogError("Could not find enough room"); LogError("Could not find enough room for item {} (quantity {}) for character {}", inst->GetItem()->Name, quantity, CharacterID());
return false; return false;
} }

View File

@ -453,7 +453,6 @@ void Client::DoParcelSend(const Parcel_Struct *parcel_in)
cpc.quantity = item->GetCharges() >= 0 ? item->GetCharges() : 1; cpc.quantity = item->GetCharges() >= 0 ? item->GetCharges() : 1;
cpc.evolve_amount = item->GetEvolveCurrentAmount(); cpc.evolve_amount = item->GetEvolveCurrentAmount();
cpc.quantity = item->GetCharges() >= 0 ? item->GetCharges() : 1;
all_entries.push_back(cpc); all_entries.push_back(cpc);
} }
CharacterParcelsContainersRepository::InsertMany(database, all_entries); CharacterParcelsContainersRepository::InsertMany(database, all_entries);