Unstable 1.8.4.0
This commit is contained in:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user