v1.3.0.1 (Epic Store release)
This commit is contained in:
+32
@@ -0,0 +1,32 @@
|
||||
#nullable enable
|
||||
|
||||
|
||||
namespace Barotrauma.Networking;
|
||||
|
||||
sealed class EosP2PEndpoint : P2PEndpoint
|
||||
{
|
||||
public EosInterface.ProductUserId ProductUserId => new EosInterface.ProductUserId((Address as EosP2PAddress)!.EosStringRepresentation);
|
||||
|
||||
public EosP2PEndpoint(EosInterface.ProductUserId puid) : this(new EosP2PAddress(puid.Value)) { }
|
||||
|
||||
public EosP2PEndpoint(EosP2PAddress address) : base(address) { }
|
||||
|
||||
public override string StringRepresentation => (Address as EosP2PAddress)!.StringRepresentation;
|
||||
|
||||
public override LocalizedString ServerTypeString { get; } = TextManager.Get("PlayerHostedServer");
|
||||
|
||||
public override int GetHashCode()
|
||||
=> (Address as EosP2PAddress)!.GetHashCode();
|
||||
|
||||
public override bool Equals(object? obj)
|
||||
=> obj is EosP2PEndpoint otherEndpoint
|
||||
&& ProductUserId == otherEndpoint.ProductUserId;
|
||||
|
||||
public new static Option<EosP2PEndpoint> Parse(string endpointStr)
|
||||
=> EosP2PAddress.Parse(endpointStr).Select(eosAddress => new EosP2PEndpoint(eosAddress));
|
||||
|
||||
public const string SocketName = "Barotrauma.EosP2PSocket";
|
||||
|
||||
public override P2PConnection MakeConnectionFromEndpoint()
|
||||
=> new EosP2PConnection(this);
|
||||
}
|
||||
+1
-1
@@ -60,7 +60,7 @@ namespace Barotrauma.Networking
|
||||
=> NetEndpoint.GetHashCode();
|
||||
|
||||
public static bool operator ==(LidgrenEndpoint a, LidgrenEndpoint b)
|
||||
=> a.Address.Equals(b.Address) && a.Port == b.Port;
|
||||
=> a.NetEndpoint.EquivalentTo(b.NetEndpoint);
|
||||
|
||||
public static bool operator !=(LidgrenEndpoint a, LidgrenEndpoint b)
|
||||
=> !(a == b);
|
||||
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
#nullable enable
|
||||
namespace Barotrauma.Networking;
|
||||
|
||||
abstract class P2PEndpoint : Endpoint
|
||||
{
|
||||
protected P2PEndpoint(P2PAddress address) : base(address) { }
|
||||
|
||||
public abstract P2PConnection MakeConnectionFromEndpoint();
|
||||
|
||||
public new static Option<P2PEndpoint> Parse(string str)
|
||||
=> Endpoint.Parse(str).Bind(ep => ep is P2PEndpoint pep ? Option.Some(pep) : Option.None);
|
||||
}
|
||||
+12
-21
@@ -2,36 +2,27 @@
|
||||
|
||||
namespace Barotrauma.Networking
|
||||
{
|
||||
sealed class SteamP2PEndpoint : Endpoint
|
||||
sealed class SteamP2PEndpoint : P2PEndpoint
|
||||
{
|
||||
public readonly SteamId SteamId;
|
||||
public SteamId SteamId => (Address as SteamP2PAddress)!.SteamId;
|
||||
|
||||
public override string StringRepresentation => SteamId.StringRepresentation;
|
||||
|
||||
public override LocalizedString ServerTypeString { get; } = TextManager.Get("SteamP2PServer");
|
||||
public override LocalizedString ServerTypeString { get; } = TextManager.Get("PlayerHostedServer");
|
||||
|
||||
public SteamP2PEndpoint(SteamId steamId) : base(new SteamP2PAddress(steamId))
|
||||
{
|
||||
SteamId = steamId;
|
||||
}
|
||||
|
||||
public new static Option<SteamP2PEndpoint> Parse(string endpointStr)
|
||||
=> SteamId.Parse(endpointStr).Select(steamId => new SteamP2PEndpoint(steamId));
|
||||
|
||||
public override bool Equals(object? obj)
|
||||
=> obj switch
|
||||
{
|
||||
SteamP2PEndpoint otherEndpoint => this == otherEndpoint,
|
||||
_ => false
|
||||
};
|
||||
public SteamP2PEndpoint(SteamId steamId) : base(new SteamP2PAddress(steamId)) { }
|
||||
|
||||
public override int GetHashCode()
|
||||
=> SteamId.GetHashCode();
|
||||
|
||||
public static bool operator ==(SteamP2PEndpoint a, SteamP2PEndpoint b)
|
||||
=> a.SteamId == b.SteamId;
|
||||
public override bool Equals(object? obj)
|
||||
=> obj is SteamP2PEndpoint otherEndpoint
|
||||
&& this.SteamId == otherEndpoint.SteamId;
|
||||
|
||||
public static bool operator !=(SteamP2PEndpoint a, SteamP2PEndpoint b)
|
||||
=> !(a == b);
|
||||
public new static Option<SteamP2PEndpoint> Parse(string endpointStr)
|
||||
=> SteamId.Parse(endpointStr).Select(steamId => new SteamP2PEndpoint(steamId));
|
||||
|
||||
public override P2PConnection MakeConnectionFromEndpoint()
|
||||
=> new SteamP2PConnection(this);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user