diff --git a/src/Core/Classes/UEnumDecompiler.cs b/src/Core/Classes/UEnumDecompiler.cs index 0bc476c..6664513 100644 --- a/src/Core/Classes/UEnumDecompiler.cs +++ b/src/Core/Classes/UEnumDecompiler.cs @@ -20,7 +20,7 @@ public override string Decompile() UnrealConfig.PrintEndBracket() + ";"; } - protected override string FormatHeader() + protected virtual string FormatHeader() { return $"enum {Name}{DecompileMeta()}"; } diff --git a/src/Core/Classes/UMetaData.cs b/src/Core/Classes/UMetaData.cs index 27c8173..aebcc69 100644 --- a/src/Core/Classes/UMetaData.cs +++ b/src/Core/Classes/UMetaData.cs @@ -71,8 +71,13 @@ public override string ToString() #region Serialized Members - // ReSharper disable once MemberCanBePrivate.Global - public UArray MetaObjects; + private UArray _Fields; + + public UArray Fields + { + get => _Fields; + set => _Fields = value; + } #endregion @@ -81,8 +86,8 @@ public override string ToString() protected override void Deserialize() { base.Deserialize(); - _Buffer.ReadArray(out MetaObjects); - Record(nameof(MetaObjects), MetaObjects); + _Buffer.ReadArray(out _Fields); + Record(nameof(_Fields), _Fields); } #endregion @@ -103,12 +108,12 @@ public override string Decompile() { // UE3 Debug BeginDeserializing(); - if (MetaObjects == null) + if (_Fields == null) { return ""; } - return string.Join("\r\n", MetaObjects.ConvertAll(data => data + data.Decompile())); + return string.Join("\r\n", _Fields.ConvertAll(data => data + data.Decompile())); } #endregion diff --git a/src/Core/Classes/UObjectDecompiler.cs b/src/Core/Classes/UObjectDecompiler.cs index d7dcd7b..ecfa5e3 100644 --- a/src/Core/Classes/UObjectDecompiler.cs +++ b/src/Core/Classes/UObjectDecompiler.cs @@ -1,4 +1,6 @@ -namespace UELib.Core +using System.Diagnostics; + +namespace UELib.Core { public partial class UObject : IUnrealDecompilable { @@ -12,8 +14,14 @@ public virtual string Decompile() BeginDeserializing(); } + if (ImportTable != null) + { + return $"// Cannot decompile import {Name}"; + } + + Debug.Assert(Class != null); string output = $"begin object name={Name} class={Class.Name}" + - $"\r\n"; + "\r\n"; UDecompilingState.AddTabs(1); try { @@ -29,12 +37,6 @@ public virtual string Decompile() $"// Reference: {Class.Name}'{GetOuterGroup()}'"; } - protected virtual string FormatHeader() - { - // Note:Dangerous recursive call! - return Decompile(); - } - protected string DecompileProperties() { if (Properties == null || Properties.Count == 0) diff --git a/src/Core/Classes/UStructDecompiler.cs b/src/Core/Classes/UStructDecompiler.cs index 13b9932..1310d95 100644 --- a/src/Core/Classes/UStructDecompiler.cs +++ b/src/Core/Classes/UStructDecompiler.cs @@ -49,7 +49,7 @@ public override string Decompile() return content + UnrealConfig.PrintEndBracket() + ";"; } - protected override string FormatHeader() + protected virtual string FormatHeader() { var output = $"struct {FormatFlags()}{Name}{(Super != null ? $" {FormatExtends()} {Super.Name}" : string.Empty)}"; string metaData = DecompileMeta(); diff --git a/src/Core/Classes/UTextBufferDecompiler.cs b/src/Core/Classes/UTextBufferDecompiler.cs index 8e7244f..8f05242 100644 --- a/src/Core/Classes/UTextBufferDecompiler.cs +++ b/src/Core/Classes/UTextBufferDecompiler.cs @@ -38,10 +38,5 @@ public override string Decompile() return output; } - - protected override string FormatHeader() - { - return "// Postprocessed copy of the source code."; - } } } \ No newline at end of file