Fixes to server settings. Closes #225

- Selected mode and mission type settings are saved and loaded.
- RandomizeSeed setting can be changed via the debug console and it also has an effect in the dedicated server.
- Dedicated server randomizes sub & mode settings if their selection modes are set to random.
This commit is contained in:
Joonas Rikkonen
2018-01-25 15:09:44 +02:00
parent 490e373c7a
commit a1ccf501c7
6 changed files with 70 additions and 19 deletions
@@ -500,14 +500,6 @@ namespace Barotrauma
if (GameModePreset.list.Count > 0 && modeList.Selected == null) modeList.Select(0);
GameMain.Server.Voting.ResetVotes(GameMain.Server.ConnectedClients);
if (GameMain.Server.RandomizeSeed) LevelSeed = ToolBox.RandomSeed(8);
if (GameMain.Server.SubSelectionMode == SelectionMode.Random)
{
var nonShuttles = subList.children.FindAll(c => c.UserData is Submarine && !((Submarine)c.UserData).HasTag(SubmarineTag.Shuttle));
subList.Select(nonShuttles[Rand.Range(0, nonShuttles.Count)].UserData);
}
if (GameMain.Server.ModeSelectionMode == SelectionMode.Random) modeList.Select(Rand.Range(0, modeList.CountChildren));
}
else if (GameMain.Client != null)
{
@@ -526,6 +518,23 @@ namespace Barotrauma
base.Select();
}
public void RandomizeSettings()
{
if (GameMain.Server == null) return;
if (GameMain.Server.RandomizeSeed) LevelSeed = ToolBox.RandomSeed(8);
if (GameMain.Server.SubSelectionMode == SelectionMode.Random)
{
var nonShuttles = subList.children.FindAll(c => c.UserData is Submarine && !((Submarine)c.UserData).HasTag(SubmarineTag.Shuttle));
subList.Select(nonShuttles[Rand.Range(0, nonShuttles.Count)].UserData);
}
if (GameMain.Server.ModeSelectionMode == SelectionMode.Random)
{
var allowedGameModes = GameModePreset.list.FindAll(m => !m.IsSinglePlayer && m.Name != "Campaign");
modeList.Select(allowedGameModes[Rand.Range(0, allowedGameModes.Count)]);
}
}
public void ShowSpectateButton()
{