-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed a bug that can cause an indexoutofbounds exception when generat…
…ing more belts than there are letters in the greek alphabet
- Loading branch information
Showing
3 changed files
with
3 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -213,7 +213,7 @@ private void GenerateBelt(long distance, ref int beltIndex) | |
|
||
string name = SettingsSession.Static.Settings.GeneratorSettings.BeltSettings.BeltNameFormat | ||
.SetProperty("ObjectNumber", beltIndex + 1) | ||
.SetProperty("ObjectNumberGreek", greek_letters[beltIndex]) | ||
.SetProperty("ObjectNumberGreek", greek_letters[beltIndex % greek_letters.Length]) | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
thorwin99
Author
Owner
|
||
.SetProperty("ObjectNumberRoman", ConvertNumberToRoman(beltIndex + 1)) | ||
.SetProperty("ObjectLetterLower", (char)('a' + (beltIndex % 26))) | ||
.SetProperty("ObjectLetterUpper", (char)('A' + (beltIndex % 26))); | ||
|
@@ -285,7 +285,7 @@ private MyPlanetMoonItem[] GenerateMoons(float planetSize, float surfaceGravity, | |
|
||
string name = SettingsSession.Static.Settings.GeneratorSettings.PlanetSettings.MoonNameFormat | ||
.SetProperty("ObjectNumber", i + 1) | ||
.SetProperty("ObjectNumberGreek", greek_letters[i]) | ||
.SetProperty("ObjectNumberGreek", greek_letters[i % greek_letters.Length]) | ||
.SetProperty("ObjectNumberRoman", ConvertNumberToRoman(i + 1)) | ||
.SetProperty("ObjectLetterLower", (char)('a' + (i % 26))) | ||
.SetProperty("ObjectLetterUpper", (char)('A' + (i % 26))) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
While this should fix the crash if there are more belts created than there are letters in the greek alphabet, wouldn't it then create 2x 'Belt Alpha', 2x 'Belt Beta' etc? From what I can tell, it just starts over with the first index again. This is going to be confusing. Also, at that point you already have 24 belts in your system for this to become a problem.
I'd rather see the number of generated belts capped at 24, so when the list of names is exhausted, no new belts will be generated. Alternatively, appending the name of any belts past the 24th by another signifier would be helpful, so you don't end up with confusing names. E.g. 'Belt Alpha' and 'Belt Alpha Alpha', 'Belt Alpha *', 'Belt Alpha Outer' etc. I highly doubt there is a need to go beyond 48 belts though, so capping it at twice the length of the greek alphabet is more than reasonable I think if you don't want to come up with even more identifiers.
As the crash should be fixed by this, any further changes are not urgent, just my two cents about the consequences of this change.