diff --git a/ClassicalSharp/2D/Screens/Menu/GenLevelScreen.cs b/ClassicalSharp/2D/Screens/Menu/GenLevelScreen.cs index 2d3d92d32..c91767b0b 100644 --- a/ClassicalSharp/2D/Screens/Menu/GenLevelScreen.cs +++ b/ClassicalSharp/2D/Screens/Menu/GenLevelScreen.cs @@ -135,7 +135,7 @@ namespace ClassicalSharp { void GenerateMap( IMapGenerator gen ) { SinglePlayerServer server = (SinglePlayerServer)game.Network; int width = GetInt( 0 ), height = GetInt( 1 ); - int length = GetInt( 2 ), seed = GetInt( 3 ); + int length = GetInt( 2 ), seed = GetSeedInt( 3 ); long volume = (long)width * height * length; if( volume > 800 * 800 * 800 ) { @@ -153,5 +153,14 @@ namespace ClassicalSharp { return 0; return text == "" ? 0 : Int32.Parse( text ); } + + int GetSeedInt( int index ) { + string text = inputs[index].GetText(); + if( text == "" ) return new Random().Next(); + + if( !inputs[index].Validator.IsValidValue( text ) ) + return 0; + return text == "" ? 0 : Int32.Parse( text ); + } } } \ No newline at end of file diff --git a/ClassicalSharp/2D/Widgets/Menu/MenuInputValidator.cs b/ClassicalSharp/2D/Widgets/Menu/MenuInputValidator.cs index 0300359b9..3ae7c2d3b 100644 --- a/ClassicalSharp/2D/Widgets/Menu/MenuInputValidator.cs +++ b/ClassicalSharp/2D/Widgets/Menu/MenuInputValidator.cs @@ -72,7 +72,7 @@ namespace ClassicalSharp { public sealed class SeedValidator : IntegerValidator { - public SeedValidator() : base( 0, 0 ) { } + public SeedValidator() : base( int.MinValue, int.MaxValue ) { } protected override void SetRange() { Range = "&7(an integer)";