From 22d40077fa858268f858240a1a61d2689d085188 Mon Sep 17 00:00:00 2001 From: Regalis Date: Mon, 27 Feb 2017 18:53:34 +0200 Subject: [PATCH] Fixed exception in LightSource if ConvexHullList for hulls outside the sub hasn't been generated (i.e. if switching to game mode using console commands), removed some debug code --- Subsurface/Source/Map/Lights/LightSource.cs | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/Subsurface/Source/Map/Lights/LightSource.cs b/Subsurface/Source/Map/Lights/LightSource.cs index 4368b05f3..f5b80f5f1 100644 --- a/Subsurface/Source/Map/Lights/LightSource.cs +++ b/Subsurface/Source/Map/Lights/LightSource.cs @@ -180,6 +180,8 @@ namespace Barotrauma.Lights private void RefreshConvexHullList(ConvexHullList chList, Vector2 lightPos, Submarine sub) { var fullChList = ConvexHull.HullLists.Find(x => x.Submarine == sub); + if (fullChList == null) return; + chList.List = fullChList.List.FindAll(ch => ch.Enabled && MathUtils.CircleIntersectsRectangle(lightPos, range, ch.BoundingBox)); NeedsHullCheck = true; @@ -299,12 +301,7 @@ namespace Barotrauma.Lights foreach (ConvexHull hull in hulls) { hull.RefreshWorldPositions(); - - if (hull.ParentEntity is Item) - { - int gfhdfgh = 1; - } - + var visibleHullSegments = hull.GetVisibleSegments(drawPos); visibleSegments.AddRange(visibleHullSegments);