mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-13 18:51:29 +00:00
[Memory Leak] Fix leak in Client::RemoveDuplicateLore (#4614)
This commit is contained in:
parent
2926b4df78
commit
faa8a492f7
@ -218,6 +218,8 @@ namespace EQ
|
|||||||
std::map<int16, ItemInstance*>& GetPersonal() { return m_inv; }
|
std::map<int16, ItemInstance*>& GetPersonal() { return m_inv; }
|
||||||
int16 HasEvolvingItem(uint64 evolve_unique_id, uint8 quantity, uint8 where);
|
int16 HasEvolvingItem(uint64 evolve_unique_id, uint8 quantity, uint8 where);
|
||||||
|
|
||||||
|
inline int16 PushItem(int16 slot_id, ItemInstance* inst) { return _PutItem(slot_id, inst); }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
///////////////////////////////
|
///////////////////////////////
|
||||||
// Protected Methods
|
// Protected Methods
|
||||||
|
|||||||
@ -1175,7 +1175,7 @@ public:
|
|||||||
void Escape(); //keep or quest function
|
void Escape(); //keep or quest function
|
||||||
void DisenchantSummonedBags(bool client_update = true);
|
void DisenchantSummonedBags(bool client_update = true);
|
||||||
void RemoveNoRent(bool client_update = true);
|
void RemoveNoRent(bool client_update = true);
|
||||||
void RemoveDuplicateLore(bool client_update = true);
|
void RemoveDuplicateLore();
|
||||||
void MoveSlotNotAllowed(bool client_update = true);
|
void MoveSlotNotAllowed(bool client_update = true);
|
||||||
virtual bool RangedAttack(Mob* other, bool CanDoubleAttack = false);
|
virtual bool RangedAttack(Mob* other, bool CanDoubleAttack = false);
|
||||||
virtual void ThrowingAttack(Mob* other, bool CanDoubleAttack = false);
|
virtual void ThrowingAttack(Mob* other, bool CanDoubleAttack = false);
|
||||||
|
|||||||
@ -764,7 +764,7 @@ void Client::BulkSendInventoryItems()
|
|||||||
RemoveNoRent(false);
|
RemoveNoRent(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
RemoveDuplicateLore(false);
|
RemoveDuplicateLore();
|
||||||
MoveSlotNotAllowed(false);
|
MoveSlotNotAllowed(false);
|
||||||
|
|
||||||
EQ::OutBuffer ob;
|
EQ::OutBuffer ob;
|
||||||
|
|||||||
@ -2979,91 +2979,48 @@ void Client::RemoveNoRent(bool client_update)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Two new methods to alleviate perpetual login desyncs
|
// Two new methods to alleviate perpetual login desyncs
|
||||||
void Client::RemoveDuplicateLore(bool client_update)
|
void Client::RemoveDuplicateLore()
|
||||||
{
|
{
|
||||||
for (auto slot_id = EQ::invslot::EQUIPMENT_BEGIN; slot_id <= EQ::invslot::EQUIPMENT_END; ++slot_id) {
|
for (auto slot_id : GetInventorySlots()) {
|
||||||
if ((((uint64)1 << slot_id) & GetInv().GetLookup()->PossessionsBitmask) == 0)
|
if ((((uint64) 1 << slot_id) & GetInv().GetLookup()->PossessionsBitmask) == 0) {
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
auto inst = m_inv.PopItem(slot_id);
|
|
||||||
if (inst == nullptr) { continue; }
|
|
||||||
if(CheckLoreConflict(inst->GetItem())) {
|
|
||||||
LogInventory("Lore Duplication Error: Deleting [{}] from slot [{}]", inst->GetItem()->Name, slot_id);
|
|
||||||
database.SaveInventory(character_id, nullptr, slot_id);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
m_inv.PutItem(slot_id, *inst);
|
|
||||||
}
|
|
||||||
safe_delete(inst);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto slot_id = EQ::invslot::GENERAL_BEGIN; slot_id <= EQ::invslot::GENERAL_END; ++slot_id) {
|
// ignore shared bank slots
|
||||||
if ((((uint64)1 << slot_id) & GetInv().GetLookup()->PossessionsBitmask) == 0)
|
if (slot_id >= EQ::invslot::SHARED_BANK_BEGIN && slot_id <= EQ::invslot::SHARED_BANK_END) {
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (slot_id >= EQ::invbag::SHARED_BANK_BAGS_BEGIN && slot_id <= EQ::invbag::SHARED_BANK_BAGS_END) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// slot gets handled in a queue
|
||||||
|
if (slot_id == EQ::invslot::slotCursor) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// temporarily move the item off of the slot
|
||||||
auto inst = m_inv.PopItem(slot_id);
|
auto inst = m_inv.PopItem(slot_id);
|
||||||
if (inst == nullptr) { continue; }
|
if (!inst) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (CheckLoreConflict(inst->GetItem())) {
|
if (CheckLoreConflict(inst->GetItem())) {
|
||||||
LogInventory("Lore Duplication Error: Deleting [{}] from slot [{}]", inst->GetItem()->Name, slot_id);
|
LogError(
|
||||||
|
"Lore Duplication Error | Deleting [{}] ({}) from slot [{}] client [{}]",
|
||||||
|
inst->GetItem()->Name,
|
||||||
|
inst->GetItem()->ID,
|
||||||
|
slot_id,
|
||||||
|
GetCleanName()
|
||||||
|
);
|
||||||
database.SaveInventory(character_id, nullptr, slot_id);
|
database.SaveInventory(character_id, nullptr, slot_id);
|
||||||
}
|
|
||||||
else {
|
|
||||||
m_inv.PutItem(slot_id, *inst);
|
|
||||||
}
|
|
||||||
safe_delete(inst);
|
safe_delete(inst);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto slot_id = EQ::invbag::GENERAL_BAGS_BEGIN; slot_id <= EQ::invbag::CURSOR_BAG_END; ++slot_id) {
|
// if no lore conflict, put the item back in the slot
|
||||||
auto temp_slot = EQ::invslot::GENERAL_BEGIN + ((slot_id - EQ::invbag::GENERAL_BAGS_BEGIN) / EQ::invbag::SLOT_COUNT);
|
m_inv.PushItem(slot_id, inst);
|
||||||
if ((((uint64)1 << temp_slot) & GetInv().GetLookup()->PossessionsBitmask) == 0)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
auto inst = m_inv.PopItem(slot_id);
|
|
||||||
if (inst == nullptr) { continue; }
|
|
||||||
if(CheckLoreConflict(inst->GetItem())) {
|
|
||||||
LogInventory("Lore Duplication Error: Deleting [{}] from slot [{}]", inst->GetItem()->Name, slot_id);
|
|
||||||
database.SaveInventory(character_id, nullptr, slot_id);
|
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
m_inv.PutItem(slot_id, *inst);
|
|
||||||
}
|
|
||||||
safe_delete(inst);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (auto slot_id = EQ::invslot::BANK_BEGIN; slot_id <= EQ::invslot::BANK_END; ++slot_id) {
|
|
||||||
if ((slot_id - EQ::invslot::BANK_BEGIN) >= GetInv().GetLookup()->InventoryTypeSize.Bank)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
auto inst = m_inv.PopItem(slot_id);
|
|
||||||
if (inst == nullptr) { continue; }
|
|
||||||
if(CheckLoreConflict(inst->GetItem())) {
|
|
||||||
LogInventory("Lore Duplication Error: Deleting [{}] from slot [{}]", inst->GetItem()->Name, slot_id);
|
|
||||||
database.SaveInventory(character_id, nullptr, slot_id);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
m_inv.PutItem(slot_id, *inst);
|
|
||||||
}
|
|
||||||
safe_delete(inst);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (auto slot_id = EQ::invbag::BANK_BAGS_BEGIN; slot_id <= EQ::invbag::BANK_BAGS_END; ++slot_id) {
|
|
||||||
auto temp_slot = (slot_id - EQ::invbag::BANK_BAGS_BEGIN) / EQ::invbag::SLOT_COUNT;
|
|
||||||
if (temp_slot >= GetInv().GetLookup()->InventoryTypeSize.Bank)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
auto inst = m_inv.PopItem(slot_id);
|
|
||||||
if (inst == nullptr) { continue; }
|
|
||||||
if(CheckLoreConflict(inst->GetItem())) {
|
|
||||||
LogInventory("Lore Duplication Error: Deleting [{}] from slot [{}]", inst->GetItem()->Name, slot_id);
|
|
||||||
database.SaveInventory(character_id, nullptr, slot_id);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
m_inv.PutItem(slot_id, *inst);
|
|
||||||
}
|
|
||||||
safe_delete(inst);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Shared Bank and Shared Bank Containers are not checked due to their allowing duplicate lore items
|
|
||||||
|
|
||||||
if (!m_inv.CursorEmpty()) {
|
if (!m_inv.CursorEmpty()) {
|
||||||
std::list<EQ::ItemInstance*> local_1;
|
std::list<EQ::ItemInstance*> local_1;
|
||||||
@ -3071,15 +3028,23 @@ void Client::RemoveDuplicateLore(bool client_update)
|
|||||||
|
|
||||||
while (!m_inv.CursorEmpty()) {
|
while (!m_inv.CursorEmpty()) {
|
||||||
auto inst = m_inv.PopItem(EQ::invslot::slotCursor);
|
auto inst = m_inv.PopItem(EQ::invslot::slotCursor);
|
||||||
if (inst == nullptr) { continue; }
|
if (!inst) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
local_1.push_back(inst);
|
local_1.push_back(inst);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto iter = local_1.begin(); iter != local_1.end(); ++iter) {
|
for (auto inst: local_1) {
|
||||||
auto inst = *iter;
|
if (!inst) {
|
||||||
if (inst == nullptr) { continue; }
|
continue;
|
||||||
|
}
|
||||||
if (CheckLoreConflict(inst->GetItem())) {
|
if (CheckLoreConflict(inst->GetItem())) {
|
||||||
LogInventory("Lore Duplication Error: Deleting [{}] from `Limbo`", inst->GetItem()->Name);
|
LogError(
|
||||||
|
"Lore Duplication Error | Deleting [{}] ({}) from `Limbo` client [{}]",
|
||||||
|
inst->GetItem()->Name,
|
||||||
|
inst->GetItem()->ID,
|
||||||
|
GetCleanName()
|
||||||
|
);
|
||||||
safe_delete(inst);
|
safe_delete(inst);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -3088,17 +3053,25 @@ void Client::RemoveDuplicateLore(bool client_update)
|
|||||||
}
|
}
|
||||||
local_1.clear();
|
local_1.clear();
|
||||||
|
|
||||||
for (auto iter = local_2.begin(); iter != local_2.end(); ++iter) {
|
for (auto inst: local_2) {
|
||||||
auto inst = *iter;
|
if (!inst) {
|
||||||
if (inst == nullptr) { continue; }
|
continue;
|
||||||
|
}
|
||||||
if (!inst->GetItem()->LoreFlag ||
|
if (!inst->GetItem()->LoreFlag ||
|
||||||
((inst->GetItem()->LoreGroup == -1) && (m_inv.HasItem(inst->GetID(), 0, invWhereCursor) == INVALID_INDEX)) ||
|
((inst->GetItem()->LoreGroup == -1) &&
|
||||||
(inst->GetItem()->LoreGroup && (~inst->GetItem()->LoreGroup) && (m_inv.HasItemByLoreGroup(inst->GetItem()->LoreGroup, invWhereCursor) == INVALID_INDEX))
|
(m_inv.HasItem(inst->GetID(), 0, invWhereCursor) == INVALID_INDEX)) ||
|
||||||
|
(inst->GetItem()->LoreGroup && (~inst->GetItem()->LoreGroup) &&
|
||||||
|
(m_inv.HasItemByLoreGroup(inst->GetItem()->LoreGroup, invWhereCursor) == INVALID_INDEX))
|
||||||
) {
|
) {
|
||||||
m_inv.PushCursor(*inst);
|
m_inv.PushCursor(*inst);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
LogInventory("Lore Duplication Error: Deleting [{}] from `Limbo`", inst->GetItem()->Name);
|
LogError(
|
||||||
|
"Lore Duplication Error | Deleting [{}] ({}) from `Limbo` client [{}]",
|
||||||
|
inst->GetItem()->Name,
|
||||||
|
inst->GetItem()->ID,
|
||||||
|
GetCleanName()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
safe_delete(inst);
|
safe_delete(inst);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user