Deserialize FUniqueNetIdRepl

This commit is contained in:
AeonLucid
2022-01-13 01:37:30 +01:00
parent 7c6353c475
commit a7399a1960
4 changed files with 22 additions and 12 deletions
+7 -3
View File
@@ -1,12 +1,16 @@
namespace Prospect.Unreal.Net;
using Prospect.Unreal.Core.Names;
namespace Prospect.Unreal.Net;
public class FUniqueNetId
{
public FUniqueNetId(string contents)
public FUniqueNetId(FName type, string contents)
{
Type = type;
Contents = contents;
}
public FName Type { get; }
public string Contents { get; }
public bool IsValid()
+9 -7
View File
@@ -7,7 +7,7 @@ namespace Prospect.Unreal.Net;
public class FUniqueNetIdRepl
{
private static readonly ILogger Logger = Log.ForContext<FUniqueNetIdRepl>();
private const int TypeHash_Other = 31;
private const int TypeHashOther = 31;
public FUniqueNetId? UniqueNetId { get; private set; }
@@ -18,8 +18,7 @@ public class FUniqueNetIdRepl
public string ToDebugString()
{
// TODO: Add type
return IsValid() ? $"{UniqueNetId!.Contents}" : "INVALID";
return IsValid() ? $"${UniqueNetId!.Type}:{UniqueNetId!.Contents}" : "INVALID";
}
public static void Write(FArchive ar, FUniqueNetIdRepl value)
@@ -68,7 +67,7 @@ public class FUniqueNetIdRepl
var bValidTypeHash = typeHash != 0;
if (typeHash == TypeHash_Other)
if (typeHash == TypeHashOther)
{
var typeString = ar.ReadString();
var type = new FName(typeString);
@@ -102,13 +101,16 @@ public class FUniqueNetIdRepl
// TypeHash = UOnlineEngineInterface::Get()->GetReplicationHashForSubsystem(UOnlineEngineInterface::Get()->GetDefaultOnlineSubsystemName());
}
FName type;
var bValidTypeHash = typeHash != 0;
if (typeHash == TypeHash_Other)
if (typeHash == TypeHashOther)
{
type = new FName(ar.ReadString());
}
else
{
type = UnrealNames.FNames[UnrealNameKey.None];
// TODO: Type = UOnlineEngineInterface::Get()->GetSubsystemFromReplicationHash(TypeHash);
}
@@ -118,7 +120,7 @@ public class FUniqueNetIdRepl
if (!ar.IsError())
{
// TODO: Check if type != none
UniqueNetId = new FUniqueNetId(contents);
UniqueNetId = new FUniqueNetId(type, contents);
bOutSuccess = true;
}
}
+2 -2
View File
@@ -1,4 +1,4 @@
using Prospect.Unreal.Core;
using Prospect.Unreal.Core;
using Prospect.Unreal.Core.Names;
using Prospect.Unreal.Exceptions;
using Prospect.Unreal.Net;
@@ -268,7 +268,7 @@ public abstract class UWorld : FNetworkNotify, IAsyncDisposable
connection.SetPlayerOnlinePlatformName(new FName(onlinePlatformName));
// ask the game code if this player can join
string errorMsg = null;
string? errorMsg = null;
var gameMode = GetAuthGameMode();
if (gameMode != null)