Skip to content

Commit

Permalink
Merge pull request #46 from chrisai-dev/ReplicatedWorldTimeSecondsDouble
Browse files Browse the repository at this point in the history
Implementing HISTORY_GAMESTATE_REPLCIATED_TIME_AS_DOUBLE
  • Loading branch information
Shiqan committed Sep 10, 2023
2 parents 528141b + 4fed5c1 commit 99351b1
Show file tree
Hide file tree
Showing 14 changed files with 42 additions and 5 deletions.
1 change: 1 addition & 0 deletions src/FortniteReplayReader.Test/FortniteReplayBuilderTest.cs
Expand Up @@ -25,6 +25,7 @@ public void GameStateTest()
GameSessionId = "123",
WinningTeam = 99,
ReplicatedWorldTimeSeconds = 1,
ReplicatedWorldTimeSecondsDouble = 1,
};
builder.UpdateGameState(state);

Expand Down
16 changes: 15 additions & 1 deletion src/FortniteReplayReader/FortniteReplayBuilder.cs
Expand Up @@ -37,6 +37,7 @@ public class FortniteReplayBuilder
private readonly Dictionary<uint, WeaponData> _unknownWeapons = new();

private float? ReplicatedWorldTimeSeconds = 0;
private double? ReplicatedWorldTimeSecondsDouble = 0;

public void AddActorChannel(uint channelIndex, uint guid)
{
Expand Down Expand Up @@ -132,6 +133,11 @@ public void UpdateGameState(GameState state)
ReplicatedWorldTimeSeconds = state.ReplicatedWorldTimeSeconds;
}

if (state.ReplicatedWorldTimeSecondsDouble != null)
{
ReplicatedWorldTimeSecondsDouble = state.ReplicatedWorldTimeSecondsDouble;
}

GameData.WinningPlayerIds ??= state.WinningPlayerList;
GameData.WinningTeam ??= state.WinningTeam;
GameData.RecorderId ??= state.RecorderPlayerState?.Value;
Expand Down Expand Up @@ -246,6 +252,8 @@ public void UpdatePlayerState(uint channelIndex, FortPlayerState state)
if (state.DeathTags != null)
{
playerData.DeathTime = ReplicatedWorldTimeSeconds;
playerData.DeathTimeDouble = ReplicatedWorldTimeSecondsDouble;

}

playerData.Cosmetics.Parts ??= state.Parts?.Name;
Expand All @@ -262,7 +270,8 @@ public void UpdateKillFeed(uint channelIndex, PlayerData data, FortPlayerState s
{
KillFeedEntry? entry = new KillFeedEntry()
{
ReplicatedWorldTimeSeconds = ReplicatedWorldTimeSeconds
ReplicatedWorldTimeSeconds = ReplicatedWorldTimeSeconds,
ReplicatedWorldTimeSecondsDouble = ReplicatedWorldTimeSecondsDouble,
};

if (state.RebootCounter != null)
Expand Down Expand Up @@ -363,6 +372,7 @@ public void UpdatePlayerPawn(uint channelIndex, PlayerPawn pawn)
{
ReplicatedMovement = pawn.ReplicatedMovement,
ReplicatedWorldTimeSeconds = ReplicatedWorldTimeSeconds,
ReplicatedWorldTimeSecondsDouble = ReplicatedWorldTimeSecondsDouble,
LastUpdateTime = pawn.ReplayLastTransformUpdateTimeStamp,
bIsCrouched = pawn.bIsCrouched,
bIsInAnyStorm = pawn.bIsInAnyStorm,
Expand Down Expand Up @@ -495,6 +505,7 @@ public void UpdateLlama(uint channelIndex, SupplyDropLlama supplyDropLlama)
{
llama.Looted = true;
llama.LootedTime = ReplicatedWorldTimeSeconds;
llama.LootedTimeDouble = ReplicatedWorldTimeSecondsDouble;
}

if (supplyDropLlama.bHasSpawnedPickups)
Expand All @@ -517,12 +528,15 @@ public void UpdateSupplyDrop(uint channelIndex, Models.NetFieldExports.SupplyDro
{
drop.Looted = true;
drop.LootedTime = ReplicatedWorldTimeSeconds;
drop.LootedTimeDouble = ReplicatedWorldTimeSecondsDouble;
}

if (supplyDrop.BalloonPopped)
{
drop.BalloonPopped = true;
drop.BalloonPoppedTime = ReplicatedWorldTimeSeconds;
drop.BalloonPoppedTimeDouble = ReplicatedWorldTimeSecondsDouble;

}

if (supplyDrop.bHasSpawnedPickups)
Expand Down
1 change: 1 addition & 0 deletions src/FortniteReplayReader/Models/KillFeedEntry.cs
Expand Up @@ -14,6 +14,7 @@ public class KillFeedEntry
public bool FinisherOrDownerIsBot { get; set; }

public float? ReplicatedWorldTimeSeconds { get; set; }
public double? ReplicatedWorldTimeSecondsDouble { get; set; }
public float? Distance { get; set; }
public int? DeathCause { get; set; }
public FVector DeathLocation { get; set; }
Expand Down
1 change: 1 addition & 0 deletions src/FortniteReplayReader/Models/Llama.cs
Expand Up @@ -24,6 +24,7 @@ public Llama(uint channelIndex, SupplyDropLlama drop)
public bool HasSpawnedPickups { get; set; }
public bool Looted { get; set; }
public float? LootedTime { get; set; }
public double? LootedTimeDouble { get; set; }
public FVector? LandingLocation { get; set; }
}
}
3 changes: 3 additions & 0 deletions src/FortniteReplayReader/Models/NetFieldExports/GameState.cs
Expand Up @@ -108,6 +108,9 @@ public class GameState : INetFieldExportGroup
[NetFieldExport("ReplicatedWorldTimeSeconds", RepLayoutCmdType.PropertyFloat)]
public float? ReplicatedWorldTimeSeconds { get; set; }

[NetFieldExport("ReplicatedWorldTimeSecondsDouble", RepLayoutCmdType.PropertyDouble)]
public double? ReplicatedWorldTimeSecondsDouble { get; set; }

[NetFieldExport("MatchState", RepLayoutCmdType.Property)]
public FName MatchState { get; set; }

Expand Down
5 changes: 4 additions & 1 deletion src/FortniteReplayReader/Models/PlayerData.cs
Expand Up @@ -71,7 +71,7 @@ public PlayerData(FortPlayerState playerState)
public IEnumerable<string> DeathTags { get; set; }
public FVector DeathLocation { get; set; }
public float? DeathTime { get; set; }

public double? DeathTimeDouble { get; set; }
public Cosmetics Cosmetics { get; set; }
public uint? CurrentWeapon { get; internal set; }

Expand Down Expand Up @@ -104,6 +104,9 @@ public class PlayerMovement
{
public FRepMovement? ReplicatedMovement { get; set; }
public float? ReplicatedWorldTimeSeconds { get; set; }

public double? ReplicatedWorldTimeSecondsDouble { get; set; }

public float? LastUpdateTime { get; set; }

public bool? bIsCrouched { get; set; }
Expand Down
2 changes: 2 additions & 0 deletions src/FortniteReplayReader/Models/SupplyDrop.cs
Expand Up @@ -21,8 +21,10 @@ public SupplyDrop(uint channelIndex, NetFieldExports.SupplyDrop drop)
public bool HasSpawnedPickups { get; set; }
public bool Looted { get; set; }
public float? LootedTime { get; set; }
public double? LootedTimeDouble { get; set; }
public bool BalloonPopped { get; set; }
public float? BalloonPoppedTime { get; set; }
public double? BalloonPoppedTimeDouble { get; set; }
public float FallSpeed { get; set; }
public FVector LandingLocation { get; set; }
public float FallHeight { get; set; }
Expand Down
2 changes: 2 additions & 0 deletions src/Unreal.Core/Contracts/ITelemetryEvent.cs
Expand Up @@ -6,5 +6,7 @@
public interface ITelemetryEvent
{
public float? ReplicatedWorldTimeSeconds { get; set; }

public double? ReplicatedWorldTimeSecondsDouble { get; set; }
}
}
Expand Up @@ -35,6 +35,7 @@ public enum EngineNetworkVersionHistory
HISTORY_RUNTIME_FEATURES_COMPATIBILITY = 28, // Bump version to add network runtime feature compatibility test to handshake (hello/upgrade) control messages
HISTORY_SOFTOBJECTPTR_NETGUIDS = 29, // Bump version to support replicating SoftObjectPtrs by NetGuid instead of raw strings.
HISTORY_SUBOBJECT_DESTROY_FLAG = 30, // Bump version to support subobject destruction message flags
HISTORY_GAMESTATE_REPLCIATED_TIME_AS_DOUBLE = 31, // Bump version to support AGameStateBase::ReplicatedWorldTimeSeconds as double instead of float.

HISTORY_ENGINENETVERSION_PLUS_ONE,
LATEST = HISTORY_ENGINENETVERSION_PLUS_ONE - 1,
Expand Down
1 change: 1 addition & 0 deletions src/Unreal.Core/Models/Enums/RepLayoutCmdType.cs
Expand Up @@ -32,6 +32,7 @@ public enum RepLayoutCmdType
PropertySoftObject = 22,
PropertyWeakObject = 23,

PropertyDouble = 94,
PropertyVector2D = 95,
PropertyInt16 = 96,
PropertyUInt16 = 97,
Expand Down
4 changes: 2 additions & 2 deletions src/Unreal.Core/Models/Enums/ReplayVersionHistory.cs
@@ -1,7 +1,7 @@
namespace Unreal.Core.Models
{
/// <summary>
/// see https://github.com/EpicGames/UnrealEngine/blob/70bc980c6361d9a7d23f6d23ffe322a2d6ef16fb/Engine/Source/Runtime/NetworkReplayStreaming/LocalFileNetworkReplayStreaming/Private/LocalFileNetworkReplayStreaming.cpp#L45
/// see https://github.com/EpicGames/UnrealEngine/blob/996ef9a9f4ad5a899abf70fb292d2914a46d0876/Engine/Source/Runtime/NetworkReplayStreaming/LocalFileNetworkReplayStreaming/Public/LocalFileNetworkReplayStreaming.h#L34
/// </summary>
[System.Flags]
public enum ReplayVersionHistory : uint
Expand All @@ -13,7 +13,7 @@ public enum ReplayVersionHistory : uint
HISTORY_STREAM_CHUNK_TIMES = 4,
HISTORY_FRIENDLY_NAME_ENCODING = 5,
HISTORY_ENCRYPTION = 6,
HISTORY_2500 = 7, // TODO, FIND THE NAME OF THIS
HISTORY_CUSTOM_VERSIONS = 7,

HISTORY_PLUS_ONE,
LATEST = HISTORY_PLUS_ONE - 1
Expand Down
5 changes: 5 additions & 0 deletions src/Unreal.Core/NetBitReader.cs
Expand Up @@ -41,6 +41,11 @@ public float SerializePropertyFloat()
return ReadSingle();
}

public double SerializePropertyDouble()
{
return ReadDouble();
}

public string SerializePropertyName()
{
return ReadFName();
Expand Down
3 changes: 3 additions & 0 deletions src/Unreal.Core/NetFieldParser.cs
Expand Up @@ -379,6 +379,9 @@ private void SetType(INetFieldExportGroup obj, NetFieldInfo netFieldInfo, NetFie
case RepLayoutCmdType.PropertyFloat:
data = netBitReader.SerializePropertyFloat();
break;
case RepLayoutCmdType.PropertyDouble:
data = netBitReader.SerializePropertyDouble();
break;
case RepLayoutCmdType.PropertyNativeBool:
data = netBitReader.SerializePropertyNativeBool();
break;
Expand Down
2 changes: 1 addition & 1 deletion src/Unreal.Core/ReplayReader.cs
Expand Up @@ -531,7 +531,7 @@ public virtual void ReadReplayInfo(FArchive archive)
{
_logger?.LogWarning("Found unexpected ReplayVersionHistory: {}", fileVersion);
}
if (archive.ReplayVersion >= ReplayVersionHistory.HISTORY_2500)
if (archive.ReplayVersion >= ReplayVersionHistory.HISTORY_CUSTOM_VERSIONS)
{
var customVersionCount = archive.ReadInt32();

Expand Down

0 comments on commit 99351b1

Please sign in to comment.