Merge remote-tracking branch 'origin/codex/bazaar-offline-trading-rework' into copilot/sub-pr-80-again

# Conflicts:
#	zone/inventory.cpp
This commit is contained in:
copilot-swe-agent[bot] 2026-03-20 02:46:49 +00:00
commit f95cb1887f
7 changed files with 37 additions and 17 deletions

View File

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

View File

@ -746,7 +746,7 @@ bool SharedDatabase::GetInventory(Client *c)
inst->SetColor(color);
}
if (charges > std::numeric_limits<int16>::max()) {
if (charges >= std::numeric_limits<int16>::max()) {
inst->SetCharges(-1);
} else if (charges == 0 && inst->IsStackable()) {
// Stackable items need a minimum charge of 1 remain moveable.

View File

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

View File

@ -77,7 +77,7 @@ public:
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 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<uint32_t> &ar, const std::string &delim);
static std::string MillisecondsToTime(int duration);

View File

@ -4700,8 +4700,9 @@ bool Client::PutItemInInventoryWithStacking(EQ::ItemInstance *inst)
int32 quantity;
};
std::vector<temp> queue;
auto quantity = inst->GetCharges();
std::vector<temp> queue;
std::vector<int16> empty_bag_slots;
auto quantity = inst->GetCharges();
for (int i = EQ::invslot::GENERAL_BEGIN; i <= EQ::invslot::GENERAL_END; i++) {
if (quantity == 0) {
@ -4710,7 +4711,6 @@ bool Client::PutItemInInventoryWithStacking(EQ::ItemInstance *inst)
auto inv_inst = GetInv().GetItem(i);
if (!inv_inst) {
// Empty general slot — skip for now; will fall back to free_id after scanning for stacks
continue;
}
@ -4723,12 +4723,12 @@ bool Client::PutItemInInventoryWithStacking(EQ::ItemInstance *inst)
}
auto bag_inst = GetInv().GetItem(base_slot_id + bag_slot);
if (!bag_inst) {
// Empty bag slot — skip for now; will fall back to free_id after scanning for stacks
if (!bag_inst && inv_inst->GetItem()->BagSize >= inst->GetItem()->Size) {
empty_bag_slots.push_back(base_slot_id + bag_slot);
continue;
}
if (bag_inst->IsStackable() && bag_inst->GetID() == inst->GetID()) {
if (bag_inst && bag_inst->IsStackable() && bag_inst->GetID() == inst->GetID()) {
auto stack_size = bag_inst->GetItem()->StackSize;
auto bag_inst_quantity = bag_inst->GetCharges();
int16 temp_slot = base_slot_id + bag_slot;
@ -4749,15 +4749,30 @@ bool Client::PutItemInInventoryWithStacking(EQ::ItemInstance *inst)
}
if (!queue.empty()) {
bool success = true;
database.TransactionBegin();
for (auto const &i: queue) {
auto bag_inst = GetInv().GetItem(i.slot_id);
if (!bag_inst) {
LogError("Client inventory error occurred. Character ID {} Slot_ID {}", CharacterID(), i.slot_id);
continue;
success = false;
break;
}
bag_inst->SetCharges(i.quantity + bag_inst->GetCharges());
PutItemInInventory(i.slot_id, *bag_inst, true);
if (!PutItemInInventory(i.slot_id, *bag_inst, true)) {
LogError(
"Failed to save stacked item to inventory. Character ID {} Slot_ID {}",
CharacterID(),
i.slot_id
);
success = false;
break;
}
}
if (!success) {
database.TransactionRollback();
return false;
}
database.TransactionCommit();
@ -4768,13 +4783,19 @@ bool Client::PutItemInInventoryWithStacking(EQ::ItemInstance *inst)
}
inst->SetCharges(quantity);
for (auto slot_id : empty_bag_slots) {
if (PutItemInInventory(slot_id, *inst, true)) {
return true;
}
}
if (free_id != INVALID_INDEX &&
!EQ::ValueWithin(free_id, EQ::invslot::EQUIPMENT_BEGIN, EQ::invslot::EQUIPMENT_END) &&
PutItemInInventory(free_id, *inst, 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;
}

View File

@ -1968,7 +1968,7 @@ private:
gender = in.gender;
race = in.race;
base_gender = in.base_gender;
base_race = in.race;
base_race = in.base_race;
use_model = in.use_model;
class_ = in.class_;
bodytype = in.bodytype;

View File

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