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
+4
View File
@@ -27,6 +27,10 @@ internal static class Program
Logger.Information("Starting Prospect.Server.Game"); Logger.Information("Starting Prospect.Server.Game");
// Prospect:
// Map: /Game/Maps/MP/Station/Station_P
// GameMode: /Script/Prospect/YGameMode_Station
var worldUrl = new FUrl var worldUrl = new FUrl
{ {
Map = "/Game/ThirdPersonCPP/Maps/ThirdPersonExampleMap" Map = "/Game/ThirdPersonCPP/Maps/ThirdPersonExampleMap"
+6 -2
View File
@@ -1,12 +1,16 @@
namespace Prospect.Unreal.Net; using Prospect.Unreal.Core.Names;
namespace Prospect.Unreal.Net;
public class FUniqueNetId public class FUniqueNetId
{ {
public FUniqueNetId(string contents) public FUniqueNetId(FName type, string contents)
{ {
Type = type;
Contents = contents; Contents = contents;
} }
public FName Type { get; }
public string Contents { get; } public string Contents { get; }
public bool IsValid() public bool IsValid()
+10 -8
View File
@@ -7,7 +7,7 @@ namespace Prospect.Unreal.Net;
public class FUniqueNetIdRepl public class FUniqueNetIdRepl
{ {
private static readonly ILogger Logger = Log.ForContext<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; } public FUniqueNetId? UniqueNetId { get; private set; }
@@ -18,8 +18,7 @@ public class FUniqueNetIdRepl
public string ToDebugString() public string ToDebugString()
{ {
// TODO: Add type return IsValid() ? $"${UniqueNetId!.Type}:{UniqueNetId!.Contents}" : "INVALID";
return IsValid() ? $"{UniqueNetId!.Contents}" : "INVALID";
} }
public static void Write(FArchive ar, FUniqueNetIdRepl value) public static void Write(FArchive ar, FUniqueNetIdRepl value)
@@ -68,7 +67,7 @@ public class FUniqueNetIdRepl
var bValidTypeHash = typeHash != 0; var bValidTypeHash = typeHash != 0;
if (typeHash == TypeHash_Other) if (typeHash == TypeHashOther)
{ {
var typeString = ar.ReadString(); var typeString = ar.ReadString();
var type = new FName(typeString); var type = new FName(typeString);
@@ -102,13 +101,16 @@ public class FUniqueNetIdRepl
// TypeHash = UOnlineEngineInterface::Get()->GetReplicationHashForSubsystem(UOnlineEngineInterface::Get()->GetDefaultOnlineSubsystemName()); // TypeHash = UOnlineEngineInterface::Get()->GetReplicationHashForSubsystem(UOnlineEngineInterface::Get()->GetDefaultOnlineSubsystemName());
} }
var bValidTypeHash = typeHash != 0; FName type;
if (typeHash == TypeHash_Other)
{
var bValidTypeHash = typeHash != 0;
if (typeHash == TypeHashOther)
{
type = new FName(ar.ReadString());
} }
else else
{ {
type = UnrealNames.FNames[UnrealNameKey.None];
// TODO: Type = UOnlineEngineInterface::Get()->GetSubsystemFromReplicationHash(TypeHash); // TODO: Type = UOnlineEngineInterface::Get()->GetSubsystemFromReplicationHash(TypeHash);
} }
@@ -118,7 +120,7 @@ public class FUniqueNetIdRepl
if (!ar.IsError()) if (!ar.IsError())
{ {
// TODO: Check if type != none // TODO: Check if type != none
UniqueNetId = new FUniqueNetId(contents); UniqueNetId = new FUniqueNetId(type, contents);
bOutSuccess = true; 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.Core.Names;
using Prospect.Unreal.Exceptions; using Prospect.Unreal.Exceptions;
using Prospect.Unreal.Net; using Prospect.Unreal.Net;
@@ -268,7 +268,7 @@ public abstract class UWorld : FNetworkNotify, IAsyncDisposable
connection.SetPlayerOnlinePlatformName(new FName(onlinePlatformName)); connection.SetPlayerOnlinePlatformName(new FName(onlinePlatformName));
// ask the game code if this player can join // ask the game code if this player can join
string errorMsg = null; string? errorMsg = null;
var gameMode = GetAuthGameMode(); var gameMode = GetAuthGameMode();
if (gameMode != null) if (gameMode != null)