Skip to content

Commit

Permalink
fix: update parse player elim for new version. Fixes #55 (#57)
Browse files Browse the repository at this point in the history
  • Loading branch information
Shiqan authored Mar 31, 2024
1 parent 81138ec commit 990ee2f
Show file tree
Hide file tree
Showing 16 changed files with 87 additions and 36 deletions.
29 changes: 21 additions & 8 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down Expand Up @@ -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
2 changes: 1 addition & 1 deletion src/BenchmarkReader/BenchmarkReader.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="BenchmarkDotNet" Version="0.13.8" />
<PackageReference Include="BenchmarkDotNet" Version="0.13.12" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\FortniteReplayReader\FortniteReplayReader.csproj" />
Expand Down
6 changes: 3 additions & 3 deletions src/ConsoleReader/ConsoleReader.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
</None>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.0-rc.2.23479.6" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.0-rc.2.23479.6" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="8.0.0-rc.2.23479.6" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="8.0.0" />
</ItemGroup>
</Project>
4 changes: 2 additions & 2 deletions src/ConsoleReader/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ private static void Main(string[] args)
var logger = provider.GetService<ILogger<Program>>();

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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@
<None Remove="AthenaTeamStats\**" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="coverlet.msbuild" Version="6.0.0">
<PackageReference Include="coverlet.msbuild" Version="6.0.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.7.2" />
<PackageReference Include="xunit" Version="2.6.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.3">
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
<PackageReference Include="xunit" Version="2.7.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.7">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
21 changes: 21 additions & 0 deletions src/FortniteReplayReader.Test/PlayerElimTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -144,6 +164,7 @@ public void ParsePlayerElimTest(byte[] rawData, EngineNetworkVersionHistory vers
{
Branch = branch
};

reader.ParseElimination(archive, new EventInfo { StartTime = 0 });

Assert.True(archive.AtEnd());
Expand Down
6 changes: 6 additions & 0 deletions src/FortniteReplayReader/FortniteReplayReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion src/FortniteReplayReader/FortniteReplayReader.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@
<ProjectReference Include="..\Unreal.Encryption\Unreal.Encryption.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.0-rc.2.23479.6" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.0" />
</ItemGroup>
</Project>
8 changes: 4 additions & 4 deletions src/OozSharp.Test/OozSharp.Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.7.2" />
<PackageReference Include="xunit" Version="2.6.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.3">
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
<PackageReference Include="xunit" Version="2.7.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.7">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" Version="6.0.0">
<PackageReference Include="coverlet.collector" Version="6.0.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
8 changes: 4 additions & 4 deletions src/Unreal.Core.Test/Unreal.Core.Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
<IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="coverlet.msbuild" Version="6.0.0">
<PackageReference Include="coverlet.msbuild" Version="6.0.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.7.2" />
<PackageReference Include="xunit" Version="2.6.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.3">
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
<PackageReference Include="xunit" Version="2.7.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.7">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
4 changes: 4 additions & 0 deletions src/Unreal.Core/Models/Enums/RepLayoutCmdType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
3 changes: 2 additions & 1 deletion src/Unreal.Core/Models/Enums/RepLayoutFlags.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
}
6 changes: 5 additions & 1 deletion src/Unreal.Core/Models/Enums/ReplayHeaderFlags.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
}
6 changes: 4 additions & 2 deletions src/Unreal.Core/ReplayReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<EngineNetworkVersionHistory>();

Expand Down
2 changes: 1 addition & 1 deletion src/Unreal.Core/Unreal.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@
</None>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.0-rc.2.23479.6" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.0" />
</ItemGroup>
</Project>
8 changes: 4 additions & 4 deletions src/Unreal.Encryption.Test/Unreal.Encryption.Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
<IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="coverlet.msbuild" Version="6.0.0">
<PackageReference Include="coverlet.msbuild" Version="6.0.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.7.2" />
<PackageReference Include="xunit" Version="2.6.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.3">
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
<PackageReference Include="xunit" Version="2.7.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.7">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down

1 comment on commit 990ee2f

@lbeneck
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice boi

Please sign in to comment.