From 5e6b949ddca12992b6268b33f110eb59a982a5f9 Mon Sep 17 00:00:00 2001 From: iAmAsval Date: Sat, 31 Oct 2020 13:32:36 +0100 Subject: [PATCH] added EnumType --- FModel/Creator/Utils.cs | 3 +-- FModel/PakReader/IO/FIoStoreEntry.cs | 2 +- FModel/PakReader/IO/PropertyInfo.cs | 5 ++++- FModel/PakReader/Parsers/Class/UObject.cs | 1 + FModel/PakReader/Parsers/Objects/FPropertyTag.cs | 3 +++ FModel/PakReader/Parsers/PropertyTagData/EnumProperty.cs | 6 +++--- 6 files changed, 13 insertions(+), 7 deletions(-) diff --git a/FModel/Creator/Utils.cs b/FModel/Creator/Utils.cs index 5d24faeb..71a90b01 100644 --- a/FModel/Creator/Utils.cs +++ b/FModel/Creator/Utils.cs @@ -17,8 +17,7 @@ namespace FModel.Creator { if (ioStore.Chunks.TryGetValue(id.Id, out string path)) { - if (ioStore.Files.TryGetValue(ioStore.MountPoint + path.Substring(0, path.LastIndexOf(".")), out FIoStoreEntry value)) - return ioStore.MountPoint + value.Name; + return ioStore.MountPoint + path; } } diff --git a/FModel/PakReader/IO/FIoStoreEntry.cs b/FModel/PakReader/IO/FIoStoreEntry.cs index bd911bba..7eadb5a9 100644 --- a/FModel/PakReader/IO/FIoStoreEntry.cs +++ b/FModel/PakReader/IO/FIoStoreEntry.cs @@ -19,7 +19,7 @@ namespace FModel.PakReader.IO public FIoOffsetAndLength OffsetLength => ioStore.Toc[ChunkId]; public override long Offset => (long) OffsetLength.Offset; public long Length => (long) OffsetLength.Length; - public string CompressionMethodString => ioStore.TocResource.CompressionMethods[CompressionMethodIndex > 0 ? CompressionMethodIndex - 1 : CompressionMethodIndex]; + public string CompressionMethodString => CompressionMethodIndex > 0 ? ("COMPRESS_" + ioStore.TocResource.CompressionMethods[CompressionMethodIndex - 1]) : "COMPRESS_None"; public FIoStoreEntry(FFileIoStoreReader ioStore, uint userData, string name, bool caseSensitive) { diff --git a/FModel/PakReader/IO/PropertyInfo.cs b/FModel/PakReader/IO/PropertyInfo.cs index 3e2b43bd..416093b0 100644 --- a/FModel/PakReader/IO/PropertyInfo.cs +++ b/FModel/PakReader/IO/PropertyInfo.cs @@ -13,17 +13,20 @@ namespace FModel.PakReader.IO [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] public string EnumName; [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public string EnumType; + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] public string InnerType; [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] public string ValueType; - public PropertyInfo(string name, string type, string structType = null, bool? b = null, string enumName = null, string innerType = null, string valueType = null) + public PropertyInfo(string name, string type, string structType = null, bool? b = null, string enumName = null, string enumType = null, string innerType = null, string valueType = null) { Name = name; Type = type; StructType = structType; Bool = b; EnumName = enumName; + EnumType = enumType; InnerType = innerType; ValueType = valueType; } diff --git a/FModel/PakReader/Parsers/Class/UObject.cs b/FModel/PakReader/Parsers/Class/UObject.cs index 03dd3928..62dffd68 100644 --- a/FModel/PakReader/Parsers/Class/UObject.cs +++ b/FModel/PakReader/Parsers/Class/UObject.cs @@ -65,6 +65,7 @@ namespace FModel.PakReader.Parsers.Class } else { + Dict[val.ToString()] = null; if (!isNonZero) { // We are lucky: We don't know this property but it also has no content diff --git a/FModel/PakReader/Parsers/Objects/FPropertyTag.cs b/FModel/PakReader/Parsers/Objects/FPropertyTag.cs index 15f8ccd7..0904b980 100644 --- a/FModel/PakReader/Parsers/Objects/FPropertyTag.cs +++ b/FModel/PakReader/Parsers/Objects/FPropertyTag.cs @@ -8,6 +8,7 @@ namespace FModel.PakReader.Parsers.Objects public readonly long Position; public readonly byte BoolVal; public readonly FName EnumName; + public readonly FName EnumType; public readonly byte HasPropertyGuid; public readonly FName InnerType; public readonly FName Name; @@ -27,6 +28,7 @@ namespace FModel.PakReader.Parsers.Objects StructName = new FName(info.StructType); BoolVal = (byte) ((info.Bool ?? false) ? 1 : 0); EnumName = new FName(info.EnumName); + EnumType = new FName(info.EnumType); InnerType = new FName(info.InnerType); ValueType = new FName(info.ValueType); ArrayIndex = 0; @@ -43,6 +45,7 @@ namespace FModel.PakReader.Parsers.Objects Position = 0; // default BoolVal = 0; EnumName = default; + EnumType = default; HasPropertyGuid = 0; InnerType = default; Name = default; diff --git a/FModel/PakReader/Parsers/PropertyTagData/EnumProperty.cs b/FModel/PakReader/Parsers/PropertyTagData/EnumProperty.cs index fc01386b..66eba63c 100644 --- a/FModel/PakReader/Parsers/PropertyTagData/EnumProperty.cs +++ b/FModel/PakReader/Parsers/PropertyTagData/EnumProperty.cs @@ -14,7 +14,7 @@ namespace FModel.PakReader.Parsers.PropertyTagData if (reader is IoPackageReader) { - var byteValue = reader.ReadByte(); + object byteValue = tag.EnumType.String == "IntProperty" ? reader.ReadInt32() : reader.ReadByte(); Value = new FName(ByteToEnum(tag.EnumName.String, byteValue)); } else @@ -23,7 +23,7 @@ namespace FModel.PakReader.Parsers.PropertyTagData } } - private static string ByteToEnum(string enumName, byte value) + private static string ByteToEnum(string enumName, object value) { string result; @@ -32,7 +32,7 @@ namespace FModel.PakReader.Parsers.PropertyTagData if (Globals.EnumMappings.TryGetValue(enumName, out var values)) { - result = values.TryGetValue(value, out var member) ? string.Concat(enumName, "::", member) : string.Concat(enumName, "::", value); + result = values.TryGetValue((int)value, out var member) ? string.Concat(enumName, "::", member) : string.Concat(enumName, "::", value); } else {