From b02fcc62895cef92c0d67425084599b5ff0e5db6 Mon Sep 17 00:00:00 2001 From: Shiqan Date: Sun, 31 Mar 2024 11:09:33 +0200 Subject: [PATCH] fix: update parse player elim for new version. Fixes #55 --- CHANGELOG.md | 29 ++++++++++++++----- src/BenchmarkReader/BenchmarkReader.csproj | 2 +- src/ConsoleReader/ConsoleReader.csproj | 6 ++-- src/ConsoleReader/Program.cs | 4 +-- .../FortniteReplayReader.Test.csproj | 8 ++--- .../PlayerElimTest.cs | 21 ++++++++++++++ .../FortniteReplayReader.cs | 6 ++++ .../FortniteReplayReader.csproj | 2 +- src/OozSharp.Test/OozSharp.Test.csproj | 8 ++--- src/Unreal.Core.Test/Unreal.Core.Test.csproj | 8 ++--- .../Models/Enums/RepLayoutCmdType.cs | 4 +++ .../Models/Enums/RepLayoutFlags.cs | 3 +- .../Models/Enums/ReplayHeaderFlags.cs | 6 +++- src/Unreal.Core/ReplayReader.cs | 6 ++-- src/Unreal.Core/Unreal.Core.csproj | 2 +- .../Unreal.Encryption.Test.csproj | 8 ++--- 16 files changed, 87 insertions(+), 36 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f74af94..39bcf09 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,13 +9,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Interfaces to support proper DI - Register types to be parsed with DI -<<<<<<< HEAD -## [2.1.0] - 2023-11-18 +## [2.2.2] - 2024-03-31 +### Changed +- fix `ParseElimination` (see [issue 55](https://github.com/Shiqan/FortniteReplayDecompressor/issues/55)) + +## [2.2.1] - 2024-03-09 +### Changed +- fix possible infinite loop while parsing broken replays (by [diopolgg](https://github.com/diopolgg)) + +## [2.2.0] - 2023-11-18 ### Changed - support .net8 -======= ->>>>>>> origin ## [2.1.0] - 2023-09-10 ### Changed - support .net6 @@ -28,11 +33,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed - add HISTORY_GAMESTATE_REPLCIATED_TIME_AS_DOUBLE (by [chrisai-dev](https://github.com/chrisai-dev)) -<<<<<<< HEAD ## [2.0.6] - 2023-06-10 -======= -## [2.0.6] - 2024-06-10 ->>>>>>> origin ### Changed - adding support for v25.00 @@ -118,3 +119,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 [1.1.1]: https://github.com/Shiqan/FortniteReplayDecompressor/releases/tag/1.1.1 [1.1.2]: https://github.com/Shiqan/FortniteReplayDecompressor/releases/tag/1.1.2 [2.0.0]: https://github.com/Shiqan/FortniteReplayDecompressor/releases/tag/2.0.0 +[2.0.1]: https://github.com/Shiqan/FortniteReplayDecompressor/releases/tag/2.0.1 +[2.0.2]: https://github.com/Shiqan/FortniteReplayDecompressor/releases/tag/2.0.2 +[2.0.3]: https://github.com/Shiqan/FortniteReplayDecompressor/releases/tag/2.0.3 +[2.0.4]: https://github.com/Shiqan/FortniteReplayDecompressor/releases/tag/2.0.4 +[2.0.5]: https://github.com/Shiqan/FortniteReplayDecompressor/releases/tag/2.0.5 +[2.0.6]: https://github.com/Shiqan/FortniteReplayDecompressor/releases/tag/2.0.6 +[2.0.7]: https://github.com/Shiqan/FortniteReplayDecompressor/releases/tag/2.0.7 +[2.0.8]: https://github.com/Shiqan/FortniteReplayDecompressor/releases/tag/2.0.8 +[2.1.0]: https://github.com/Shiqan/FortniteReplayDecompressor/releases/tag/2.1.0 +[2.2.0]: https://github.com/Shiqan/FortniteReplayDecompressor/releases/tag/2.2.0 +[2.2.1]: https://github.com/Shiqan/FortniteReplayDecompressor/releases/tag/2.2.1 +[2.2.2]: https://github.com/Shiqan/FortniteReplayDecompressor/releases/tag/2.2.2 diff --git a/src/BenchmarkReader/BenchmarkReader.csproj b/src/BenchmarkReader/BenchmarkReader.csproj index 35488fb..db7683f 100644 --- a/src/BenchmarkReader/BenchmarkReader.csproj +++ b/src/BenchmarkReader/BenchmarkReader.csproj @@ -5,7 +5,7 @@ false - + diff --git a/src/ConsoleReader/ConsoleReader.csproj b/src/ConsoleReader/ConsoleReader.csproj index b2714fd..4bd533d 100644 --- a/src/ConsoleReader/ConsoleReader.csproj +++ b/src/ConsoleReader/ConsoleReader.csproj @@ -28,8 +28,8 @@ - - - + + + \ No newline at end of file diff --git a/src/ConsoleReader/Program.cs b/src/ConsoleReader/Program.cs index ccda276..b4baa81 100644 --- a/src/ConsoleReader/Program.cs +++ b/src/ConsoleReader/Program.cs @@ -21,9 +21,9 @@ private static void Main(string[] args) var logger = provider.GetService>(); var localAppDataFolder = GetFolderPath(SpecialFolder.LocalApplicationData); - var replayFilesFolder = Path.Combine(localAppDataFolder, @"FortniteGame\Saved\Demos"); + //var replayFilesFolder = Path.Combine(localAppDataFolder, @"FortniteGame\Saved\Demos"); //var replayFilesFolder = @"F:\Projects\FortniteReplayCollection\_upload\"; - //var replayFilesFolder = @"C:\Users\ferro\Downloads\"; + var replayFilesFolder = @"C:\Users\ferro\Downloads\"; var replayFiles = Directory.EnumerateFiles(replayFilesFolder, "*.replay"); var sw = new Stopwatch(); diff --git a/src/FortniteReplayReader.Test/FortniteReplayReader.Test.csproj b/src/FortniteReplayReader.Test/FortniteReplayReader.Test.csproj index 89e95f4..4106591 100644 --- a/src/FortniteReplayReader.Test/FortniteReplayReader.Test.csproj +++ b/src/FortniteReplayReader.Test/FortniteReplayReader.Test.csproj @@ -9,13 +9,13 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive - - - + + + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/src/FortniteReplayReader.Test/PlayerElimTest.cs b/src/FortniteReplayReader.Test/PlayerElimTest.cs index 98d9a9d..f8936d8 100644 --- a/src/FortniteReplayReader.Test/PlayerElimTest.cs +++ b/src/FortniteReplayReader.Test/PlayerElimTest.cs @@ -133,6 +133,26 @@ public class PlayerElimTest 0xA6, 0x39, 0x20, 0x4A, 0xDC, 0x8E, 0xC2, 0x63, 0x53, 0xA2, 0xD5, 0xB8, 0x39, 0x08, 0x00, 0x00, 0x00, 0x00 }, EngineNetworkVersionHistory.HISTORY_OPTIONALLY_QUANTIZE_SPAWN_INFO, "++Fortnite+Release-11.31")] + [InlineData(new byte[] { + 0x09, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, + 0x3F, 0x2E, 0x48, 0xC9, 0x9A, 0xE1, 0xB4, 0xE4, 0x40, 0x53, 0x7E, 0x96, + 0x8E, 0xFD, 0x47, 0xF1, 0xC0, 0x81, 0x47, 0x61, 0x66, 0x26, 0xDD, 0xB0, + 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0x3F, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0xF0, 0x3F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, + 0x3F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0x3F, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0xF0, 0x3F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, + 0x3F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0x3F, 0x11, 0x10, 0x3F, + 0x6B, 0xCD, 0x61, 0xF3, 0xA5, 0x44, 0x3F, 0x8A, 0x73, 0x78, 0xA2, 0xF1, + 0x90, 0x6D, 0x59, 0x11, 0x10, 0xBF, 0x48, 0x07, 0x77, 0xC3, 0x03, 0x48, + 0xA5, 0xAB, 0x30, 0xE9, 0x97, 0x74, 0x92, 0xA9, 0x03, 0x03, 0x01, 0x00, + 0x00, 0x00 + }, (EngineNetworkVersionHistory) 34, "++Fortnite+Release-29.01")] public void ParsePlayerElimTest(byte[] rawData, EngineNetworkVersionHistory version, string branch) { using var stream = new MemoryStream(rawData); @@ -144,6 +164,7 @@ public void ParsePlayerElimTest(byte[] rawData, EngineNetworkVersionHistory vers { Branch = branch }; + reader.ParseElimination(archive, new EventInfo { StartTime = 0 }); Assert.True(archive.AtEnd()); diff --git a/src/FortniteReplayReader/FortniteReplayReader.cs b/src/FortniteReplayReader/FortniteReplayReader.cs index df6c6cc..e05763b 100644 --- a/src/FortniteReplayReader/FortniteReplayReader.cs +++ b/src/FortniteReplayReader/FortniteReplayReader.cs @@ -283,6 +283,12 @@ public virtual PlayerElimination ParseElimination(FArchive archive, EventInfo in archive.SkipBytes(36); } } + + if ((int) archive.EngineNetworkVersion >= 34) + { + archive.SkipBytes(80); + } + ParsePlayer(archive, elim.EliminatedInfo, version); ParsePlayer(archive, elim.EliminatorInfo, version); diff --git a/src/FortniteReplayReader/FortniteReplayReader.csproj b/src/FortniteReplayReader/FortniteReplayReader.csproj index f02107d..2788658 100644 --- a/src/FortniteReplayReader/FortniteReplayReader.csproj +++ b/src/FortniteReplayReader/FortniteReplayReader.csproj @@ -25,6 +25,6 @@ - + \ No newline at end of file diff --git a/src/OozSharp.Test/OozSharp.Test.csproj b/src/OozSharp.Test/OozSharp.Test.csproj index 78a2c8b..6332985 100644 --- a/src/OozSharp.Test/OozSharp.Test.csproj +++ b/src/OozSharp.Test/OozSharp.Test.csproj @@ -5,13 +5,13 @@ true - - - + + + all runtime; build; native; contentfiles; analyzers; buildtransitive - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/src/Unreal.Core.Test/Unreal.Core.Test.csproj b/src/Unreal.Core.Test/Unreal.Core.Test.csproj index 8ae3ea3..0bb6860 100644 --- a/src/Unreal.Core.Test/Unreal.Core.Test.csproj +++ b/src/Unreal.Core.Test/Unreal.Core.Test.csproj @@ -4,13 +4,13 @@ false - + all runtime; build; native; contentfiles; analyzers; buildtransitive - - - + + + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/src/Unreal.Core/Models/Enums/RepLayoutCmdType.cs b/src/Unreal.Core/Models/Enums/RepLayoutCmdType.cs index 67f989a..438826c 100644 --- a/src/Unreal.Core/Models/Enums/RepLayoutCmdType.cs +++ b/src/Unreal.Core/Models/Enums/RepLayoutCmdType.cs @@ -31,11 +31,15 @@ public enum RepLayoutCmdType PropertyNativeBool = 21, PropertySoftObject = 22, PropertyWeakObject = 23, + PropertyInterface = 24, + NetSerializeStructWithObjectReferences = 25, PropertyDouble = 94, PropertyVector2D = 95, PropertyInt16 = 96, PropertyUInt16 = 97, + PropertyQuat = 98, + Enum = 99, Ignore = 100 } diff --git a/src/Unreal.Core/Models/Enums/RepLayoutFlags.cs b/src/Unreal.Core/Models/Enums/RepLayoutFlags.cs index 75f92b3..4afe91f 100644 --- a/src/Unreal.Core/Models/Enums/RepLayoutFlags.cs +++ b/src/Unreal.Core/Models/Enums/RepLayoutFlags.cs @@ -8,5 +8,6 @@ public enum RepLayoutFlags { None = 0, //! No flags. IsSharedSerialization = (1 << 0), //! Indicates the property is eligible for shared serialization. - IsStruct = (1 << 1) //! This is a struct property. + IsStruct = (1 << 1), //! This is a struct property. + IsEmptyArrayStruct = (1 << 2), //! This is an ArrayProperty whose InnerProperty has no replicated properties. } diff --git a/src/Unreal.Core/Models/Enums/ReplayHeaderFlags.cs b/src/Unreal.Core/Models/Enums/ReplayHeaderFlags.cs index b74cdbb..230b4ed 100644 --- a/src/Unreal.Core/Models/Enums/ReplayHeaderFlags.cs +++ b/src/Unreal.Core/Models/Enums/ReplayHeaderFlags.cs @@ -12,5 +12,9 @@ public enum ReplayHeaderFlags ClientRecorded = (1 << 0), HasStreamingFixes = (1 << 1), DeltaCheckpoints = (1 << 2), - GameSpecificFrameData = (1 << 3), + GameSpecificFrameData = (1 << 3), + ReplayConnection = (1 << 4), + ActorPrioritizationEnabled = (1 << 5), + NetRelevancyEnabled = (1 << 6), + AsyncRecorded = (1 << 7), } diff --git a/src/Unreal.Core/ReplayReader.cs b/src/Unreal.Core/ReplayReader.cs index d933a7f..8cbb976 100644 --- a/src/Unreal.Core/ReplayReader.cs +++ b/src/Unreal.Core/ReplayReader.cs @@ -416,14 +416,16 @@ public virtual void ReadReplayHeader(FArchive archive) _logger?.LogError("Header.Version < MIN_NETWORK_DEMO_VERSION. Header.Version: {}, MIN_NETWORK_DEMO_VERSION: {}", header.NetworkVersion, NetworkVersionHistory.HISTORY_EXTRA_VERSION); throw new InvalidReplayException($"Header.Version < MIN_NETWORK_DEMO_VERSION. Header.Version: {header.NetworkVersion}, MIN_NETWORK_DEMO_VERSION: {NetworkVersionHistory.HISTORY_EXTRA_VERSION}"); } + if (header.NetworkVersion >= NetworkVersionHistory.HISTORY_USE_CUSTOM_VERSION) { var customVersionCount = archive.ReadInt32(); - // version guid -> 16 bytes - // version -> 4 bytes + //var fguid = archive.ReadGUID(); + //var latestVersion = archive.ReadInt32(); archive.SkipBytes(customVersionCount * 20); } + header.NetworkChecksum = archive.ReadUInt32(); header.EngineNetworkVersion = archive.ReadUInt32AsEnum(); diff --git a/src/Unreal.Core/Unreal.Core.csproj b/src/Unreal.Core/Unreal.Core.csproj index 5bf45da..7be1b8f 100644 --- a/src/Unreal.Core/Unreal.Core.csproj +++ b/src/Unreal.Core/Unreal.Core.csproj @@ -21,6 +21,6 @@ - + \ No newline at end of file diff --git a/src/Unreal.Encryption.Test/Unreal.Encryption.Test.csproj b/src/Unreal.Encryption.Test/Unreal.Encryption.Test.csproj index 543d55e..6dd4c7f 100644 --- a/src/Unreal.Encryption.Test/Unreal.Encryption.Test.csproj +++ b/src/Unreal.Encryption.Test/Unreal.Encryption.Test.csproj @@ -4,13 +4,13 @@ false - + all runtime; build; native; contentfiles; analyzers; buildtransitive - - - + + + all runtime; build; native; contentfiles; analyzers; buildtransitive