mirror of
https://github.com/unmojang/drasl.git
synced 2025-09-09 07:06:52 -04:00
Merge pull request #134 from evan-goode/evan-goode/fix-unlimited-max-player-count
config: allow unlimited max player count (-1)
This commit is contained in:
commit
cda9c270f9
@ -182,8 +182,8 @@ func CleanConfig(config *Config) error {
|
|||||||
if _, err := os.Open(config.DataDirectory); err != nil {
|
if _, err := os.Open(config.DataDirectory); err != nil {
|
||||||
return fmt.Errorf("Couldn't open DataDirectory: %s", err)
|
return fmt.Errorf("Couldn't open DataDirectory: %s", err)
|
||||||
}
|
}
|
||||||
if config.DefaultMaxPlayerCount < 0 {
|
if config.DefaultMaxPlayerCount < 0 && config.DefaultMaxPlayerCount != Constants.MaxPlayerCountUnlimited {
|
||||||
return errors.New("DefaultMaxPlayerCount must be >= 0")
|
return fmt.Errorf("DefaultMaxPlayerCount must be >= 0, or %d to indicate unlimited players", Constants.MaxPlayerCountUnlimited)
|
||||||
}
|
}
|
||||||
if config.RegistrationExistingPlayer.Allow {
|
if config.RegistrationExistingPlayer.Allow {
|
||||||
if config.RegistrationExistingPlayer.Nickname == "" {
|
if config.RegistrationExistingPlayer.Nickname == "" {
|
||||||
|
@ -51,6 +51,14 @@ func TestConfig(t *testing.T) {
|
|||||||
config.ListenAddress = ""
|
config.ListenAddress = ""
|
||||||
assert.NotNil(t, CleanConfig(config))
|
assert.NotNil(t, CleanConfig(config))
|
||||||
|
|
||||||
|
config = configTestConfig(sd)
|
||||||
|
config.DefaultMaxPlayerCount = Constants.MaxPlayerCountUseDefault
|
||||||
|
assert.NotNil(t, CleanConfig(config))
|
||||||
|
|
||||||
|
config = configTestConfig(sd)
|
||||||
|
config.DefaultMaxPlayerCount = Constants.MaxPlayerCountUnlimited
|
||||||
|
assert.Nil(t, CleanConfig(config))
|
||||||
|
|
||||||
config = configTestConfig(sd)
|
config = configTestConfig(sd)
|
||||||
config.DataDirectory = "/tmp/DraslInvalidDataDirectoryNothingHere"
|
config.DataDirectory = "/tmp/DraslInvalidDataDirectoryNothingHere"
|
||||||
assert.NotNil(t, CleanConfig(config))
|
assert.NotNil(t, CleanConfig(config))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user