Unstable v0.19.1.0
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
#nullable enable
|
||||
using Barotrauma.Networking;
|
||||
|
||||
namespace Barotrauma
|
||||
{
|
||||
readonly struct ConnectCommand
|
||||
{
|
||||
public readonly struct NameAndEndpoint
|
||||
{
|
||||
public readonly string ServerName;
|
||||
public readonly Endpoint Endpoint;
|
||||
|
||||
public NameAndEndpoint(string serverName, Endpoint endpoint)
|
||||
{
|
||||
ServerName = serverName;
|
||||
Endpoint = endpoint;
|
||||
}
|
||||
}
|
||||
|
||||
public readonly Either<NameAndEndpoint, ulong> EndpointOrLobby;
|
||||
|
||||
public ConnectCommand(string serverName, Endpoint endpoint)
|
||||
{
|
||||
EndpointOrLobby = new NameAndEndpoint(serverName, endpoint);
|
||||
}
|
||||
|
||||
public ConnectCommand(ulong lobbyId)
|
||||
{
|
||||
EndpointOrLobby = lobbyId;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using Barotrauma.Networking;
|
||||
|
||||
namespace Barotrauma
|
||||
{
|
||||
static class RichTextDataExtensions
|
||||
{
|
||||
public static Client ExtractClient(this RichTextData data)
|
||||
{
|
||||
bool isInt = UInt64.TryParse(data.Metadata, out ulong uintId);
|
||||
Option<AccountId> accountId = AccountId.Parse(data.Metadata);
|
||||
Client client = GameMain.Client.ConnectedClients.Find(c => accountId.IsSome() && accountId == c.AccountId)
|
||||
?? GameMain.Client.ConnectedClients.Find(c => isInt && c.SessionId == uintId)
|
||||
?? GameMain.Client.PreviouslyConnectedClients.FirstOrDefault(c => accountId.IsSome() && accountId == c.AccountId)
|
||||
?? GameMain.Client.PreviouslyConnectedClients.FirstOrDefault(c => isInt && c.SessionId == uintId);
|
||||
return client;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -7,7 +7,7 @@ using System.Text;
|
||||
|
||||
namespace Barotrauma
|
||||
{
|
||||
public class SpriteRecorder : ISpriteBatch, IDisposable
|
||||
class SpriteRecorder : ISpriteBatch, IDisposable
|
||||
{
|
||||
private struct Command
|
||||
{
|
||||
|
||||
@@ -4,11 +4,12 @@ using System.Collections.Generic;
|
||||
using System.Collections.Immutable;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using Barotrauma.Networking;
|
||||
using Color = Microsoft.Xna.Framework.Color;
|
||||
|
||||
namespace Barotrauma
|
||||
{
|
||||
public static partial class ToolBox
|
||||
static partial class ToolBox
|
||||
{
|
||||
/// <summary>
|
||||
/// Checks if point is inside of a polygon
|
||||
@@ -450,21 +451,26 @@ namespace Barotrauma
|
||||
public static string WrapText(string text, float lineLength, ScalableFont font, float textScale = 1.0f)
|
||||
=> font.WrapText(text, lineLength / textScale);
|
||||
|
||||
public static void ParseConnectCommand(string[] args, out string name, out string endpoint, out UInt64 lobbyId)
|
||||
public static Option<ConnectCommand> ParseConnectCommand(string[] args)
|
||||
{
|
||||
name = null; endpoint = null; lobbyId = 0;
|
||||
if (args == null || args.Length < 2) { return; }
|
||||
if (args == null || args.Length < 2) { return Option<ConnectCommand>.None(); }
|
||||
|
||||
if (args[0].Equals("-connect", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
if (args.Length < 3) { return; }
|
||||
name = args[1];
|
||||
endpoint = args[2];
|
||||
if (args.Length < 3) { return Option<ConnectCommand>.None(); }
|
||||
if (!(Endpoint.Parse(args[2]).TryUnwrap(out var endpoint))) { return Option<ConnectCommand>.None(); }
|
||||
return Option<ConnectCommand>.Some(
|
||||
new ConnectCommand(
|
||||
serverName: args[1],
|
||||
endpoint: endpoint));
|
||||
}
|
||||
else if (args[0].Equals("+connect_lobby", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
UInt64.TryParse(args[1], out lobbyId);
|
||||
return UInt64.TryParse(args[1], out var lobbyId)
|
||||
? Option<ConnectCommand>.Some(new ConnectCommand(lobbyId))
|
||||
: Option<ConnectCommand>.None();
|
||||
}
|
||||
return Option<ConnectCommand>.None();
|
||||
}
|
||||
|
||||
public static bool VersionNewerIgnoreRevision(Version a, Version b)
|
||||
|
||||
Reference in New Issue
Block a user