Unstable 1.8.4.0
This commit is contained in:
+10
-1
@@ -74,7 +74,16 @@ sealed class SteamConnectSocket : P2PSocket
|
||||
{
|
||||
if (!SteamManager.IsInitialized) { return Result.Failure(new Error(ErrorCode.SteamNotInitialized)); }
|
||||
|
||||
var connectionManager = Steamworks.SteamNetworkingSockets.ConnectRelay<ConnectionManager>(endpoint.SteamId.Value);
|
||||
ConnectionManager connectionManager;
|
||||
try
|
||||
{
|
||||
connectionManager = Steamworks.SteamNetworkingSockets.ConnectRelay<ConnectionManager>(endpoint.SteamId.Value);
|
||||
}
|
||||
catch (ArgumentException e)
|
||||
{
|
||||
DebugConsole.ThrowError("Failed to connect via SteamP2P. Are you logged in to Steam, is the same Steam account already connected to the server?", e);
|
||||
return Result.Failure(new Error(ErrorCode.FailedToCreateSteamP2PSocket));
|
||||
}
|
||||
if (connectionManager is null) { return Result.Failure(new Error(ErrorCode.FailedToCreateSteamP2PSocket)); }
|
||||
connectionManager.SetEndpointAndCallbacks(endpoint, callbacks);
|
||||
|
||||
|
||||
+1
-1
@@ -68,7 +68,7 @@ sealed class SteamListenSocket : P2PSocket
|
||||
|
||||
public override void OnMessage(Steamworks.Data.Connection connection, Steamworks.Data.NetIdentity identity, IntPtr data, int size, long messageNum, long recvTime, int channel)
|
||||
{
|
||||
if (!identity.IsSteamId) { return; }
|
||||
if (!identity.IsSteamId || data == IntPtr.Zero) { return; }
|
||||
var endpoint = new SteamP2PEndpoint(new SteamId((Steamworks.SteamId)identity));
|
||||
|
||||
var dataArray = new byte[size];
|
||||
|
||||
@@ -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();
|
||||
|
||||
+7
-4
@@ -224,10 +224,13 @@ namespace Barotrauma.Networking
|
||||
ToolBox.ThrowIfNull(netPeerConfiguration);
|
||||
|
||||
#if DEBUG
|
||||
netPeerConfiguration.SimulatedDuplicatesChance = GameMain.Client.SimulatedDuplicatesChance;
|
||||
netPeerConfiguration.SimulatedMinimumLatency = GameMain.Client.SimulatedMinimumLatency;
|
||||
netPeerConfiguration.SimulatedRandomLatency = GameMain.Client.SimulatedRandomLatency;
|
||||
netPeerConfiguration.SimulatedLoss = GameMain.Client.SimulatedLoss;
|
||||
if (GameMain.Client != null)
|
||||
{
|
||||
netPeerConfiguration.SimulatedDuplicatesChance = GameMain.Client.SimulatedDuplicatesChance;
|
||||
netPeerConfiguration.SimulatedMinimumLatency = GameMain.Client.SimulatedMinimumLatency;
|
||||
netPeerConfiguration.SimulatedRandomLatency = GameMain.Client.SimulatedRandomLatency;
|
||||
netPeerConfiguration.SimulatedLoss = GameMain.Client.SimulatedLoss;
|
||||
}
|
||||
#endif
|
||||
|
||||
byte[] bufAux = msg.PrepareForSending(compressPastThreshold, out bool isCompressed, out _);
|
||||
|
||||
Reference in New Issue
Block a user