From 84466e298a6d06d69fa9372c6fbf85701feb7f22 Mon Sep 17 00:00:00 2001 From: Thorwin Vogt Date: Mon, 31 Aug 2020 00:50:53 +0200 Subject: [PATCH] Fixed bug in getPlanetDefinition which would crash the plugin when using mandatory planets --- SEWorldGenPlugin/GUI/PluginWorldSettings.cs | 12 ++++++------ SEWorldGenPlugin/Generator/SystemGenerator.cs | 4 ++-- .../ObjectBuilders/MyObjectBuilder_PluginSettings.cs | 9 ++++++++- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/SEWorldGenPlugin/GUI/PluginWorldSettings.cs b/SEWorldGenPlugin/GUI/PluginWorldSettings.cs index 4301b16..07a493c 100644 --- a/SEWorldGenPlugin/GUI/PluginWorldSettings.cs +++ b/SEWorldGenPlugin/GUI/PluginWorldSettings.cs @@ -134,12 +134,12 @@ protected override void BuildControls() if (m_isNewGame) { - PlSettings = new MyObjectBuilder_PluginSettings(); - PlSettings.GeneratorSettings.FirstPlanetCenter = MySettings.Static.Settings.GeneratorSettings.FirstPlanetCenter; - PlSettings.GeneratorSettings.PlanetSettings.BlacklistedPlanets = MySettings.Static.Settings.GeneratorSettings.PlanetSettings.BlacklistedPlanets; - PlSettings.GeneratorSettings.PlanetSettings.Moons = MySettings.Static.Settings.GeneratorSettings.PlanetSettings.Moons; - PlSettings.GeneratorSettings.PlanetSettings.MandatoryPlanets = MySettings.Static.Settings.GeneratorSettings.PlanetSettings.MandatoryPlanets; - PlSettings.GeneratorSettings.PlanetSettings.GasGiants = MySettings.Static.Settings.GeneratorSettings.PlanetSettings.GasGiants; + PlSettings = MySettings.Static.Settings.copy(); + //PlSettings.GeneratorSettings.FirstPlanetCenter = MySettings.Static.Settings.GeneratorSettings.FirstPlanetCenter; + //PlSettings.GeneratorSettings.PlanetSettings.BlacklistedPlanets = MySettings.Static.Settings.GeneratorSettings.PlanetSettings.BlacklistedPlanets; + //PlSettings.GeneratorSettings.PlanetSettings.Moons = MySettings.Static.Settings.GeneratorSettings.PlanetSettings.Moons; + //PlSettings.GeneratorSettings.PlanetSettings.MandatoryPlanets = MySettings.Static.Settings.GeneratorSettings.PlanetSettings.MandatoryPlanets; + //PlSettings.GeneratorSettings.PlanetSettings.GasGiants = MySettings.Static.Settings.GeneratorSettings.PlanetSettings.GasGiants; //PlSettings.GeneratorSettings.PlanetSettings.PlanetNameFormat = MySettings.Static.Settings.GeneratorSettings.PlanetSettings.PlanetNameFormat; //PlSettings.GeneratorSettings.PlanetSettings.MoonNameFormat = MySettings.Static.Settings.GeneratorSettings.PlanetSettings.MoonNameFormat; //PlSettings.GeneratorSettings.BeltSettings.BeltNameFormat = MySettings.Static.Settings.GeneratorSettings.BeltSettings.BeltNameFormat; diff --git a/SEWorldGenPlugin/Generator/SystemGenerator.cs b/SEWorldGenPlugin/Generator/SystemGenerator.cs index 6a4804b..fde5669 100644 --- a/SEWorldGenPlugin/Generator/SystemGenerator.cs +++ b/SEWorldGenPlugin/Generator/SystemGenerator.cs @@ -246,7 +246,7 @@ private void GeneratePlanet(int index, long distance, int totalObjects, ref int string name = SettingsSession.Static.Settings.GeneratorSettings.PlanetSettings.PlanetNameFormat .SetProperty("ObjectNumber", planetIndex + 1) - .SetProperty("ObjectNumberGreek", greek_letters[planetIndex]) + .SetProperty("ObjectNumberGreek", greek_letters[planetIndex % greek_letters.Length]) .SetProperty("ObjectNumberRoman", ConvertNumberToRoman(planetIndex + 1)) .SetProperty("ObjectLetterLower", (char)('a' + (planetIndex % 26))) .SetProperty("ObjectLetterUpper", (char)('A' + (planetIndex % 26))) @@ -330,7 +330,7 @@ private MyPlanetGeneratorDefinition GetPlanetDefinition(float maximumSize, bool float size; MyPlanetGeneratorDefinition def; - if(m_mandatoryPlanets.Count != 0 && !ignoreMandatory) + if(m_mandatoryPlanets.Count > 0 && !ignoreMandatory) { def = m_mandatoryPlanets[0]; m_mandatoryPlanets.RemoveAt(0); diff --git a/SEWorldGenPlugin/ObjectBuilders/MyObjectBuilder_PluginSettings.cs b/SEWorldGenPlugin/ObjectBuilders/MyObjectBuilder_PluginSettings.cs index 1162153..6e94696 100644 --- a/SEWorldGenPlugin/ObjectBuilders/MyObjectBuilder_PluginSettings.cs +++ b/SEWorldGenPlugin/ObjectBuilders/MyObjectBuilder_PluginSettings.cs @@ -11,7 +11,8 @@ public MyObjectBuilder_PluginSettings() { Enable = false; if(MySettings.Static != null) - if(MySettings.Static.Settings != null) + { + if (MySettings.Static.Settings != null) { GeneratorSettings = MySettings.Static.Settings.GeneratorSettings.copy(); } @@ -19,6 +20,12 @@ public MyObjectBuilder_PluginSettings() { GeneratorSettings = new GeneratorSettings(); } + } + else + { + GeneratorSettings = new GeneratorSettings(); + } + } [ProtoMember(1)]