Fix singleplayer maps always being generated with seed 0. (Thanks McBean56545)

This commit is contained in:
UnknownShadow200 2016-02-11 07:47:38 +11:00
parent 53bf3e7b27
commit 96da756918
2 changed files with 11 additions and 2 deletions

View File

@ -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 );
}
}
}

View File

@ -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)";