(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

View File

@@ -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)