Unstable 1.8.4.0

This commit is contained in:
Markus Isberg
2025-03-12 12:56:27 +00:00
parent a4c3e868e4
commit a4a3427e4e
627 changed files with 29860 additions and 10018 deletions
@@ -20,6 +20,8 @@ namespace Barotrauma.Networking
public bool AllowModDownloads { get; private set; } = true;
public string AutomaticallyAttemptedPassword = string.Empty;
public readonly record struct Callbacks(
Callbacks.MessageCallback OnMessageReceived,
Callbacks.DisconnectCallback OnDisconnect,
@@ -39,6 +41,9 @@ namespace Barotrauma.Networking
protected bool IsOwner => ownerKey.IsSome();
protected readonly Option<int> ownerKey;
/// <summary>
/// Has the ClientPeer been started? Set to true in <see cref="Start"/>, set to false when shutting the client down <see cref="Close(PeerDisconnectPacket)"/>.
/// </summary>
public bool IsActive => isActive;
protected bool isActive;
@@ -102,8 +107,12 @@ namespace Barotrauma.Networking
TaskPool.Add($"{GetType().Name}.{nameof(GetAccountId)}", GetAccountId(), t =>
{
if (GameMain.Client?.ClientPeer is null) { return; }
if (!IsActive)
{
//client has become inactive (cancelled/disconnected while waiting for initialization)
return;
}
if (!t.TryGetResult(out Option<AccountId> accountId))
{
Close(PeerDisconnectPacket.WithReason(DisconnectReason.AuthenticationFailed));
@@ -118,7 +127,7 @@ namespace Barotrauma.Networking
var body = new ClientAuthTicketAndVersionPacket
{
Name = GameMain.Client.Name,
Name = GameMain.Client?.Name ?? "Unknown",
OwnerKey = ownerKey,
AccountId = accountId,
AuthTicket = authTicket,
@@ -177,10 +186,16 @@ namespace Barotrauma.Networking
var passwordPacket = INetSerializableStruct.Read<ServerPeerPasswordPacket>(inc.Message);
if (WaitingForPassword) { return; }
passwordPacket.Salt.TryUnwrap(out passwordSalt);
passwordPacket.RetriesLeft.TryUnwrap(out var retries);
if (!string.IsNullOrWhiteSpace(AutomaticallyAttemptedPassword))
{
SendPassword(AutomaticallyAttemptedPassword);
return;
}
LocalizedString pwMsg = TextManager.Get("PasswordRequired");
passwordMsgBox?.Close();