Skip to content

Commit

Permalink
Merge branch 'UE4-2014' into feature/Feature-merge_UE4
Browse files Browse the repository at this point in the history
  • Loading branch information
EliotVU committed Jun 14, 2022
2 parents 9a65954 + ab49963 commit ea3c1aa
Show file tree
Hide file tree
Showing 25 changed files with 912 additions and 637 deletions.
14 changes: 9 additions & 5 deletions Benchmark/UnrealTestStream.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,20 @@ 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 uint Version => _Archive.Version;
public uint LicenseeVersion { get; }
public uint UE4Version { get; }
public bool BigEndianCode { get; }

public UnrealPackage Package => _Archive.Package;
public UnrealReader UR => this;
public UnrealWriter UW { get; }

public UnrealTestStream(IUnrealArchive archive, Stream baseStream) : base(archive, baseStream)
{
_Archive = archive;
}

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

public string ReadASCIIString()
{
throw new NotImplementedException();
Expand Down
14 changes: 10 additions & 4 deletions Test/UnrealStreamTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,11 @@ public void ReadString()
{
using var stream = CreateTempStream();
using var linker = new UnrealPackage(stream);
// The easiest version to test against.
linker.Version = 300;
linker.Summary = new UnrealPackage.PackageFileSummary()
{
// The easiest version to test against.
Version = 300
};
using var writer = new BinaryWriter(stream);
// Skip past the signature
writer.Seek(sizeof(int), SeekOrigin.Begin);
Expand Down Expand Up @@ -59,8 +62,11 @@ public void ReadAtomicStruct()
{
using var stream = CreateTempStream();
using var linker = new UnrealPackage(stream);
// The easiest version to test against.
linker.Version = 300;
linker.Summary = new UnrealPackage.PackageFileSummary()
{
// The easiest version to test against.
Version = 300
};
using var writer = new BinaryWriter(stream);
// Skip past the signature
writer.Seek(sizeof(int), SeekOrigin.Begin);
Expand Down
50 changes: 28 additions & 22 deletions src/Core/Classes/Props/UProperty.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ public partial class UProperty : UField, IUnrealNetObject

[CanBeNull] public UName CategoryName;

[Obsolete("See CategoryName")]
public int CategoryIndex { get; }
[Obsolete("See CategoryName")] public int CategoryIndex { get; }

[CanBeNull] public UEnum ArrayEnum { get; private set; }

Expand Down Expand Up @@ -115,30 +114,36 @@ protected override void Deserialize()
Record(nameof(deusFlags), deusFlags);
}
#endif
if (!Package.IsConsoleCooked())
// FIXME: UE4 version
if (!Package.IsConsoleCooked() && _Buffer.UE4Version < 160)
{
CategoryName = _Buffer.ReadNameReference();
Record(nameof(CategoryName), CategoryName);
}

if (Package.Version > 400)
{
ArrayEnum = GetIndexObject(_Buffer.ReadObjectIndex()) as UEnum;
Record("ArrayEnum", ArrayEnum);
}
else
{
if (Package.Version > 400)
{
ArrayEnum = GetIndexObject(_Buffer.ReadObjectIndex()) as UEnum;
Record("ArrayEnum", ArrayEnum);
}
#if THIEF_DS || DEUSEX_IW
if (Package.Build == BuildGeneration.Thief)
{
short deusInheritedOrRuntimeInstiantiated = _Buffer.ReadInt16();
Record(nameof(deusInheritedOrRuntimeInstiantiated), deusInheritedOrRuntimeInstiantiated);
short deusUnkInt16= _Buffer.ReadInt16();
Record(nameof(deusUnkInt16), deusUnkInt16);
}
if (Package.Build == BuildGeneration.Thief)
{
short deusInheritedOrRuntimeInstiantiated = _Buffer.ReadInt16();
Record(nameof(deusInheritedOrRuntimeInstiantiated), deusInheritedOrRuntimeInstiantiated);
short deusUnkInt16 = _Buffer.ReadInt16();
Record(nameof(deusUnkInt16), deusUnkInt16);
}
#endif
}
#if UE4
if (_Buffer.UE4Version > 0)
{
// RepNotify function name
var repnotifyFunc = _Buffer.ReadNameReference();
Record("RepNotifyFunc", repnotifyFunc);
return;
}

#endif
if (HasPropertyFlag(PropertyFlagsLO.Net))
{
RepOffset = _Buffer.ReadUShort();
Expand All @@ -155,7 +160,8 @@ protected override void Deserialize()
#endif
// Appears to be a UE2X feature, it is not present in UE2 builds with no custom LicenseeVersion
// Albeit DeusEx indicates otherwise?
if ((HasPropertyFlag(PropertyFlagsLO.EditorData) && (Package.Build == BuildGeneration.UE2_5 || Package.Build == BuildGeneration.Thief))
if ((HasPropertyFlag(PropertyFlagsLO.EditorData) &&
(Package.Build == BuildGeneration.UE2_5 || Package.Build == BuildGeneration.Thief))
// No property flag
|| Package.Build == BuildGeneration.Vengeance)
{
Expand All @@ -169,12 +175,12 @@ protected override void Deserialize()
if (_Buffer.Version < 157)
{
throw new NotSupportedException("< 157 Spellborn packages are not supported");

if (133 < _Buffer.Version)
{
// idk
}

if (134 < _Buffer.Version)
{
int unk32 = _Buffer.ReadInt32();
Expand Down
23 changes: 1 addition & 22 deletions src/Core/Classes/Props/UPropertyDecompiler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,28 +11,7 @@ public partial class UProperty
// Called before the var () is printed.
public virtual string PreDecompile()
{
string tooltipValue = null;
MetaData?.Tags.TryGetValue("ToolTip", out tooltipValue);
if (tooltipValue == null)
{
return string.Empty;
}

var comment = $"{UDecompilingState.Tabs}/** ";
// Multiline comment?
if (tooltipValue.IndexOf('\n') != -1)
{
comment +=
" \r\n" +
$"{UDecompilingState.Tabs} *{tooltipValue.Replace("\n", "\n" + UDecompilingState.Tabs + " *")}" +
$"\r\n{UDecompilingState.Tabs}";
}
else
{
comment += tooltipValue;
}

return $"{comment} */\r\n";
return FormatTooltipMetaData();
}

public override string Decompile()
Expand Down
Loading

0 comments on commit ea3c1aa

Please sign in to comment.