Skip to content

Commit

Permalink
feat: add support for .net 9 #minor (#62)
Browse files Browse the repository at this point in the history
* feat: add support for .net 9

* fix: parse FRepMovement with RepMoveOptionalAcceleration
  • Loading branch information
Shiqan authored Nov 13, 2024
1 parent 2a22812 commit 30d7bb5
Show file tree
Hide file tree
Showing 20 changed files with 118 additions and 86 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Build

on:
push:
branches: [ master ]
branches: [ '*' ]
pull_request:
branches: [ master ]

Expand All @@ -18,11 +18,11 @@ jobs:
uses: actions/checkout@v4

- name: Setup .NET
uses: actions/setup-dotnet@v3
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
6.x
8.x
9.x
- name: Build
run: dotnet build ./src/FortniteReplayDecompressor.sln --configuration Release
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Setup .NET
uses: actions/setup-dotnet@v3
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
6.x
8.x
9.x
- name: Build
run: dotnet build ./src/FortniteReplayDecompressor.sln --configuration Release
Expand Down
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,14 @@ 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

## [2.4.0] - 2024-11-13
### Changed
- support .net9
- fix parsing of `FRepMovement` with `RepMoveOptionalAcceleration` (thanks @Zaid)

### Removed
- support .net6

## [2.3.1] - 2024-11-08
### Changed
- fix parsing of `FGameplayTag` with new `bUseDynamicReplication`
Expand Down Expand Up @@ -139,3 +147,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.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.3.1]: https://github.com/Shiqan/FortniteReplayDecompressor/releases/tag/2.3.0
[2.3.1]: https://github.com/Shiqan/FortniteReplayDecompressor/releases/tag/2.3.1
[2.4.0]: https://github.com/Shiqan/FortniteReplayDecompressor/releases/tag/2.4.0
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ C# parser for your Fortnite replays.

## Getting Started

.NET 6.0 or .NET 8.0 is required.
.NET 8.0 or .NET 9.0 is required.

```powershell
dotnet add package FortniteReplayReader
Expand Down
4 changes: 2 additions & 2 deletions src/BenchmarkReader/BenchmarkReader.csproj
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFrameworks>net6.0;net8.0</TargetFrameworks>
<TargetFrameworks>net8.0;net9.0</TargetFrameworks>
<IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="BenchmarkDotNet" Version="0.13.12" />
<PackageReference Include="BenchmarkDotNet" Version="0.14.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\FortniteReplayReader\FortniteReplayReader.csproj" />
Expand Down
8 changes: 4 additions & 4 deletions src/ConsoleReader/ConsoleReader.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFrameworks>net6.0;net8.0</TargetFrameworks>
<TargetFrameworks>net8.0;net9.0</TargetFrameworks>
<IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>
Expand Down Expand Up @@ -31,8 +31,8 @@
</None>
</ItemGroup>
<ItemGroup>
<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" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="9.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="9.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="9.0.0" />
</ItemGroup>
</Project>
68 changes: 31 additions & 37 deletions src/ConsoleReader/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,49 +5,43 @@
using System.Diagnostics;
using System.IO;
using Unreal.Core.Models.Enums;
using static System.Environment;

namespace ConsoleReader;
// Set up dependency injection and logging services
var serviceCollection = new ServiceCollection()
.AddLogging(loggingBuilder => loggingBuilder
.AddConsole()
.SetMinimumLevel(LogLevel.Warning));
var provider = serviceCollection.BuildServiceProvider();
var logger = provider.GetService<ILogger<Program>>();

internal class Program
{
private static void Main(string[] args)
{
var serviceCollection = new ServiceCollection()
.AddLogging(loggingBuilder => loggingBuilder
.AddConsole()
.SetMinimumLevel(LogLevel.Warning));
var provider = serviceCollection.BuildServiceProvider();
var logger = provider.GetService<ILogger<Program>>();
// Define the folder containing replay files
//var replayFilesFolder = Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.LocalApplicationData), @"FortniteGame\Saved\Demos");
var replayFilesFolder = @"C:\Users\ferro\Downloads\";
var replayFiles = Directory.EnumerateFiles(replayFilesFolder, "*.replay");

var localAppDataFolder = GetFolderPath(SpecialFolder.LocalApplicationData);
//var replayFilesFolder = Path.Combine(localAppDataFolder, @"FortniteGame\Saved\Demos");
//var replayFilesFolder = @"F:\Projects\FortniteReplayCollection\_upload\";
var replayFilesFolder = @"C:\Users\ferro\Downloads\";
var replayFiles = Directory.EnumerateFiles(replayFilesFolder, "*919.replay");
var sw = new Stopwatch();
long total = 0;

var sw = new Stopwatch();
#if DEBUG
var reader = new ReplayReader(logger, ParseMode.Minimal);
var reader = new ReplayReader(logger, ParseMode.Normal);
#else
var reader = new ReplayReader(null, ParseMode.Minimal);
var reader = new ReplayReader(null, ParseMode.Minimal);
#endif
long total = 0;
foreach (var replayFile in replayFiles)
{
sw.Restart();
try
{
var replay = reader.ReadReplay(replayFile);
}
catch (Exception ex)
{
Console.WriteLine(ex);
}
sw.Stop();
Console.WriteLine($"---- {replayFile} : done in {sw.ElapsedMilliseconds} milliseconds ----");
total += sw.ElapsedMilliseconds;
}
Console.WriteLine($"total: {total / 1000} seconds ----");

foreach (var replayFile in replayFiles)
{
sw.Restart();
try
{
var replay = reader.ReadReplay(replayFile);
}
catch (Exception ex)
{
Console.WriteLine(ex);
}
sw.Stop();
Console.WriteLine($"---- {replayFile} : done in {sw.ElapsedMilliseconds} milliseconds ----");
total += sw.ElapsedMilliseconds;
}

Console.WriteLine($"total: {total / 1000} seconds ----");
10 changes: 5 additions & 5 deletions src/FortniteReplayReader.Test/FortniteReplayReader.Test.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net6.0;net8.0</TargetFrameworks>
<TargetFrameworks>net8.0;net9.0</TargetFrameworks>
<IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>
Expand All @@ -9,13 +9,13 @@
<None Remove="AthenaTeamStats\**" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="coverlet.msbuild" Version="6.0.1">
<PackageReference Include="coverlet.msbuild" Version="6.0.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<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">
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
<PackageReference Include="xunit" Version="2.9.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
4 changes: 2 additions & 2 deletions src/FortniteReplayReader/FortniteReplayReader.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net6.0;net8.0</TargetFrameworks>
<TargetFrameworks>net8.0;net9.0</TargetFrameworks>
<Nullable>enable</Nullable>
<AssemblyName>FortniteReplayReader</AssemblyName>
<RootNamespace>FortniteReplayReader</RootNamespace>
Expand All @@ -25,6 +25,6 @@
<ProjectReference Include="..\Unreal.Encryption\Unreal.Encryption.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="9.0.0" />
</ItemGroup>
</Project>
10 changes: 5 additions & 5 deletions src/OozSharp.Test/OozSharp.Test.csproj
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net6.0;net8.0</TargetFrameworks>
<TargetFrameworks>net8.0;net9.0</TargetFrameworks>
<IsPackable>false</IsPackable>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<ItemGroup>
<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">
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
<PackageReference Include="xunit" Version="2.9.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" Version="6.0.1">
<PackageReference Include="coverlet.collector" Version="6.0.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
2 changes: 1 addition & 1 deletion src/OozSharp/OozSharp.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net6.0;net8.0</TargetFrameworks>
<TargetFrameworks>net8.0;net9.0</TargetFrameworks>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<Authors>SL-x-TnT, Shiqan</Authors>
<Company />
Expand Down
17 changes: 13 additions & 4 deletions src/Unreal.Core.Test/NetBitReaderTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,25 +26,34 @@ public class NetBitReaderTest
// sniper rifle bullet season 11
[InlineData(new byte[] {
0x34, 0x88, 0xDF, 0x03, 0xE0, 0xE9, 0xCB, 0x3F, 0x92, 0x3B, 0x53, 0x3C,
0x47, 0x61, 0xD6, 0x01}, 122,
0x47, 0x61, 0xD6, 0x01 }, 122,
VectorQuantization.RoundWholeNumber, RotatorQuantization.ByteComponents, VectorQuantization.RoundWholeNumber)]
// supply drop season 11
[InlineData(new byte[] {
0x74, 0x20, 0x88, 0x53, 0x86, 0xDA, 0x16, 0xD8, 0x02, 0x40, 0x00, 0x38,
0x2B, 0x00}, 105,
0x2B, 0x00 }, 105,
VectorQuantization.RoundWholeNumber, RotatorQuantization.ByteComponents, VectorQuantization.RoundWholeNumber)]
// meat vehicle 11.40
[InlineData(new byte[] {
0xDA, 0x34, 0x06, 0xCA, 0x0A, 0xFE, 0x68, 0x40, 0x29, 0xBE, 0xB9, 0xFF,
0x83, 0x55, 0x1A, 0xF9, 0x47, 0xF2, 0xBD, 0xBE, 0x54, 0x3B, 0xFB, 0x88,
0xAB, 0xBF, 0x70, 0xB3, 0xCB, 0x02}, 236,
VectorQuantization.RoundWholeNumber, RotatorQuantization.ShortComponents, VectorQuantization.RoundTwoDecimals)]
[InlineData(new byte[] {
0xA0, 0x65, 0x06, 0xE5, 0x68, 0x79, 0x0F, 0x60, 0xD8, 0x85, 0xFD, 0x05,
0x15, 0x04 }, 111, VectorQuantization.RoundTwoDecimals, RotatorQuantization.ByteComponents, VectorQuantization.RoundWholeNumber,
EngineNetworkVersionHistory.CustomExports)]
public void RepMovementTest(byte[] rawData, int bitCount,
VectorQuantization locationQuantizationLevel = VectorQuantization.RoundTwoDecimals,
RotatorQuantization rotationQuantizationLevel = RotatorQuantization.ByteComponents,
VectorQuantization velocityQuantizationLevel = VectorQuantization.RoundWholeNumber)
VectorQuantization velocityQuantizationLevel = VectorQuantization.RoundWholeNumber,
EngineNetworkVersionHistory engineNetworkVersion = EngineNetworkVersionHistory.HISTORY_INITIAL)
{
var reader = new NetBitReader(rawData, bitCount);
var reader = new NetBitReader(rawData, bitCount)
{
EngineNetworkVersion = engineNetworkVersion
};

reader.SerializeRepMovement(locationQuantizationLevel, rotationQuantizationLevel, velocityQuantizationLevel);
Assert.False(reader.IsError);
Assert.True(reader.AtEnd());
Expand Down
10 changes: 5 additions & 5 deletions src/Unreal.Core.Test/Unreal.Core.Test.csproj
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net6.0;net8.0</TargetFrameworks>
<TargetFrameworks>net8.0;net9.0</TargetFrameworks>
<IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="coverlet.msbuild" Version="6.0.1">
<PackageReference Include="coverlet.msbuild" Version="6.0.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<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">
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
<PackageReference Include="xunit" Version="2.9.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
6 changes: 3 additions & 3 deletions src/Unreal.Core/BitReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public class BitReader : FBitArchive

public override int MarkPosition { get; protected set; }

private readonly Dictionary<FBitArchiveEndIndex, int> _tempLastBit = new();
private readonly Dictionary<FBitArchiveEndIndex, int> _tempLastBit = [];


public BitReader()
Expand Down Expand Up @@ -132,7 +132,7 @@ public override ReadOnlySpan<byte> ReadBits(int bitCount)
if (!CanRead(bitCount) || bitCount < 0)
{
IsError = true;
return ReadOnlySpan<byte>.Empty;
return [];
}

var bitCountUsedInByte = Position & 7;
Expand Down Expand Up @@ -205,7 +205,7 @@ public override ReadOnlySpan<byte> ReadBytes(int byteCount)
if (!CanRead(byteCount * 8) || byteCount < 0)
{
IsError = true;
return Span<byte>.Empty;
return [];
}

var bitCountUsedInByte = Position & 7;
Expand Down
10 changes: 10 additions & 0 deletions src/Unreal.Core/Models/FRepMovement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ public struct FRepMovement
/// </summary>
public FRotator Rotation { get; set; }

/// <summary>
/// Acceleration of component in world space. Only valid if bRepAcceleration is set.
/// </summary>
public FVector? Acceleration { get; set; }

/// <summary>
/// If set, RootComponent should be sleeping.
/// </summary>
Expand All @@ -38,6 +43,11 @@ public struct FRepMovement
/// </summary>
public bool bRepPhysics { get; set; }

/// <summary>
/// If set, additional acceleration data will be replicated.
/// </summary>
public bool bRepAcceleration { get; set; }

/// <summary>
/// Server physics step
/// </summary>
Expand Down
10 changes: 9 additions & 1 deletion src/Unreal.Core/NetBitReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ public FRepMovement SerializeRepMovement(
bRepPhysics = bRepPhysics,
Location = SerializePropertyQuantizedVector(locationQuantizationLevel),
Rotation = rotationQuantizationLevel == RotatorQuantization.ByteComponents ? ReadRotation() : ReadRotationShort(),

LinearVelocity = SerializePropertyQuantizedVector(velocityQuantizationLevel)
};

Expand All @@ -79,6 +78,15 @@ public FRepMovement SerializeRepMovement(
repMovement.ServerPhysicsHandle = ReadIntPacked();
}

if (EngineNetworkVersion >= EngineNetworkVersionHistory.RepMoveOptionalAcceleration)
{
repMovement.bRepAcceleration = ReadBit();
if (repMovement.bRepAcceleration)
{
repMovement.Acceleration = SerializePropertyQuantizedVector(velocityQuantizationLevel);
}
}

return repMovement;
}

Expand Down
Loading

0 comments on commit 30d7bb5

Please sign in to comment.