From 7dd4dca2eddc956904fd13a29067628956ea506a Mon Sep 17 00:00:00 2001 From: Joonas Rikkonen Date: Mon, 7 May 2018 11:15:12 +0300 Subject: [PATCH 1/2] Fixed crashing when a round starts if the sub has been saved while a fabricator was running. Closes #398 --- .../Source/Items/Components/Machines/Fabricator.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Barotrauma/BarotraumaShared/Source/Items/Components/Machines/Fabricator.cs b/Barotrauma/BarotraumaShared/Source/Items/Components/Machines/Fabricator.cs index 7a1e32758..4c553b0ef 100644 --- a/Barotrauma/BarotraumaShared/Source/Items/Components/Machines/Fabricator.cs +++ b/Barotrauma/BarotraumaShared/Source/Items/Components/Machines/Fabricator.cs @@ -241,6 +241,12 @@ namespace Barotrauma.Items.Components public override void Update(float deltaTime, Camera cam) { + if (fabricatedItem == null) + { + CancelFabricating(); + return; + } + #if CLIENT if (progressBar != null) { From 421e77cc3e549a812ee18a7c1ec3f12f41536af0 Mon Sep 17 00:00:00 2001 From: Joonas Rikkonen Date: Mon, 7 May 2018 11:15:49 +0300 Subject: [PATCH 2/2] Fixed itemcomponents being loaded incorrectly if an item has multiple components of the same type. --- Barotrauma/BarotraumaShared/Source/Items/Item.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Barotrauma/BarotraumaShared/Source/Items/Item.cs b/Barotrauma/BarotraumaShared/Source/Items/Item.cs index f7bb4f920..21548bfcb 100644 --- a/Barotrauma/BarotraumaShared/Source/Items/Item.cs +++ b/Barotrauma/BarotraumaShared/Source/Items/Item.cs @@ -1763,13 +1763,14 @@ namespace Barotrauma } } + List unloadedComponents = new List(item.components); foreach (XElement subElement in element.Elements()) { - ItemComponent component = item.components.Find(x => x.Name == subElement.Name.ToString()); - + ItemComponent component = unloadedComponents.Find(x => x.Name == subElement.Name.ToString()); if (component == null) continue; component.Load(subElement); + unloadedComponents.Remove(component); } }