From 942b8a85881debd518805ae801e1722bbc06d968 Mon Sep 17 00:00:00 2001 From: Joonas Rikkonen Date: Sun, 9 Jun 2019 17:38:57 +0300 Subject: [PATCH] (2be015bd1) Added: Code hardening due to a crash where the item was null --- .../Source/Items/Components/Signal/Wire.cs | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/Barotrauma/BarotraumaShared/Source/Items/Components/Signal/Wire.cs b/Barotrauma/BarotraumaShared/Source/Items/Components/Signal/Wire.cs index c26ed06c5..a969fa28d 100644 --- a/Barotrauma/BarotraumaShared/Source/Items/Components/Signal/Wire.cs +++ b/Barotrauma/BarotraumaShared/Source/Items/Components/Signal/Wire.cs @@ -338,15 +338,19 @@ namespace Barotrauma.Items.Components canPlaceNode = true; } - Vector2 relativeNodePos = newNodePos - item.Position; - if (sub != null) + if (item != null) { - relativeNodePos += sub.HiddenSubPosition; - } + Vector2 relativeNodePos = newNodePos - item.Position; - sectionExtents = new Vector2( - Math.Max(Math.Abs(relativeNodePos.X), sectionExtents.X), - Math.Max(Math.Abs(relativeNodePos.Y), sectionExtents.Y)); + if (sub != null) + { + relativeNodePos += sub.HiddenSubPosition; + } + + sectionExtents = new Vector2( + Math.Max(Math.Abs(relativeNodePos.X), sectionExtents.X), + Math.Max(Math.Abs(relativeNodePos.Y), sectionExtents.Y)); + } } public override bool Use(float deltaTime, Character character = null)