diff --git a/common/item.cpp b/common/item.cpp index 044d55d3d..533a0817b 100644 --- a/common/item.cpp +++ b/common/item.cpp @@ -1710,9 +1710,17 @@ void ItemInst::ClearByFlags(byFlagSetting is_nodrop, byFlagSetting is_norent) end = m_contents.end(); for (; cur != end;) { ItemInst* inst = cur->second; - if (inst == nullptr) + if (inst == nullptr) { + cur = m_contents.erase(cur); continue; + } + const Item_Struct* item = inst->GetItem(); + if (item == nullptr) { + cur = m_contents.erase(cur); + continue; + } + del = cur; ++cur; @@ -1723,6 +1731,7 @@ void ItemInst::ClearByFlags(byFlagSetting is_nodrop, byFlagSetting is_norent) m_contents.erase(del->first); continue; } + // no 'break;' deletes 'byFlagNotSet' type - can't add at the moment because it really *breaks* the process somewhere case byFlagNotSet: if (item->NoDrop != 0) { safe_delete(inst); @@ -1740,6 +1749,7 @@ void ItemInst::ClearByFlags(byFlagSetting is_nodrop, byFlagSetting is_norent) m_contents.erase(del->first); continue; } + // no 'break;' deletes 'byFlagNotSet' type - can't add at the moment because it really *breaks* the process somewhere case byFlagNotSet: if (item->NoRent != 0) { safe_delete(inst);