From cd7086f669f81c4cbe9a11e8da65958da66bd67a Mon Sep 17 00:00:00 2001 From: Noah Pilarski Date: Wed, 15 Jun 2022 10:26:13 -0400 Subject: [PATCH] Fix NRE in ShipLogHandler.cs --- NewHorizons/Handlers/ShipLogHandler.cs | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/NewHorizons/Handlers/ShipLogHandler.cs b/NewHorizons/Handlers/ShipLogHandler.cs index 0d5faaf5..2ffb175f 100644 --- a/NewHorizons/Handlers/ShipLogHandler.cs +++ b/NewHorizons/Handlers/ShipLogHandler.cs @@ -26,9 +26,18 @@ namespace NewHorizons.Handlers _entryIDsToNHBody = new Dictionary(); _nhBodyToAstroIDs = new Dictionary(); - List gameObjects = SearchUtilities.GetAllChildren(SearchUtilities.Find(PAN_ROOT_PATH)); - _vanillaBodies = gameObjects.ConvertAll(g => g.name).ToArray(); - _vanillaBodyIDs = gameObjects.ConvertAll(g => g.GetComponent()?.GetID()).ToArray(); + GameObject panRoot = SearchUtilities.Find(PAN_ROOT_PATH); + if (panRoot != null) + { + List gameObjects = SearchUtilities.GetAllChildren(panRoot); + _vanillaBodies = gameObjects.ConvertAll(g => g.name).ToArray(); + _vanillaBodyIDs = gameObjects.ConvertAll(g => g.GetComponent()?.GetID()).ToArray(); + } + else + { + _vanillaBodies = new string[0]; + _vanillaBodyIDs = new string[0]; + } } public static void CheckForModdedFacts(ShipLogManager manager)