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:
@@ -67,6 +67,12 @@ namespace Barotrauma
|
||||
GameMain.NetLobbyScreen.LevelSeed = string.Join(" ", args);
|
||||
}));
|
||||
|
||||
commands.Add(new Command("randomizeseed", "randomizeseed: Toggles level seed randomization on/off.", (string[] args) =>
|
||||
{
|
||||
GameMain.Server.RandomizeSeed = !GameMain.Server.RandomizeSeed;
|
||||
NewMessage((GameMain.Server.RandomizeSeed ? "Enabled" : "Disabled") + " level seed randomization.", Color.Cyan);
|
||||
}));
|
||||
|
||||
commands.Add(new Command("gamemode", "gamemode [name]/[index]: Select the game mode for the next round. The parameter can either be the name or the index number of the game mode (0 = sandbox, 1 = mission, etc).", (string[] args) =>
|
||||
{
|
||||
int index = -1;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Microsoft.Xna.Framework;
|
||||
using Barotrauma.Networking;
|
||||
using Microsoft.Xna.Framework;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@@ -71,9 +72,10 @@ namespace Barotrauma
|
||||
public int MissionTypeIndex
|
||||
{
|
||||
get { return missionTypeIndex; }
|
||||
set {
|
||||
set
|
||||
{
|
||||
lastUpdateID++;
|
||||
missionTypeIndex = Math.Max(0, Math.Min(Mission.MissionTypes.Count()-1, value));
|
||||
missionTypeIndex = Math.Max(0, Math.Min(Mission.MissionTypes.Count() - 1, value));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -172,5 +174,21 @@ namespace Barotrauma
|
||||
|
||||
lastUpdateID++;
|
||||
}
|
||||
|
||||
public void RandomizeSettings()
|
||||
{
|
||||
if (GameMain.Server.RandomizeSeed) LevelSeed = ToolBox.RandomSeed(8);
|
||||
|
||||
if (GameMain.Server.SubSelectionMode == SelectionMode.Random)
|
||||
{
|
||||
var nonShuttles = Submarine.SavedSubmarines.FindAll(c => !c.HasTag(SubmarineTag.Shuttle) && !c.HasTag(SubmarineTag.HideInMenus));
|
||||
SelectedSub = nonShuttles[Rand.Range(0, nonShuttles.Count)];
|
||||
}
|
||||
if (GameMain.Server.ModeSelectionMode == SelectionMode.Random)
|
||||
{
|
||||
var allowedGameModes = Array.FindAll(gameModes, m => !m.IsSinglePlayer && m.Name != "Campaign");
|
||||
SelectedModeName = allowedGameModes[Rand.Range(0, allowedGameModes.Length)].Name;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user