Handle NMT Login packet

This commit is contained in:
AeonLucid
2022-01-13 01:04:54 +01:00
parent 65a28b32ef
commit 7c6353c475
21 changed files with 722 additions and 57 deletions
+1 -2
View File
@@ -1,5 +1,4 @@
using Prospect.Unreal.Net;
using Prospect.Unreal.Serialization;
using Prospect.Unreal.Serialization;
namespace Prospect.Unreal.Core;
+15 -5
View File
@@ -41,13 +41,23 @@ public static class FString
}
else
{
var num = value.Length + 1;
var valueBytes = num > 128 ? new byte[num] : stackalloc byte[num];
var num = value.Length;
if (num != 0)
{
// Add null terminator.
num += 1;
var valueBytes = num > 128 ? new byte[num] : stackalloc byte[num];
Encoding.ASCII.GetBytes(value, valueBytes);
Encoding.ASCII.GetBytes(value, valueBytes);
archive.WriteInt32(num);
archive.Serialize(valueBytes, num);
archive.WriteInt32(num);
archive.Serialize(valueBytes, num);
}
else
{
archive.WriteInt32(0);
}
}
}
+65 -4
View File
@@ -1,14 +1,75 @@
using System.Net;
using System.Text;
namespace Prospect.Unreal.Core;
public class FUrl
{
public string Protocol { get; set; } = "unreal";
public IPAddress Host { get; set; } = IPAddress.Any;
public int Port { get; set; } = 7777;
public string Map { get; set; } = "GearStart";
private const string DefaultProtocol = "unreal";
private static readonly IPAddress DefaultHost = IPAddress.Any;
private const int DefaultPort = 7777;
public string Protocol { get; set; } = DefaultProtocol;
public IPAddress Host { get; set; } = DefaultHost;
public int Port { get; set; } = DefaultPort;
public string Map { get; set; } = "GearStart"; // TODO: UGameMapsSettings::GetGameDefaultMap()
public string RedirectUrl { get; set; } = string.Empty;
public List<string> Options { get; set; } = new List<string>();
public string Portal { get; set; } = string.Empty;
public bool Valid { get; set; } = true;
public string ToString(bool fullyQualified)
{
var result = new StringBuilder();
// Emit protocol.
if ((Protocol != DefaultProtocol) || fullyQualified)
{
result.Append(Protocol);
result.Append(':');
if (!Equals(Host, DefaultHost))
{
result.Append("//");
}
}
// Emit host and port
if (!Equals(Host, DefaultHost) || (Port != DefaultPort))
{
result.Append(Port);
if (!Map.StartsWith("/") && !Map.StartsWith("\\"))
{
result.Append('/');
}
}
// Emit map.
if (!string.IsNullOrEmpty(Map))
{
result.Append(Map);
}
// Emit options.
foreach (var option in Options)
{
result.Append('?');
result.Append(option);
}
// Emit portal.
if (!string.IsNullOrEmpty(Portal))
{
result.Append('#');
result.Append(Portal);
}
return result.ToString();
}
public override string ToString()
{
return ToString(false);
}
}