Skip to content

Commit

Permalink
Fixed bug in getPlanetDefinition which would crash the plugin when us…
Browse files Browse the repository at this point in the history
…ing mandatory planets
  • Loading branch information
thorwin99 committed Aug 30, 2020
1 parent 711c6dd commit 84466e2
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 9 deletions.
12 changes: 6 additions & 6 deletions SEWorldGenPlugin/GUI/PluginWorldSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions SEWorldGenPlugin/Generator/SystemGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)))
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,21 @@ 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();
}
else
{
GeneratorSettings = new GeneratorSettings();
}
}
else
{
GeneratorSettings = new GeneratorSettings();
}

}

[ProtoMember(1)]
Expand Down

0 comments on commit 84466e2

Please sign in to comment.