diff --git a/NewHorizons/Main.cs b/NewHorizons/Main.cs index 0383ed9a..31769f43 100644 --- a/NewHorizons/Main.cs +++ b/NewHorizons/Main.cs @@ -454,18 +454,17 @@ namespace NewHorizons var config = mod.ModHelper.Storage.Load(relativeDirectory); // var config = JsonConvert.DeserializeObject(File.ReadAllText($"{mod.ModHelper.Manifest.ModFolderPath}/{relativeDirectory}")); - config.MigrateAndValidate(); - Logger.Log($"Loaded {config.name}"); if (!SystemDict.ContainsKey(config.starSystem)) { // Since we didn't load it earlier there shouldn't be a star system config var starSystemConfig = mod.ModHelper.Storage.Load($"systems/{config.starSystem}.json"); - starSystemConfig.FixCoordinates(); if (starSystemConfig == null) starSystemConfig = new StarSystemConfig(); else Logger.LogWarning($"Loaded system config for {config.starSystem}. Why wasn't this loaded earlier?"); + starSystemConfig.FixCoordinates(); + var system = new NewHorizonsSystem(config.starSystem, starSystemConfig, mod); SystemDict.Add(config.starSystem, system); @@ -473,6 +472,9 @@ namespace NewHorizons BodyDict.Add(config.starSystem, new List()); } + // Has to happen after we make sure theres a system config + config.MigrateAndValidate(); + body = new NewHorizonsBody(config, mod, relativeDirectory); } catch (Exception e)