Skip to content

Commit

Permalink
Support data types (UClass, UTextBuffer, UPalette, USound) for "Clive…
Browse files Browse the repository at this point in the history
… Barker's Undying" (UE1).
  • Loading branch information
EliotVU committed Oct 15, 2022
1 parent 17688c1 commit 4780771
Show file tree
Hide file tree
Showing 6 changed files with 125 additions and 15 deletions.
20 changes: 14 additions & 6 deletions src/Core/Classes/UClass.cs
Original file line number Diff line number Diff line change
Expand Up @@ -403,13 +403,12 @@ protected override void Deserialize()
#endif
}
}
#if UE4
if (_Buffer.UE4Version > 0)
#if UNDYING
if (Package.Build == UnrealPackage.GameBuild.BuildName.Undying &&
_Buffer.Version >= 70)
{
string dummy = _Buffer.ReadName();
Record("dummy", dummy);
bool isCooked = _Buffer.ReadBool();
Record("isCooked", isCooked);
_Buffer.Read(out uint classCRC); // v4a8
Record(nameof(classCRC), classCRC);
}
#endif
#if THIEF_DS || DeusEx_IW
Expand Down Expand Up @@ -507,6 +506,15 @@ protected override void Deserialize()
Record("Unknown:Vengeance", b);
}
}
#endif
#if UE4
if (_Buffer.UE4Version > 0)
{
string dummy = _Buffer.ReadName();
Record("dummy", dummy);
bool isCooked = _Buffer.ReadBool();
Record("isCooked", isCooked);
}
#endif
scriptProperties:
// In later UE3 builds, defaultproperties are stored in separated objects named DEFAULT_namehere,
Expand Down
24 changes: 22 additions & 2 deletions src/Core/Classes/UTextBuffer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ public partial class UTextBuffer : UObject

public uint Top;
public uint Pos;

public string ScriptText;

#endregion
Expand All @@ -22,11 +22,31 @@ public UTextBuffer()
protected override void Deserialize()
{
base.Deserialize();

Top = _Buffer.ReadUInt32();
Record(nameof(Top), Top);
Pos = _Buffer.ReadUInt32();
Record(nameof(Pos), Pos);
#if UNDYING
if (Package.Build == UnrealPackage.GameBuild.BuildName.Undying &&
_Buffer.Version >= 85)
{
int uncompressedDataSize = _Buffer.ReadIndex();
Record(nameof(uncompressedDataSize), uncompressedDataSize);

int dataLength = _Buffer.ReadIndex();
Record(nameof(dataLength), dataLength);
if (dataLength > 0)
{
var data = new byte[uncompressedDataSize];
_Buffer.Read(data, 0, dataLength);
Record(nameof(data), data);
}

ScriptText = "Text data is compressed";
return;
}
#endif
ScriptText = _Buffer.ReadText();
Record(nameof(ScriptText), "...");
}
Expand Down
10 changes: 5 additions & 5 deletions src/Eliot.UELib.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>TRACE;DEBUG;DECOMPILE BINARYMETADATA Forms UE1 UE2 UE3 UE4 VENGEANCE SWAT4 UNREAL2 INFINITYBLADE BORDERLANDS2 GOW2 DEBUG_TEST APB SPECIALFORCE2 XIII SINGULARITY THIEF_DS DEUSEX_IW BORDERLANDS MIRRORSEDGE BIOSHOCK HAWKEN UT DISHONORED REMEMBERME ALPHAPROTOCOL VANGUARD TERA MKKE TRANSFORMERS XCOM2 DD2 DCUO AA2 SPELLBORN BATMAN MOH ROCKETLEAGUE DNF LSGAME</DefineConstants>
<DefineConstants>TRACE;DEBUG;DECOMPILE BINARYMETADATA Forms UE1 UE2 UE3 UE4 VENGEANCE SWAT4 UNREAL2 INFINITYBLADE BORDERLANDS2 GOW2 DEBUG_TEST APB SPECIALFORCE2 XIII SINGULARITY THIEF_DS DEUSEX_IW BORDERLANDS MIRRORSEDGE BIOSHOCK HAWKEN UT DISHONORED REMEMBERME ALPHAPROTOCOL VANGUARD TERA MKKE TRANSFORMERS XCOM2 DD2 DCUO AA2 SPELLBORN BATMAN MOH ROCKETLEAGUE DNF LSGAME UNDYING</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>0</WarningLevel>
<PlatformTarget>AnyCPU</PlatformTarget>
Expand All @@ -61,7 +61,7 @@
<DebugType>none</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE;DECOMPILE BINARYMETADATA Forms UE1 UE2 UE3 UE4 VENGEANCE SWAT4 UNREAL2 INFINITYBLADE BORDERLANDS2 GOW2 APB SPECIALFORCE2 XIII SINGULARITY THIEF_DS DEUSEX_IW BORDERLANDS MIRRORSEDGE BIOSHOCK HAWKEN UT DISHONORED REMEMBERME ALPHAPROTOCOL VANGUARD TERA MKKE TRANSFORMERS XCOM2 DD2 DCUO AA2 SPELLBORN BATMAN ROCKETLEAGUE DNF LSGAME</DefineConstants>
<DefineConstants>TRACE;DECOMPILE BINARYMETADATA Forms UE1 UE2 UE3 UE4 VENGEANCE SWAT4 UNREAL2 INFINITYBLADE BORDERLANDS2 GOW2 APB SPECIALFORCE2 XIII SINGULARITY THIEF_DS DEUSEX_IW BORDERLANDS MIRRORSEDGE BIOSHOCK HAWKEN UT DISHONORED REMEMBERME ALPHAPROTOCOL VANGUARD TERA MKKE TRANSFORMERS XCOM2 DD2 DCUO AA2 SPELLBORN BATMAN ROCKETLEAGUE DNF LSGAME UNDYING</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<DocumentationFile>
Expand All @@ -73,7 +73,7 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'DecompileDebug|AnyCPU'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>TRACE;DEBUG;DECOMPILE BINARYMETADATA Forms UE1 UE2 UE3 UE4 DEBUG_TEST DEBUG_TOKENPOSITIONS DEBUG_HIDDENTOKENS DEBUG_NESTS DEBUG_FUNCTIONINFO UE1 UE2 UE3 VENGEANCE SWAT4 UNREAL2 INFINITYBLADE BORDERLANDS2 GOW2 DEBUG_TEST APB SPECIALFORCE2 XIII SINGULARITY THIEF_DS DEUSEX_IW BORDERLANDS MIRRORSEDGE BIOSHOCK HAWKEN UT DISHONORED REMEMBERME ALPHAPROTOCOL VANGUARD TERA MKKE TRANSFORMERS XCOM2 DD2 DCUO AA2 SPELLBORN BATMAN MOH ROCKETLEAGUE DNF LSGAME</DefineConstants>
<DefineConstants>TRACE;DEBUG;DECOMPILE BINARYMETADATA Forms UE1 UE2 UE3 UE4 DEBUG_TEST DEBUG_TOKENPOSITIONS DEBUG_HIDDENTOKENS DEBUG_NESTS DEBUG_FUNCTIONINFO UE1 UE2 UE3 VENGEANCE SWAT4 UNREAL2 INFINITYBLADE BORDERLANDS2 GOW2 DEBUG_TEST APB SPECIALFORCE2 XIII SINGULARITY THIEF_DS DEUSEX_IW BORDERLANDS MIRRORSEDGE BIOSHOCK HAWKEN UT DISHONORED REMEMBERME ALPHAPROTOCOL VANGUARD TERA MKKE TRANSFORMERS XCOM2 DD2 DCUO AA2 SPELLBORN BATMAN MOH ROCKETLEAGUE DNF LSGAME UNDYING</DefineConstants>
<DocumentationFile>
</DocumentationFile>
<Optimize>false</Optimize>
Expand All @@ -85,7 +85,7 @@
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Publish|AnyCPU'">
<OutputPath>bin\Publish\</OutputPath>
<DefineConstants>Forms DECOMPILE BINARYMETADATA UE1 UE2 UE3 UE4 VENGEANCE SWAT4 UNREAL2 INFINITYBLADE BORDERLANDS2 GOW2 APB SPECIALFORCE2 XIII SINGULARITY THIEF_DS DEUSEX_IW BORDERLANDS MIRRORSEDGE BIOSHOCK HAWKEN UT DISHONORED REMEMBERME ALPHAPROTOCOL VANGUARD TERA MKKE TRANSFORMERS XCOM2 DD2 DCUO AA2 SPELLBORN BATMAN ROCKETLEAGUE DNF LSGAME</DefineConstants>
<DefineConstants>Forms DECOMPILE BINARYMETADATA UE1 UE2 UE3 UE4 VENGEANCE SWAT4 UNREAL2 INFINITYBLADE BORDERLANDS2 GOW2 APB SPECIALFORCE2 XIII SINGULARITY THIEF_DS DEUSEX_IW BORDERLANDS MIRRORSEDGE BIOSHOCK HAWKEN UT DISHONORED REMEMBERME ALPHAPROTOCOL VANGUARD TERA MKKE TRANSFORMERS XCOM2 DD2 DCUO AA2 SPELLBORN BATMAN ROCKETLEAGUE DNF LSGAME UNDYING</DefineConstants>
<Optimize>true</Optimize>
<PlatformTarget>AnyCPU</PlatformTarget>
<DocumentationFile>
Expand All @@ -97,7 +97,7 @@
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'UnitTest|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\Test\</OutputPath>
<DefineConstants>TRACE;DEBUG;STRICT DECOMPILE UE1 UE2 UE3 UE4 VENGEANCE SWAT4 UNREAL2 INFINITYBLADE BORDERLANDS2 GOW2 DEBUG_TEST APB SPECIALFORCE2 XIII SINGULARITY THIEF_DS DEUSEX_IW BORDERLANDS MIRRORSEDGE BIOSHOCK HAWKEN UT DISHONORED REMEMBERME ALPHAPROTOCOL VANGUARD TERA MKKE TRANSFORMERS XCOM2 DD2 DCUO AA2 SPELLBORN BATMAN ROCKETLEAGUE DNF LSGAME</DefineConstants>
<DefineConstants>TRACE;DEBUG;STRICT DECOMPILE UE1 UE2 UE3 UE4 VENGEANCE SWAT4 UNREAL2 INFINITYBLADE BORDERLANDS2 GOW2 DEBUG_TEST APB SPECIALFORCE2 XIII SINGULARITY THIEF_DS DEUSEX_IW BORDERLANDS MIRRORSEDGE BIOSHOCK HAWKEN UT DISHONORED REMEMBERME ALPHAPROTOCOL VANGUARD TERA MKKE TRANSFORMERS XCOM2 DD2 DCUO AA2 SPELLBORN BATMAN ROCKETLEAGUE DNF LSGAME UNDYING</DefineConstants>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<WarningLevel>0</WarningLevel>
<DebugType>full</DebugType>
Expand Down
11 changes: 11 additions & 0 deletions src/Engine/Classes/UPalette.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Diagnostics;
using UELib.Branch;
using UELib.Core;

namespace UELib.Engine
Expand All @@ -14,6 +15,9 @@ public class UPalette : UObject, IUnrealViewable
/// </summary>
public UArray<UColor> Colors;

[Build(UnrealPackage.GameBuild.BuildName.Undying)]
public bool HasAlphaChannel;

public UPalette()
{
ShouldDeserializeOnDemand = true;
Expand All @@ -27,6 +31,13 @@ protected override void Deserialize()
int count = _Buffer.ReadIndex();
Debug.Assert(count == 256);
_Buffer.ReadMarshalArray(out Colors, count);
#if UNDYING
if (Package.Build == UnrealPackage.GameBuild.BuildName.Undying &&
_Buffer.Version >= 75)
{
_Buffer.Read(out HasAlphaChannel); // v28
}
#endif
}
}
}
59 changes: 59 additions & 0 deletions src/Engine/Classes/USound.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,40 @@ protected override void Deserialize()

FileType = _Buffer.ReadNameReference();
Record(nameof(FileType), FileType);
#if UNDYING
if (Package.Build == UnrealPackage.GameBuild.BuildName.Undying)
{
if (_Buffer.Version >= 77)
{
_Buffer.Read(out int v7c);
Record(nameof(v7c), v7c);
_Buffer.Read(out int v74);
Record(nameof(v74), v74);
_Buffer.Read(out float v6c);
Record(nameof(v6c), v6c);
}

if (_Buffer.Version >= 79)
{
_Buffer.Read(out uint v78);
Record(nameof(v78), v78);
_Buffer.Read(out float v68); // Radius?
Record(nameof(v68), v68);
}

if (_Buffer.Version >= 80)
{
_Buffer.Read(out float v80);
Record(nameof(v80), v80);
}

if (_Buffer.Version >= 82)
{
_Buffer.Read(out int v84);
Record(nameof(v84), v84);
}
}
#endif
#if UT
if ((Package.Build == UnrealPackage.GameBuild.BuildName.UT2004 ||
Package.Build == UnrealPackage.GameBuild.BuildName.UT2003)
Expand All @@ -57,6 +91,31 @@ protected override void Deserialize()
// Resource Interchange File Format
_Buffer.ReadLazyArray(out Data);
Record(nameof(Data), Data);
#if UNDYING
if (Package.Build == UnrealPackage.GameBuild.BuildName.Undying)
{
if (_Buffer.Version >= 76)
{
_Buffer.Read(out uint v5c);
Record(nameof(v5c), v5c);

int undyingExtraDataLength = _Buffer.ReadIndex();
Record(nameof(undyingExtraDataLength), undyingExtraDataLength);
if (undyingExtraDataLength > 0)
{
var undyingExtraData = new byte[undyingExtraDataLength];
_Buffer.Read(undyingExtraData, 0, undyingExtraDataLength);
Record(nameof(undyingExtraData), undyingExtraData);
}
}

if (_Buffer.Version >= 85)
{
_Buffer.Read(out uint v8c);
Record(nameof(v8c), v8c);
}
}
#endif
}
}
}
16 changes: 14 additions & 2 deletions src/UnrealPackage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -170,14 +170,26 @@ public enum BuildName
///
/// 61/000
/// </summary>
[Build(61, 0)] Unreal1,
[Build(61, 0, BuildGeneration.UE1)] Unreal1,

/// <summary>
/// Standard, Unreal Tournament & Deus Ex
///
/// 68:69/000
/// </summary>
[Build(68, 69, 0u, 0u)] UT,
[Build(68, 69, 0u, 0u, BuildGeneration.UE1)]
UT,

//[Build(80, 0, BuildGeneration.UE1)]
BrotherBear,

/// <summary>
/// Clive Barker's Undying
///
/// 72:85/000 (Only 84 to 85 is auto detected, other versions are overlapping with older unrelated games)
/// </summary>
[Build(84, 85, 0u, 0u, BuildGeneration.UE1)]
Undying,

/// <summary>
/// Deus Ex: Invisible War
Expand Down

0 comments on commit 4780771

Please sign in to comment.