Unstable v0.9.707.0

This commit is contained in:
Juan Pablo Arce
2020-02-11 16:07:21 -03:00
parent 8324d20464
commit 2783125162
68 changed files with 1460 additions and 1219 deletions
@@ -283,6 +283,15 @@ namespace Barotrauma
GameMain.NetLobbyScreen.SetBotCount(botCount);
NewMessage("Set the number of bots to " + botCount, Color.White);
});
AssignOnClientRequestExecute("botcount", (Client client, Vector2 cursorPos, string[] args) =>
{
if (args.Length < 1 || GameMain.Server == null) return;
int botCount = GameMain.Server.ServerSettings.BotCount;
int.TryParse(args[0], out botCount);
GameMain.NetLobbyScreen.SetBotCount(botCount);
NewMessage(client.Name + " set the number of bots to " + botCount, Color.White);
GameMain.Server.SendConsoleMessage("Set the number of bots to " + botCount, client);
});
AssignOnExecute("botspawnmode", (string[] args) =>
{
@@ -297,6 +306,20 @@ namespace Barotrauma
NewMessage("\"" + args[0] + "\" is not a valid bot spawn mode. (Valid modes are Fill and Normal)", Color.White);
}
});
AssignOnClientRequestExecute("botspawnmode", (Client client, Vector2 cursorPos, string[] args) =>
{
if (args.Length < 1 || GameMain.Server == null) return;
if (Enum.TryParse(args[0], true, out BotSpawnMode spawnMode))
{
GameMain.NetLobbyScreen.SetBotSpawnMode(spawnMode);
NewMessage(client.Name + " set bot spawn mode to " + spawnMode, Color.White);
GameMain.Server.SendConsoleMessage("Set bot spawn mode to " + spawnMode, client);
}
else
{
GameMain.Server.SendConsoleMessage("\"" + args[0] + "\" is not a valid bot spawn mode. (Valid modes are Fill and Normal)", client);
}
});
AssignOnExecute("killdisconnectedtimer", (string[] args) =>
{
@@ -304,13 +327,29 @@ namespace Barotrauma
float seconds = GameMain.Server.ServerSettings.KillDisconnectedTime;
if (float.TryParse(args[0], out seconds))
{
NewMessage("Set kill disconnected timer to " + seconds + " seconds", Color.White);
seconds = Math.Max(0, seconds);
NewMessage("Set kill disconnected timer to " + ToolBox.SecondsToReadableTime(seconds), Color.White);
}
else
{
NewMessage("\"" + args[0] + "\" is not a valid duration.", Color.White);
}
});
AssignOnClientRequestExecute("killdisconnectedtimer", (Client client, Vector2 cursorPos, string[] args) =>
{
if (args.Length < 1 || GameMain.Server == null) return;
float seconds = GameMain.Server.ServerSettings.KillDisconnectedTime;
if (float.TryParse(args[0], out seconds))
{
seconds = Math.Max(0, seconds);
GameMain.Server.SendConsoleMessage("Set kill disconnected timer to " + ToolBox.SecondsToReadableTime(seconds), client);
NewMessage(client.Name + " set kill disconnected timer to " + ToolBox.SecondsToReadableTime(seconds), Color.White);
}
else
{
GameMain.Server.SendConsoleMessage("\"" + args[0] + "\" is not a valid duration.", client);
}
});
AssignOnExecute("autorestart", (string[] args) =>
{
@@ -329,10 +368,6 @@ namespace Barotrauma
if (GameMain.Server.ServerSettings.AutoRestartInterval <= 0) GameMain.Server.ServerSettings.AutoRestartInterval = 10;
GameMain.Server.ServerSettings.AutoRestartTimer = GameMain.Server.ServerSettings.AutoRestartInterval;
GameMain.Server.ServerSettings.AutoRestart = enabled;
#if CLIENT
//TODO: reimplement
GameMain.NetLobbyScreen.SetAutoRestart(enabled, GameMain.Server.AutoRestartTimer);
#endif
GameMain.NetLobbyScreen.LastUpdateID++;
}
NewMessage(GameMain.Server.ServerSettings.AutoRestart ? "Automatic restart enabled." : "Automatic restart disabled.", Color.White);
@@ -357,10 +392,6 @@ namespace Barotrauma
GameMain.Server.ServerSettings.AutoRestart = false;
NewMessage("Autorestart disabled.", Color.White);
}
#if CLIENT
//TODO: redo again
GameMain.NetLobbyScreen.SetAutoRestart(GameMain.Server.AutoRestart, GameMain.Server.AutoRestartTimer);
#endif
GameMain.NetLobbyScreen.LastUpdateID++;
}
}
@@ -677,6 +708,13 @@ namespace Barotrauma
GameMain.Server.ServerSettings.KarmaEnabled = !GameMain.Server.ServerSettings.KarmaEnabled;
NewMessage(GameMain.Server.ServerSettings.KarmaEnabled ? "Karma system enabled." : "Karma system disabled.", Color.LightGreen);
});
AssignOnClientRequestExecute("togglekarma", (Client client, Vector2 cursorWorldPos, string[] args) =>
{
if (GameMain.Server == null) return;
GameMain.Server.ServerSettings.KarmaEnabled = !GameMain.Server.ServerSettings.KarmaEnabled;
NewMessage((GameMain.Server.ServerSettings.KarmaEnabled ? "Karma system enabled by " : "Karma system disabled by ") + client.Name, Color.LightGreen);
GameMain.Server.SendConsoleMessage(GameMain.Server.ServerSettings.KarmaEnabled ? "Karma system enabled." : "Karma system disabled.", client);
});
AssignOnExecute("resetkarma", (string[] args) =>
{
@@ -91,7 +91,10 @@ namespace Barotrauma.Items.Components
}
existingWire.RemoveConnection(item);
item.GetComponent<ConnectionPanel>()?.DisconnectedWires.Add(existingWire);
if (existingWire.Item.ParentInventory == null)
{
item.GetComponent<ConnectionPanel>()?.DisconnectedWires.Add(existingWire);
}
if (!wires.Any(w => w.Contains(existingWire)))
{
@@ -103,8 +106,14 @@ namespace Barotrauma.Items.Components
GameServer.Log(c.Character.LogName + " disconnected a wire from " +
Connections[i].Item.Name + " (" + Connections[i].Name + ")", ServerLog.MessageType.Wiring);
if (!clientSideDisconnectedWires.Contains(existingWire))
if (existingWire.Item.ParentInventory != null)
{
//in an inventory and not connected to anything -> the wire cannot have any nodes
existingWire.ClearConnections();
}
else if (!clientSideDisconnectedWires.Contains(existingWire))
{
//not in an inventory, not connected to anything, not hanging loose from any panel -> must be dropped
existingWire.Item.Drop(c.Character);
}
}
@@ -145,7 +154,8 @@ namespace Barotrauma.Items.Components
{
if (disconnectedWire.Connections[0] == null &&
disconnectedWire.Connections[1] == null &&
!clientSideDisconnectedWires.Contains(disconnectedWire))
!clientSideDisconnectedWires.Contains(disconnectedWire) &&
disconnectedWire.Item.ParentInventory == null)
{
disconnectedWire.Item.Drop(c.Character);
GameServer.Log(c.Character.LogName + " dropped " + disconnectedWire.Name, ServerLog.MessageType.Inventory);
@@ -627,7 +627,7 @@ namespace Barotrauma.Networking
//game already started -> send start message immediately
if (gameStarted)
{
SendStartMessage(roundStartSeed, Submarine.MainSub, GameMain.GameSession.GameMode.Preset, connectedClient);
SendStartMessage(roundStartSeed, GameMain.GameSession.Level.Seed, Submarine.MainSub, GameMain.GameSession.GameMode.Preset, connectedClient, true);
}
}
break;
@@ -1796,6 +1796,8 @@ namespace Barotrauma.Networking
campaign.Map.SelectRandomLocation(preferUndiscovered: true);
}
SendStartMessage(roundStartSeed, campaign.Map.SelectedConnection.Level.Seed, Submarine.MainSub, GameMain.GameSession.GameMode.Preset, connectedClients, false);
GameMain.GameSession.StartRound(campaign.Map.SelectedConnection.Level,
reloadSub: true,
loadSecondSub: teamCount > 1,
@@ -1808,6 +1810,8 @@ namespace Barotrauma.Networking
}
else
{
SendStartMessage(roundStartSeed, GameMain.NetLobbyScreen.LevelSeed, Submarine.MainSub, GameMain.GameSession.GameMode.Preset, connectedClients, false);
GameMain.GameSession.StartRound(GameMain.NetLobbyScreen.LevelSeed, serverSettings.SelectedLevelDifficulty, teamCount > 1);
Log("Game mode: " + selectedMode.Name, ServerLog.MessageType.ServerMessage);
Log("Submarine: " + selectedSub.Name, ServerLog.MessageType.ServerMessage);
@@ -1946,7 +1950,7 @@ namespace Barotrauma.Networking
GameAnalyticsManager.AddDesignEvent("Traitors:" + (TraitorManager == null ? "Disabled" : "Enabled"));
SendStartMessage(roundStartSeed, Submarine.MainSub, GameMain.GameSession.GameMode.Preset, connectedClients);
SendRoundStartFinalize(connectedClients);
yield return CoroutineStatus.Running;
@@ -1965,22 +1969,21 @@ namespace Barotrauma.Networking
yield return CoroutineStatus.Success;
}
private void SendStartMessage(int seed, Submarine selectedSub, GameModePreset selectedMode, List<Client> clients)
private void SendStartMessage(int seed, string levelSeed, Submarine selectedSub, GameModePreset selectedMode, List<Client> clients, bool includesFinalize)
{
foreach (Client client in clients)
{
SendStartMessage(seed, selectedSub, selectedMode, client);
SendStartMessage(seed, levelSeed, selectedSub, selectedMode, client, includesFinalize);
}
}
private void SendStartMessage(int seed, Submarine selectedSub, GameModePreset selectedMode, Client client)
private void SendStartMessage(int seed, string levelSeed, Submarine selectedSub, GameModePreset selectedMode, Client client, bool includesFinalize)
{
IWriteMessage msg = new WriteOnlyMessage();
msg.Write((byte)ServerPacketHeader.STARTGAME);
msg.Write(seed);
msg.Write(GameMain.GameSession.Level.Seed);
msg.Write(GameMain.GameSession.Level.EqualityCheckVal);
msg.Write(levelSeed);
msg.Write(serverSettings.SelectedLevelDifficulty);
msg.Write((byte)GameMain.Config.LosMode);
@@ -2020,6 +2023,32 @@ namespace Barotrauma.Networking
serverSettings.WriteMonsterEnabled(msg);
msg.Write(includesFinalize); msg.WritePadBits();
if (includesFinalize)
{
msg.Write(GameMain.GameSession.Level.EqualityCheckVal);
GameMain.GameSession.Mission?.ServerWriteInitial(msg, client);
}
//GameMain.GameSession.Mission?.ServerWriteInitial(msg, client);
serverPeer.Send(msg, client.Connection, DeliveryMethod.Reliable);
}
private void SendRoundStartFinalize(List<Client> clients)
{
foreach (Client client in clients)
{
SendRoundStartFinalize(client);
}
}
private void SendRoundStartFinalize(Client client)
{
IWriteMessage msg = new WriteOnlyMessage();
msg.Write((byte)ServerPacketHeader.STARTGAMEFINALIZE);
msg.Write(GameMain.GameSession.Level.EqualityCheckVal);
GameMain.GameSession.Mission?.ServerWriteInitial(msg, client);
serverPeer.Send(msg, client.Connection, DeliveryMethod.Reliable);
@@ -184,29 +184,25 @@ namespace Barotrauma.Networking
{
XDocument doc = new XDocument(new XElement("serversettings"));
SerializableProperty.SerializeProperties(this, doc.Root, true);
doc.Root.SetAttributeValue("name", ServerName);
doc.Root.SetAttributeValue("public", IsPublic);
doc.Root.SetAttributeValue("port", Port);
#if USE_STEAM
doc.Root.SetAttributeValue("queryport", QueryPort);
#endif
doc.Root.SetAttributeValue("password", password ?? "");
doc.Root.SetAttributeValue("enableupnp", EnableUPnP);
doc.Root.SetAttributeValue("autorestart", autoRestart);
if (!string.IsNullOrEmpty(password))
{
doc.Root.SetAttributeValue("password", password);
}
doc.Root.SetAttributeValue("LevelDifficulty", ((int)selectedLevelDifficulty).ToString());
doc.Root.SetAttributeValue("ServerMessage", ServerMessageText);
doc.Root.SetAttributeValue("AllowedRandomMissionTypes", string.Join(",", AllowedRandomMissionTypes));
doc.Root.SetAttributeValue("AllowedClientNameChars", string.Join(",", AllowedClientNameChars.Select(c => c.First + "-" + c.Second)));
doc.Root.SetAttributeValue("ServerMessage", ServerMessageText);
SerializableProperty.SerializeProperties(this, doc.Root, true);
XmlWriterSettings settings = new XmlWriterSettings
{
@@ -15,10 +15,10 @@ namespace Barotrauma
msg.Write(SimPosition.Y);
#if DEBUG
if (Math.Abs(body.LinearVelocity.X) > MaxVel ||
Math.Abs(body.LinearVelocity.Y) > MaxVel)
if (Math.Abs(FarseerBody.LinearVelocity.X) > MaxVel ||
Math.Abs(FarseerBody.LinearVelocity.Y) > MaxVel)
{
DebugConsole.ThrowError("Item velocity out of range (" + body.LinearVelocity + ")");
DebugConsole.ThrowError("Item velocity out of range (" + FarseerBody.LinearVelocity + ")");
}
#endif
@@ -27,20 +27,20 @@ namespace Barotrauma
if (!FarseerBody.FixedRotation)
{
msg.WriteRangedSingle(MathUtils.WrapAngleTwoPi(body.Rotation), 0.0f, MathHelper.TwoPi, 8);
msg.WriteRangedSingle(MathUtils.WrapAngleTwoPi(FarseerBody.Rotation), 0.0f, MathHelper.TwoPi, 8);
}
if (FarseerBody.Awake)
{
body.Enabled = true;
body.LinearVelocity = new Vector2(
MathHelper.Clamp(body.LinearVelocity.X, -MaxVel, MaxVel),
MathHelper.Clamp(body.LinearVelocity.Y, -MaxVel, MaxVel));
msg.WriteRangedSingle(body.LinearVelocity.X, -MaxVel, MaxVel, 12);
msg.WriteRangedSingle(body.LinearVelocity.Y, -MaxVel, MaxVel, 12);
FarseerBody.Enabled = true;
FarseerBody.LinearVelocity = new Vector2(
MathHelper.Clamp(FarseerBody.LinearVelocity.X, -MaxVel, MaxVel),
MathHelper.Clamp(FarseerBody.LinearVelocity.Y, -MaxVel, MaxVel));
msg.WriteRangedSingle(FarseerBody.LinearVelocity.X, -MaxVel, MaxVel, 12);
msg.WriteRangedSingle(FarseerBody.LinearVelocity.Y, -MaxVel, MaxVel, 12);
if (!FarseerBody.FixedRotation)
{
body.AngularVelocity = MathHelper.Clamp(body.AngularVelocity, -MaxAngularVel, MaxAngularVel);
msg.WriteRangedSingle(body.AngularVelocity, -MaxAngularVel, MaxAngularVel, 8);
FarseerBody.AngularVelocity = MathHelper.Clamp(FarseerBody.AngularVelocity, -MaxAngularVel, MaxAngularVel);
msg.WriteRangedSingle(FarseerBody.AngularVelocity, -MaxAngularVel, MaxAngularVel, 8);
}
}