Dedicated servers can use autorestart

This commit is contained in:
Joonas Rikkonen
2017-07-24 21:21:00 +03:00
parent 379c65e07d
commit aaea8bc709
7 changed files with 88 additions and 25 deletions
@@ -408,10 +408,10 @@ namespace Barotrauma.Networking
initiatedStartGame = false;
}
}
else if (autoRestart && Screen.Selected == GameMain.NetLobbyScreen && connectedClients.Count>0)
else if (autoRestart && Screen.Selected == GameMain.NetLobbyScreen && connectedClients.Count > 0)
{
AutoRestartTimer -= deltaTime;
if (AutoRestartTimer < 0.0f && GameMain.NetLobbyScreen.StartButtonEnabled)
AutoRestartTimer -= deltaTime;
if (AutoRestartTimer < 0.0f && !initiatedStartGame)
{
StartGame();
}
@@ -1057,6 +1057,7 @@ namespace Barotrauma.Networking
private IEnumerable<object> InitiateStartGame(Submarine selectedSub, Submarine selectedShuttle, GameModePreset selectedMode)
{
initiatedStartGame = true;
GameMain.NetLobbyScreen.StartButtonEnabled = false;
if (connectedClients.Any())
@@ -1113,9 +1114,7 @@ namespace Barotrauma.Networking
}
private IEnumerable<object> StartGame(Submarine selectedSub, Submarine selectedShuttle, GameModePreset selectedMode)
{
initiatedStartGame = true;
{
entityEventManager.Clear();
GameMain.NetLobbyScreen.StartButtonEnabled = false;
@@ -1353,7 +1352,12 @@ namespace Barotrauma.Networking
Mission mission = GameMain.GameSession.Mission;
GameMain.GameSession.gameMode.End(endMessage);
if (autoRestart) AutoRestartTimer = AutoRestartInterval;
if (autoRestart)
{
AutoRestartTimer = AutoRestartInterval;
//send a netlobby update to get the clients' autorestart timers up to date
GameMain.NetLobbyScreen.LastUpdateID++;
}
if (SaveServerLogs) log.Save();
@@ -120,7 +120,7 @@ namespace Barotrauma.Networking
public float AutoRestartInterval
{
get;
private set;
set;
}
[HasDefaultValue(true, true)]
@@ -166,7 +166,7 @@ namespace Barotrauma.Networking
public bool AutoRestart
{
get { return (connectedClients.Count != 0) && autoRestart; }
get { return autoRestart; }
set
{
autoRestart = value;
@@ -236,6 +236,8 @@ namespace Barotrauma.Networking
doc.Root.SetAttributeValue("maxplayers", maxPlayers);
doc.Root.SetAttributeValue("enableupnp", config.EnableUPnP);
doc.Root.SetAttributeValue("autorestart", autoRestart);
doc.Root.SetAttributeValue("SubSelection", subSelectionMode.ToString());
doc.Root.SetAttributeValue("ModeSelection", modeSelectionMode.ToString());
@@ -279,6 +281,14 @@ namespace Barotrauma.Networking
ObjectProperties = ObjectProperty.InitProperties(this, doc.Root);
AutoRestart = ToolBox.GetAttributeBool(doc.Root, "autorestart", false);
#if CLIENT
if (autoRestart)
{
GameMain.NetLobbyScreen.SetAutoRestart(autoRestart, AutoRestartInterval);
}
#endif
subSelectionMode = SelectionMode.Manual;
Enum.TryParse<SelectionMode>(ToolBox.GetAttributeString(doc.Root, "SubSelection", "Manual"), out subSelectionMode);
Voting.AllowSubVoting = subSelectionMode == SelectionMode.Vote;