From b8263d6a90c3dd2fffc0efcf7e312fe5be82ac43 Mon Sep 17 00:00:00 2001 From: Regalis Date: Tue, 31 Jan 2017 20:11:19 +0200 Subject: [PATCH] Removing items from their parent inventory in item.Drop --- Subsurface/Source/Items/Inventory.cs | 1 + Subsurface/Source/Items/Item.cs | 12 +++++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/Subsurface/Source/Items/Inventory.cs b/Subsurface/Source/Items/Inventory.cs index 462713567..c1edf24d9 100644 --- a/Subsurface/Source/Items/Inventory.cs +++ b/Subsurface/Source/Items/Inventory.cs @@ -564,6 +564,7 @@ namespace Barotrauma if (newItemIDs[i] == 0) { if (Items[i] != null) Items[i].Drop(); + System.Diagnostics.Debug.Assert(Items[i]==null); } else { diff --git a/Subsurface/Source/Items/Item.cs b/Subsurface/Source/Items/Item.cs index 34b1990c1..09bf80dcb 100644 --- a/Subsurface/Source/Items/Item.cs +++ b/Subsurface/Source/Items/Item.cs @@ -1529,7 +1529,17 @@ namespace Barotrauma { foreach (ItemComponent ic in components) ic.Drop(dropper); - if (Container != null) Container.RemoveContained(this); + if (Container != null) + { + Container.RemoveContained(this); + Container = null; + } + + if (parentInventory != null) + { + parentInventory.RemoveItem(this); + parentInventory = null; + } } public void Equip(Character character)