diff --git a/FModel/PakReader/IO/FIoStoreEntry.cs b/FModel/PakReader/IO/FIoStoreEntry.cs index f59dd8c3..bd911bba 100644 --- a/FModel/PakReader/IO/FIoStoreEntry.cs +++ b/FModel/PakReader/IO/FIoStoreEntry.cs @@ -17,9 +17,9 @@ namespace FModel.PakReader.IO public FIoChunkId ChunkId => ioStore.TocResource.ChunkIds[UserData]; public FIoOffsetAndLength OffsetLength => ioStore.Toc[ChunkId]; - public long Offset => (long) OffsetLength.Offset; + public override long Offset => (long) OffsetLength.Offset; public long Length => (long) OffsetLength.Length; - public string CompressionMethodString => ioStore.TocResource.CompressionMethods[CompressionMethodIndex - 1]; + public string CompressionMethodString => ioStore.TocResource.CompressionMethods[CompressionMethodIndex > 0 ? CompressionMethodIndex - 1 : CompressionMethodIndex]; public FIoStoreEntry(FFileIoStoreReader ioStore, uint userData, string name, bool caseSensitive) { diff --git a/FModel/PakReader/Parsers/Objects/FPakEntry.cs b/FModel/PakReader/Parsers/Objects/FPakEntry.cs index 3c839089..d74e95c4 100644 --- a/FModel/PakReader/Parsers/Objects/FPakEntry.cs +++ b/FModel/PakReader/Parsers/Objects/FPakEntry.cs @@ -16,7 +16,8 @@ namespace FModel.PakReader.Parsers.Objects public override string ContainerName { get; } public override string Name => _name; private readonly string _name; - public readonly long Offset; + public override long Offset => _offset; + private readonly long _offset; public override long Size => _size; private readonly long _size; public override long UncompressedSize => _uncompressedSize; @@ -42,7 +43,7 @@ namespace FModel.PakReader.Parsers.Objects var StartOffset = reader.BaseStream.Position; - Offset = reader.ReadInt64(); + _offset = reader.ReadInt64(); _size = reader.ReadInt64(); _uncompressedSize = reader.ReadInt64(); if (Version < EPakVersion.FNAME_BASED_COMPRESSION_METHOD) @@ -105,7 +106,7 @@ namespace FModel.PakReader.Parsers.Objects var StartOffset = reader.BaseStream.Position; - Offset = reader.ReadInt64(); + _offset = reader.ReadInt64(); _size = reader.ReadInt64(); _uncompressedSize = reader.ReadInt64(); _compressionMethodIndex = reader.ReadUInt32(); @@ -125,7 +126,7 @@ namespace FModel.PakReader.Parsers.Objects { ContainerName = pakName; _name = name; - Offset = offset; + _offset = offset; _size = size; _uncompressedSize = uncompressedSize; CompressionBlocks = compressionBlocks; @@ -141,7 +142,7 @@ namespace FModel.PakReader.Parsers.Objects { if (_compressionMethodIndex == 0U) { - stream.Position = Offset + _structSize; + stream.Position = _offset + _structSize; if (Encrypted) { var data = new byte[(_size & 15) == 0 ? _size : (_size / 16 + 1) * 16]; @@ -174,7 +175,7 @@ namespace FModel.PakReader.Parsers.Objects int bytesRead = 0; for (int i = 0; i < CompressionBlocks.Length; i++) { - stream.Position = Offset + CompressionBlocks[i].CompressedStart; + stream.Position = _offset + CompressionBlocks[i].CompressedStart; int uncompressedSize = (int)Math.Min(CompressionBlockSize, outData.Length - bytesRead); byte[] blockBbuffer; diff --git a/FModel/PakReader/ReaderEntry.cs b/FModel/PakReader/ReaderEntry.cs index 1731963b..fb3786df 100644 --- a/FModel/PakReader/ReaderEntry.cs +++ b/FModel/PakReader/ReaderEntry.cs @@ -6,6 +6,7 @@ namespace FModel.PakReader { public abstract string Name { get; } public abstract long UncompressedSize { get; } + public abstract long Offset { get; } public abstract long Size { get; } public abstract int StructSize { get; } public abstract uint CompressionMethodIndex { get; } diff --git a/FModel/ViewModels/TabControl/AssetPropertiesViewModel.cs b/FModel/ViewModels/TabControl/AssetPropertiesViewModel.cs index 164d7502..53cb063d 100644 --- a/FModel/ViewModels/TabControl/AssetPropertiesViewModel.cs +++ b/FModel/ViewModels/TabControl/AssetPropertiesViewModel.cs @@ -16,18 +16,12 @@ namespace FModel.ViewModels.TabControl string ext = string.Join(" ", entry.GetExtension(), entry.Uexp?.GetExtension(), entry.Ubulk?.GetExtension()); string offsets; string tSize; - if (entry is FPakEntry pakEntry) + if (entry is ReaderEntry pakEntry) { offsets = string.Join(" ", "0x" + (pakEntry.Offset + pakEntry.StructSize).ToString("X2"), - entry.Uexp != null ? "0x" + (((FPakEntry)pakEntry.Uexp).Offset + pakEntry.StructSize).ToString("X2") : string.Empty, - entry.Ubulk != null ? "0x" + (((FPakEntry)pakEntry.Ubulk).Offset + pakEntry.StructSize).ToString("X2") : string.Empty); - tSize = Strings.GetReadableSize(pakEntry.Size + ((pakEntry.Uexp as FPakEntry)?.Size ?? 0) + ((pakEntry.Ubulk as FPakEntry)?.Size ?? 0)); - } else if (entry is FIoStoreEntry ioEntry) - { - offsets = string.Join(" ", "0x" + (ioEntry.Offset).ToString("X2"), - entry.Uexp != null ? "0x" + (((FIoStoreEntry)ioEntry.Uexp).Offset).ToString("X2") : string.Empty, - entry.Ubulk != null ? "0x" + (((FIoStoreEntry)ioEntry.Ubulk).Offset).ToString("X2") : string.Empty); - tSize = Strings.GetReadableSize(ioEntry.Size + ((ioEntry.Uexp as FIoStoreEntry)?.Size ?? 0) + ((ioEntry.Ubulk as FIoStoreEntry)?.Size ?? 0)); + entry.Uexp != null ? "0x" + (pakEntry.Uexp?.Offset + pakEntry.StructSize)?.ToString("X2") : string.Empty, + entry.Ubulk != null ? "0x" + (pakEntry.Ubulk?.Offset + pakEntry.StructSize)?.ToString("X2") : string.Empty); + tSize = Strings.GetReadableSize(pakEntry.Size + (pakEntry.Uexp?.Size ?? 0) + (pakEntry.Ubulk?.Size ?? 0)); } else { diff --git a/README.md b/README.md index d01e2ba9..9dc06322 100644 --- a/README.md +++ b/README.md @@ -165,11 +165,14 @@ This software uses the following open source packages: ## Support [![](https://wakatime.com/badge/github/iAmAsval/FModel.svg)](https://wakatime.com/badge/github/iAmAsval/FModel) -This project is not my full time job, donations are greatly appreciated. +This project is not my full time job, donations and stars are greatly appreciated. + + + ## You may also like...