1
0

Avoid overflow items remaining in memory and causing a crash

This commit is contained in:
Emagi 2024-12-13 14:50:41 -05:00
parent 7daead0d11
commit 2a3a280793
2 changed files with 11 additions and 1 deletions

View File

@ -3379,7 +3379,12 @@ void PlayerItemList::DestroyItem(int16 index){
items[item->details.inv_slot_id][item->details.appearance_type].erase(item->details.slot_id);
indexed_items[index] = 0;
vector<Item*>::iterator itr = std::find(overflowItems.begin(), overflowItems.end(), item);
if(itr != overflowItems.end()) {
overflowItems.erase(itr); // avoid a dead ptr
}
lua_interface->SetLuaUserDataStale(item);
safe_delete(item);
}
MPlayerItems.releasewritelock(__FUNCTION__, __LINE__);

View File

@ -2146,9 +2146,14 @@ void Player::UpdateInventory(int32 bag_id) {
}
EQ2Packet* Player::MoveInventoryItem(sint32 to_bag_id, int16 from_index, int8 new_slot, int8 charges, int8 appearance_type, bool* item_deleted, int16 version) {
Item* item = item_list.GetItemFromIndex(from_index);
bool isOverflow = ((item != nullptr) && (item->details.inv_slot_id == -2));
int8 result = item_list.MoveItem(to_bag_id, from_index, new_slot, appearance_type, charges);
if (result == 1) {
if(isOverflow && item->details.inv_slot_id != -2) {
item_list.RemoveOverflowItem(item);
}
if (item) {
if (!item->needs_deletion)
item->save_needed = true;