(2be015bd1) Added: Code hardening due to a crash where the item was null

This commit is contained in:
Joonas Rikkonen
2019-06-09 17:38:57 +03:00
parent 771f8d7286
commit 942b8a8588
@@ -338,7 +338,10 @@ namespace Barotrauma.Items.Components
canPlaceNode = true; canPlaceNode = true;
} }
if (item != null)
{
Vector2 relativeNodePos = newNodePos - item.Position; Vector2 relativeNodePos = newNodePos - item.Position;
if (sub != null) if (sub != null)
{ {
relativeNodePos += sub.HiddenSubPosition; relativeNodePos += sub.HiddenSubPosition;
@@ -348,6 +351,7 @@ namespace Barotrauma.Items.Components
Math.Max(Math.Abs(relativeNodePos.X), sectionExtents.X), Math.Max(Math.Abs(relativeNodePos.X), sectionExtents.X),
Math.Max(Math.Abs(relativeNodePos.Y), sectionExtents.Y)); Math.Max(Math.Abs(relativeNodePos.Y), sectionExtents.Y));
} }
}
public override bool Use(float deltaTime, Character character = null) public override bool Use(float deltaTime, Character character = null)
{ {