mirror of
https://github.com/EQEmu/Server.git
synced 2026-04-19 21:02:41 +00:00
Merge origin/codex/bazaar-offline-trading-rework: resolve inventory.cpp transaction conflict
This commit is contained in:
commit
4bb92a8cd6
@ -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()) {
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -4700,16 +4700,14 @@ 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++) {
|
||||
auto inv_inst = GetInv().GetItem(i);
|
||||
if (!inv_inst) {
|
||||
LogError("Found a slot {} in general inventory", i);
|
||||
inst->SetCharges(quantity);
|
||||
PutItemInInventory(i, *inst, true);
|
||||
return true;
|
||||
continue;
|
||||
}
|
||||
|
||||
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);
|
||||
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);
|
||||
inst->SetCharges(quantity);
|
||||
PutItemInInventory(base_slot_id + bag_slot, *inst, true);
|
||||
return true;
|
||||
empty_bag_slots.push_back(base_slot_id + bag_slot);
|
||||
continue;
|
||||
}
|
||||
|
||||
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};
|
||||
queue.push_back(tmp);
|
||||
quantity = 0;
|
||||
LogError(
|
||||
"Found an item parent {} base_slot_id {} bag_slot {} in bag with ENOUGH space",
|
||||
i,
|
||||
base_slot_id,
|
||||
bag_slot
|
||||
);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -4749,12 +4739,6 @@ bool Client::PutItemInInventoryWithStacking(EQ::ItemInstance *inst)
|
||||
temp tmp = {temp_slot, stack_size - bag_inst_quantity};
|
||||
queue.push_back(tmp);
|
||||
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;
|
||||
break;
|
||||
}
|
||||
LogError("Write out data. Item {} quantity {} slot {}", bag_inst->GetItem()->Name, i.quantity, i.slot_id);
|
||||
}
|
||||
|
||||
if (!success) {
|
||||
@ -4792,18 +4775,23 @@ bool Client::PutItemInInventoryWithStacking(EQ::ItemInstance *inst)
|
||||
}
|
||||
|
||||
if (quantity == 0) {
|
||||
LogError("Quantity was zero. All items placed in inventory.");
|
||||
return true;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
@ -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);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user