Skip to content

Commit

Permalink
Finish release-1.4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
EliotVU committed Mar 25, 2024
2 parents 6cc86f0 + 6968579 commit 58b5022
Show file tree
Hide file tree
Showing 203 changed files with 12,220 additions and 5,857 deletions.
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"dotnet.defaultSolution": "src\\Eliot.UELib.sln"
}
6 changes: 4 additions & 2 deletions Benchmark/Eliot.UELib.Benchmark.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,17 @@
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
<Configurations>Debug;Release;UnitTest</Configurations>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<IsPublishable>False</IsPublishable>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="BenchmarkDotNet" Version="0.13.1" />
<PackageReference Include="BenchmarkDotNet" Version="0.13.5" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\src\Eliot.UELib.csproj" />
<ProjectReference Include="..\Test\Eliot.UELib.Test.csproj" />
</ItemGroup>

</Project>
9 changes: 4 additions & 5 deletions Benchmark/UnrealPackageBenchmark.cs
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
using System.IO;
using System.Reflection;
using BenchmarkDotNet.Attributes;
using Eliot.UELib.Test;
using UELib;

namespace Eliot.UELib.Benchmark
{
public class UnrealPackageBenchmark
{
private readonly string _TempFilePath;
private UnrealPackage _Linker;
private readonly UnrealPackage _Linker;

public UnrealPackageBenchmark()
{
byte[] testFileBytes = Packages.TestUC2;
byte[] testFileBytes = { };
_TempFilePath = Path.Join(Assembly.GetExecutingAssembly().Location, "../test.u");
// Workaround due the enforced use of UnrealLoader's UPackageStream
File.WriteAllBytes(_TempFilePath, testFileBytes);
Expand All @@ -34,8 +33,8 @@ public void PackageDeserialization()
public void NamesDeserialization()
{
_Linker.Stream.Position = 4;
_Linker.Stream.Seek(_Linker.Summary.NamesOffset, SeekOrigin.Begin);
for (var i = 0; i < _Linker.Summary.NamesCount; ++i)
_Linker.Stream.Seek(_Linker.Summary.NameOffset, SeekOrigin.Begin);
for (var i = 0; i < _Linker.Summary.NameCount; ++i)
{
var nameEntry = new UNameTableItem();
nameEntry.Deserialize(_Linker.Stream);
Expand Down
136 changes: 120 additions & 16 deletions Benchmark/UnrealStreamBenchmark.cs
Original file line number Diff line number Diff line change
@@ -1,31 +1,135 @@
using System.IO;
using UELib;
using UELib.Core.Types;
using BenchmarkDotNet.Attributes;
using UELib;
using UELib.Core;

namespace Eliot.UELib.Benchmark
{
public class UnrealStreamBenchmark
{
private IUnrealStream _Stream;

private readonly byte[] _ArchiveData = new byte[20];
private readonly IUnrealStream _Stream;

private UColor _Color = new UColor(128, 64, 32, 0);
private readonly long _ColorPosition;

private int _CompactIndex1 = 0x40 - 1;
private int _CompactIndex2 = 0x40 + (0x80 - 1);
private int _CompactIndex3 = 0x40 + 0x80 + (0x80 - 1);
private readonly long _CompactIndexPosition1, _CompactIndexPosition2, _CompactIndexPosition3;

private string _String = "String";
private readonly long _StringPosition;

public UnrealStreamBenchmark()
{
// B, G, R, A;
var structBuffer = new byte[] { 255, 128, 64, 80 };
var baseStream = new MemoryStream(structBuffer);
_Stream = new UnrealTestStream(null, baseStream);
var baseStream = new MemoryStream(_ArchiveData);
var testArchive = new UnrealTestArchive(null, 100);
_Stream = new UnrealTestStream(testArchive, baseStream);

_CompactIndexPosition1 = _Stream.Position;
_Stream.WriteIndex(_CompactIndex1);

_CompactIndexPosition2 = _Stream.Position;
_Stream.WriteIndex(_CompactIndex2);

_CompactIndexPosition3 = _Stream.Position;
_Stream.WriteIndex(_CompactIndex3);

_StringPosition = _Stream.Position;
_Stream.WriteString(_String);

_ColorPosition = _Stream.Position;
_Stream.WriteStruct(ref _Color);
}

[Benchmark]
public void ReadCompactIndex1()
{
_Stream.Position = _CompactIndexPosition1;
_CompactIndex1 = _Stream.ReadIndex();
}

[Benchmark]
public void WriteCompactIndex1()
{
_Stream.Position = _CompactIndexPosition1;
_Stream.WriteIndex(_CompactIndex1);
}

[Benchmark]
public void ReadCompactIndex2()
{
_Stream.Position = _CompactIndexPosition2;
_CompactIndex2 = _Stream.ReadIndex();
}

[Benchmark]
public void WriteCompactIndex2()
{
_Stream.Position = _CompactIndexPosition2;
_Stream.WriteIndex(_CompactIndex2);
}

[Benchmark]
public void ReadCompactIndex3()
{
_Stream.Position = _CompactIndexPosition3;
_CompactIndex3 = _Stream.ReadIndex();
}

[Benchmark]
public void WriteCompactIndex3()
{
_Stream.Position = _CompactIndexPosition3;
_Stream.WriteIndex(_CompactIndex3);
}

[Benchmark]
public void ReadString()
{
_Stream.Position = _StringPosition;
_String = _Stream.ReadString();
}

[Benchmark]
public void WriteString()
{
_Stream.Position = _StringPosition;
_Stream.WriteString(_String);
}

[Benchmark]
public void ReadColor()
{
_Stream.Position = _ColorPosition;
_Stream.ReadStruct(_Color);
}

[Benchmark]
public void WriteColor()
{
_Stream.Position = _ColorPosition;
_Stream.WriteStruct(ref _Color);
}

/// <summary>
/// Verify that ReadAtomicStruct is indeed performing its purpose :)
/// </summary>

// So far marshal is faster! But writing is still slower
// | Method | Mean | Error | StdDev |
// |------------------- |---------:|---------:|---------:|
// | ReadColor | 38.17 ns | 0.781 ns | 0.767 ns |
// | ReadColorMarshal | 16.06 ns | 0.344 ns | 0.545 ns |
[Benchmark]
public void ReadColorMarshal()
{
_Stream.Position = _ColorPosition;
_Stream.ReadStructMarshal(out _Color);
}

[Benchmark]
public void ReadAtomicStruct()
public void WriteColorMarshal()
{
var stream = _Stream;
stream.Seek(0, SeekOrigin.Begin);
stream.ReadAtomicStruct(out UColor color);
_Stream.Position = _ColorPosition;
_Stream.WriteStructMarshal(ref _Color);
}
}
}
64 changes: 38 additions & 26 deletions Benchmark/UnrealTestStream.cs
Original file line number Diff line number Diff line change
@@ -1,34 +1,52 @@
using System;
using System.IO;
using UELib;
using UELib.Branch;
using UELib.Core;
using UELib.Decoding;

namespace Eliot.UELib.Benchmark
{
/// Hackish workaround for the issue with UPackageStream requiring a file and path, so that we can perform stream tests without a package.
public class UnrealTestStream : UnrealReader, IUnrealStream
public class UnrealTestArchive : IUnrealArchive
{
public UnrealTestStream(IUnrealArchive archive, Stream baseStream) : base(archive, baseStream)
public UnrealTestArchive(UnrealPackage package, uint version, uint licenseeVersion = 0, uint ue4Version = 0, bool bigEndianCode = false)
{
_Archive = archive;
Package = package;
Version = version;
LicenseeVersion = licenseeVersion;
UE4Version = ue4Version;
BigEndianCode = bigEndianCode;
}

public UnrealPackage Package => _Archive.Package;
public UnrealReader UR => this;
public UnrealPackage Package { get; }
public uint Version { get; }
public uint LicenseeVersion { get; }
public uint UE4Version { get; }
public bool BigEndianCode { get; }
}

/// Hackish workaround for the issue with UPackageStream requiring a file and path, so that we can perform stream tests without a package.
public class UnrealTestStream : UnrealReader, IUnrealStream
{
public uint Version => Archive.Version;
public uint LicenseeVersion => Archive.LicenseeVersion;
public uint UE4Version => Archive.UE4Version;
public bool BigEndianCode => Archive.BigEndianCode;

public UnrealPackage Package => Archive.Package;
public UnrealReader UR { get; }
public UnrealWriter UW { get; }
public uint Version => _Archive.Version;

public string ReadASCIIString()
{
throw new NotImplementedException();
}
public IBufferDecoder Decoder { get; set; }
public IPackageSerializer Serializer { get; set; }

public int ReadObjectIndex()
public UnrealTestStream(IUnrealArchive archive, Stream baseStream) : base(archive, baseStream)
{
throw new NotImplementedException();
UR = new UnrealReader(archive, baseStream);
UW = new UnrealWriter(archive, baseStream);
}

public UObject ReadObject()
public int ReadObjectIndex()
{
throw new NotImplementedException();
}
Expand All @@ -38,12 +56,12 @@ public UObject ParseObject(int index)
throw new NotImplementedException();
}

public int ReadNameIndex()
public new int ReadNameIndex()
{
throw new NotImplementedException();
}

public int ReadNameIndex(out int num)
public new int ReadNameIndex(out int num)
{
throw new NotImplementedException();
}
Expand All @@ -53,32 +71,26 @@ public string ParseName(int index)
throw new NotImplementedException();
}

public float ReadFloat()
{
throw new NotImplementedException();
}

public void Skip(int bytes)
{
throw new NotImplementedException();
}

public long Length => BaseStream.Length;
public long Position
{
get => BaseStream.Position;
set => BaseStream.Position = value;
}

public long LastPosition
public long AbsolutePosition
{
get => _Archive.LastPosition;
set => _Archive.LastPosition = value;
get => Position;
set => Position = value;
}

public long Seek(long offset, SeekOrigin origin)
{
return BaseStream.Seek(offset, origin);
}
}
}
}
55 changes: 52 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,62 @@
# [1.4.0](https://github.com/EliotVU/Unreal-Library/releases/tag/1.4.0)

Notable changes that affect UnrealScript output:

* Improved decompilation output of string and decimal literals.
* 5141285c Improved decompilation of delegate assignments (in a T3D context)
* 6d889c87 Added decompilation of optional parameter assignments e.g. `function MyFunction(option bool A = true);`.
* e55cfce0 Fixed decompilation with arrays of bools

Notable changes that affect support of games:

General deserialization fixes that affect all of UE1, UE2, and UE3 builds, as well as more specifically:

* 13460cca Support for Battleborn
* 4aff61fa Support for Duke Nukem Forever (2011)
* bce38c4f Support for Tom Clancy's Splinter Cell
* 809edaad Support for Harry Potter (UE1) data class {USound}
* b3e1489d Support for Devastation (UE2, 2003)
* 4780771a Support for Clive Barker's Undying (UE1) data classes {UClass, UTextBuffer, UPalette, USound}
* 01772a83 Support for Lemony Snicket's A Series of Unfortunate Events data class {UProperty}
* c4c1978d Fixed support for Dungeon Defenders 2 (versions 687-688/111-117)
* 86538e5d Fixed support for Vanguard: Saga of Heroes
* eb82dba5 Fixed support for Rocket League (version 868/003)
* 6ed6ed74 Fixed support for Hawken (version 860/002)
* b4b79773 Fixed ResizeStringToken for UE1 builds
* 3653f8e1 Fixed ReturnToken and BeginFunctionToken for UE1 builds (with a package version of 61)
* 9a659549 Fixed deserialization of Heritages for UE1 builds (with a package version older than 68)

Notable changes that affect various data structures:

* Improved detection of UComponent objects and class types.
* ea3c1aa5 Support for UE4 .uasset packages (earlier builds only)
* e37b8a12 Support for class {UTexture}, f1b74af1 {UPrimitive, UTexture2D and its derivatives} (UE3)
* aa5ca861 Support for classes: {UFont, UMultiFont}
* ab290b6c Support for types {UPolys, FPoly}
* 02bea77b Support for types {FUntypedBulkData} (UE3) and {TLazyArray} (UE1, UE2)
* 94e02927 Support for structures: {FPointRegion, FCoords, FPlane, FScale, FSphere, FRotator, FVector, FGuid, FBox, FLinearColor, FMatrix, FQuat, FRange, FRangeVector, FVector2D, FVector4}
* 09c76240 Support for class {USoundGroup} (UE2.5)

**Support for the data types listed above have only been implemented for the standard structure that Epic Games uses**

# [1.3.1](https://github.com/EliotVU/Unreal-Library/releases/tag/1.3.1)

Notable changes back-ported from 'develop' version 1.4.0:

* Added support for various data structures: FColor; and data class UBitmapMaterial (UE2)

* Improved support for Batman series
* Improved support for Transformers series
* Fixed the decompilation of UnrealScript casting byte-codes that were swapped i.e. `InterfaceToBool` with `InterfaceToObject`.
* Fixed a missing package version check in UStateFrame (this affected some object classes that are usually found in map package files).
* Added the capability to override the interpreted version for packages of builds that are auto-detected.
* e8308284 Fixed decompilation of primitive castings for UE1 builds
* ffaca763 Fixed decompilation of interface castings i.e. `InterfaceToBool` with `InterfaceToObject` (UE3).
* 3317e06a Fixed a missing package version check in UStateFrame (this affected some object classes that are usually found in map package files).

* 42783b16 Added the capability to override the interpreted version for packages of builds that are auto-detected.

# [1.3.0](https://github.com/EliotVU/Unreal-Library/releases/tag/1.3.0.0)

Notable changes:

* Support for Vengeance which includes BioShock 1 & 2, Swat4, and Tribes: Vengeance
* Support for Batman series (to the release branch, incomplete)
* Support for Thief: Deadly Shadows and Deus Ex: Invisible War
Expand Down
Loading

0 comments on commit 58b5022

Please sign in to comment.