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:
@@ -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()
|
||||
{
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -201,7 +201,9 @@ namespace Barotrauma.Networking
|
||||
Log("Server started", ServerLog.MessageType.ServerMessage);
|
||||
|
||||
GameMain.NetLobbyScreen.Select();
|
||||
GameMain.NetLobbyScreen.RandomizeSettings();
|
||||
started = true;
|
||||
|
||||
yield return CoroutineStatus.Success;
|
||||
}
|
||||
|
||||
@@ -1480,22 +1482,21 @@ namespace Barotrauma.Networking
|
||||
}
|
||||
}
|
||||
|
||||
CoroutineManager.StartCoroutine(EndCinematic(),"EndCinematic");
|
||||
}
|
||||
CoroutineManager.StartCoroutine(EndCinematic(), "EndCinematic");
|
||||
|
||||
GameMain.NetLobbyScreen.RandomizeSettings();
|
||||
}
|
||||
|
||||
public IEnumerable<object> EndCinematic()
|
||||
{
|
||||
float endPreviewLength = 10.0f;
|
||||
|
||||
var cinematic = new TransitionCinematic(Submarine.MainSub, GameMain.GameScreen.Cam, endPreviewLength);
|
||||
//float secondsLeft = endPreviewLength;
|
||||
|
||||
do
|
||||
{
|
||||
//secondsLeft -= CoroutineManager.UnscaledDeltaTime;
|
||||
|
||||
yield return CoroutineStatus.Running;
|
||||
} while (cinematic.Running);//(secondsLeft > 0.0f);
|
||||
} while (cinematic.Running);
|
||||
#if CLIENT
|
||||
SoundPlayer.OverrideMusicType = null;
|
||||
#endif
|
||||
|
||||
@@ -79,10 +79,9 @@ namespace Barotrauma.Networking
|
||||
public bool RandomizeSeed
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
set;
|
||||
}
|
||||
|
||||
|
||||
[Serialize(300.0f, true)]
|
||||
public float RespawnInterval
|
||||
{
|
||||
@@ -241,6 +240,20 @@ namespace Barotrauma.Networking
|
||||
set;
|
||||
}
|
||||
|
||||
[Serialize("Sandbox", true)]
|
||||
public string GameMode
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
[Serialize("Random", true)]
|
||||
public string MissionType
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
private void SaveSettings()
|
||||
{
|
||||
XDocument doc = new XDocument(new XElement("serversettings"));
|
||||
@@ -327,6 +340,8 @@ namespace Barotrauma.Networking
|
||||
{
|
||||
#if SERVER
|
||||
GameMain.NetLobbyScreen.ServerName = doc.Root.GetAttributeString("name", "");
|
||||
GameMain.NetLobbyScreen.SelectedModeName = GameMode;
|
||||
GameMain.NetLobbyScreen.MissionTypeName = MissionType;
|
||||
#endif
|
||||
GameMain.NetLobbyScreen.ServerMessageText = doc.Root.GetAttributeString("ServerMessage", "");
|
||||
}
|
||||
|
||||
@@ -26,5 +26,7 @@
|
||||
karmaenabled="False"
|
||||
SubSelection="Manual"
|
||||
ModeSelection="Manual"
|
||||
GameMode="SandBox"
|
||||
MissionType="Random"
|
||||
TraitorsEnabled="No"
|
||||
/>
|
||||
|
||||
Reference in New Issue
Block a user