v0.19.8.0

This commit is contained in:
Juan Pablo Arce
2022-09-28 21:30:52 -03:00
parent fec8131243
commit 3ca584f2fc
152 changed files with 1931 additions and 1071 deletions
@@ -2,7 +2,6 @@
using Microsoft.Xna.Framework;
using System;
using System.Collections.Generic;
using System.Linq;
namespace Barotrauma.Networking
{
@@ -88,12 +87,13 @@ namespace Barotrauma.Networking
TextManager.Get("BanPermanent") : TextManager.GetWithVariable("BanExpires", "[time]", bannedPlayer.ExpirationTime.Value.ToString()),
font: GUIStyle.SmallFont);
LocalizedString reason = TextManager.GetServerMessage(bannedPlayer.Reason).Fallback(bannedPlayer.Reason);
var reasonText = new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), paddedPlayerFrame.RectTransform),
TextManager.Get("BanReason") + " " +
(string.IsNullOrEmpty(bannedPlayer.Reason) ? TextManager.Get("None") : bannedPlayer.Reason),
(string.IsNullOrEmpty(bannedPlayer.Reason) ? TextManager.Get("None") : reason),
font: GUIStyle.SmallFont, wrap: true)
{
ToolTip = bannedPlayer.Reason
ToolTip = reason
};
paddedPlayerFrame.Recalculate();
@@ -31,12 +31,17 @@ namespace Barotrauma.Networking
public bool IsOwner;
public bool AllowKicking;
public bool IsDownloading;
public float Karma;
public bool AllowKicking =>
!IsOwner &&
!HasPermission(ClientPermissions.Ban) &&
!HasPermission(ClientPermissions.Kick) &&
!HasPermission(ClientPermissions.Unban);
public void UpdateSoundPosition()
{
if (VoipSound == null) { return; }
@@ -362,8 +362,7 @@ namespace Barotrauma.Networking
// When this is set to true, we are approved and ready to go
canStart = false;
DateTime timeOut = DateTime.Now + new TimeSpan(0, 0, 40);
DateTime reqAuthTime = DateTime.Now + new TimeSpan(0, 0, 0, 0, 200);
DateTime timeOut = DateTime.Now + new TimeSpan(0, 0, 200);
// Loop until we are approved
LocalizedString connectingText = TextManager.Get("Connecting");
@@ -489,7 +488,10 @@ namespace Barotrauma.Networking
}
GameAnalyticsManager.AddErrorEventOnce("GameClient.Update:CheckServerMessagesException" + e.TargetSite.ToString(), GameAnalyticsManager.ErrorSeverity.Error, errorMsg);
DebugConsole.ThrowError("Error while reading a message from server.", e);
new GUIMessageBox(TextManager.Get("Error"), TextManager.GetWithVariables("MessageReadError", ("[message]", e.Message), ("[targetsite]", e.TargetSite.ToString())));
new GUIMessageBox(TextManager.Get("Error"), TextManager.GetWithVariables("MessageReadError", ("[message]", e.Message), ("[targetsite]", e.TargetSite.ToString())))
{
DisplayInLoadingScreens = true
};
Quit();
GameMain.ServerListScreen.Select();
return;
@@ -965,10 +967,10 @@ namespace Barotrauma.Networking
}
AttemptReconnect(disconnectPacket);
}
else if (disconnectPacket.ShouldShowMessage)
else
{
ReturnToPreviousMenu(null, null);
var msgBox = new GUIMessageBox(TextManager.Get(wasConnected ? "ConnectionLost" : "CouldNotConnectToServer"), disconnectPacket.PopupMessage)
new GUIMessageBox(TextManager.Get(wasConnected ? "ConnectionLost" : "CouldNotConnectToServer"), disconnectPacket.PopupMessage)
{
DisplayInLoadingScreens = true
};
@@ -1033,6 +1035,7 @@ namespace Barotrauma.Networking
if (ClientPeer != null)
{
//restore the previous list of content packages so we can reconnect immediately without having to recheck that the packages match
ClientPeer.ContentPackageOrderReceived = true;
ClientPeer.ServerContentPackages = prevContentPackages;
}
}
@@ -1721,6 +1724,7 @@ namespace Barotrauma.Networking
string subName = inc.ReadString();
string subHash = inc.ReadString();
byte subClass = inc.ReadByte();
bool isShuttle = inc.ReadBoolean();
bool requiredContentPackagesInstalled = inc.ReadBoolean();
var matchingSub = SubmarineInfo.SavedSubmarines.FirstOrDefault(s => s.Name == subName && s.MD5Hash.StringRepresentation == subHash);
@@ -1730,6 +1734,7 @@ namespace Barotrauma.Networking
{
SubmarineClass = (SubmarineClass)subClass
};
if (isShuttle) { matchingSub.AddTag(SubmarineTag.Shuttle); }
}
matchingSub.RequiredContentPackagesInstalled = requiredContentPackagesInstalled;
ServerSubmarines.Add(matchingSub);
@@ -1780,7 +1785,6 @@ namespace Barotrauma.Networking
AccountInfo = tc.AccountInfo,
Muted = tc.Muted,
InGame = tc.InGame,
AllowKicking = tc.AllowKicking,
IsOwner = tc.IsOwner
};
otherClients.Add(existingClient);
@@ -1795,7 +1799,6 @@ namespace Barotrauma.Networking
existingClient.Muted = tc.Muted;
existingClient.InGame = tc.InGame;
existingClient.IsOwner = tc.IsOwner;
existingClient.AllowKicking = tc.AllowKicking;
existingClient.IsDownloading = tc.IsDownloading;
GameMain.NetLobbyScreen.SetPlayerNameAndJobPreference(existingClient);
if (Screen.Selected != GameMain.NetLobbyScreen && tc.CharacterId > 0)
@@ -2404,7 +2407,7 @@ namespace Barotrauma.Networking
var subElement = subListChildren.FirstOrDefault(c =>
((SubmarineInfo)c.UserData).Name == newSub.Name &&
((SubmarineInfo)c.UserData).MD5Hash.StringRepresentation == newSub.MD5Hash.StringRepresentation);
if (subElement == null) continue;
if (subElement == null) { continue; }
Color newSubTextColor = new Color(subElement.GetChild<GUITextBlock>().TextColor, 1.0f);
subElement.GetChild<GUITextBlock>().TextColor = newSubTextColor;
@@ -2429,7 +2432,7 @@ namespace Barotrauma.Networking
if (GameMain.NetLobbyScreen.FailedSelectedShuttle.HasValue &&
GameMain.NetLobbyScreen.FailedSelectedShuttle.Value.Name == newSub.Name &&
GameMain.NetLobbyScreen.FailedSelectedShuttle.Value.Name == newSub.MD5Hash.StringRepresentation)
GameMain.NetLobbyScreen.FailedSelectedShuttle.Value.Hash == newSub.MD5Hash.StringRepresentation)
{
GameMain.NetLobbyScreen.TrySelectSub(newSub.Name, newSub.MD5Hash.StringRepresentation, GameMain.NetLobbyScreen.ShuttleList.ListBox);
}
@@ -2583,6 +2586,7 @@ namespace Barotrauma.Networking
}
}
ChildServerRelay.ShutDown();
GUIMessageBox.MessageBoxes.RemoveAll(c => c?.UserData is RoundSummary);
characterInfo?.Remove();
@@ -49,7 +49,7 @@ namespace Barotrauma.Networking
protected abstract void SendMsgInternal(PeerPacketHeaders headers, INetSerializableStruct? body);
protected ConnectionInitialization initializationStep;
public bool ContentPackageOrderReceived { get; protected set; }
public bool ContentPackageOrderReceived { get; set; }
protected int passwordSalt;
protected Steamworks.AuthTicket? steamAuthTicket;
private GUIMessageBox? passwordMsgBox;
@@ -36,6 +36,8 @@ namespace Barotrauma.Networking
public override void Start()
{
if (isActive) { return; }
ContentPackageOrderReceived = false;
steamAuthTicket = SteamManager.GetAuthSessionTicket();
@@ -189,6 +191,7 @@ namespace Barotrauma.Networking
if (packet is { SteamId: var steamId, Data: var data })
{
OnP2PData(steamId, data, data.Length);
if (!isActive) { return; }
receivedBytes += data.Length;
}
}
@@ -391,7 +391,7 @@ namespace Barotrauma.Networking
for (int i = remotePeers.Count - 1; i >= 0; i--)
{
DisconnectPeer(remotePeers[i], peerDisconnectPacket);
DisconnectPeer(remotePeers[i], PeerDisconnectPacket.WithReason(DisconnectReason.ServerShutdown));
}
Thread.Sleep(100);
@@ -37,6 +37,7 @@ namespace Barotrauma.Networking
switch (serverInfo.Endpoint)
{
case LidgrenEndpoint { NetEndpoint: { Address: var address } }:
GetIPAddressPing(serverInfo, address, onPingDiscovered);
break;
case SteamP2PEndpoint steamP2PEndpoint:
@@ -132,24 +133,30 @@ namespace Barotrauma.Networking
private static void GetIPAddressPing(ServerInfo serverInfo, IPAddress address, Action<ServerInfo> onPingDiscovered)
{
lock (activePings)
if (IPAddress.IsLoopback(address))
{
if (activePings.ContainsKey(address)) { return; }
activePings.Add(address, activePings.Any() ? activePings.Values.Max() + 1 : 0);
serverInfo.Ping = Option<int>.Some(0);
onPingDiscovered(serverInfo);
}
serverInfo.Ping = Option<int>.None();
TaskPool.Add($"PingServerAsync ({address})", PingServerAsync(address, 1000),
rtt =>
else
{
lock (activePings)
{
if (!rtt.TryGetResult(out serverInfo.Ping)) { serverInfo.Ping = Option<int>.None(); }
onPingDiscovered(serverInfo);
lock (activePings)
if (activePings.ContainsKey(address)) { return; }
activePings.Add(address, activePings.Any() ? activePings.Values.Max() + 1 : 0);
}
serverInfo.Ping = Option<int>.None();
TaskPool.Add($"PingServerAsync ({address})", PingServerAsync(address, 1000),
rtt =>
{
activePings.Remove(address);
}
});
if (!rtt.TryGetResult(out serverInfo.Ping)) { serverInfo.Ping = Option<int>.None(); }
onPingDiscovered(serverInfo);
lock (activePings)
{
activePings.Remove(address);
}
});
}
}
private static async Task<Option<int>> PingServerAsync(IPAddress ipAddress, int timeOut)
@@ -70,7 +70,7 @@ namespace Barotrauma.Networking
[Serialize(PlayStyle.Casual, IsPropertySaveable.Yes)]
public PlayStyle PlayStyle { get; set; }
public Version GameVersion { get; set; } = new Version(0,0,0,0);
public Version GameVersion { get; set; } = new Version(0, 0, 0, 0);
public Option<int> Ping = Option<int>.None();
@@ -200,7 +200,7 @@ namespace Barotrauma.Networking
new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), frame.RectTransform),
TextManager.AddPunctuation(':', TextManager.Get("ServerListVersion"),
GameVersion.ToString()))
GameVersion == new Version(0, 0, 0, 0) ? TextManager.Get("Unknown") : GameVersion.ToString()))
{
CanBeFocused = false
};
@@ -397,10 +397,10 @@ namespace Barotrauma.Networking
public void UpdateInfo(Func<string, string?> valueGetter)
{
ServerMessage = valueGetter("message") ?? "";
GameVersion = Version.TryParse(valueGetter("version"), out var version)
? version
: GameMain.Version;
if (Version.TryParse(valueGetter("version"), out var version))
{
GameVersion = version;
}
if (int.TryParse(valueGetter("playercount"), out int playerCount)) { PlayerCount = playerCount; }
if (int.TryParse(valueGetter("maxplayernum"), out int maxPlayers)) { MaxPlayers = maxPlayers; }
if (Enum.TryParse(valueGetter("modeselectionmode"), out SelectionMode modeSelectionMode)) { ModeSelectionMode = modeSelectionMode; }