Fix issues.

This commit is contained in:
Sławomir Śpiewak 2024-08-01 11:46:41 +02:00
parent 738b2950f6
commit 45e7af60ea
2 changed files with 14 additions and 10 deletions

View File

@ -335,9 +335,9 @@ namespace GameRes.Formats.DxLib
{ {
public long BaseOffset; public long BaseOffset;
public long IndexOffset; public long IndexOffset;
public uint IndexSize; public long IndexSize;
public uint FileTable; public long FileTable;
public uint DirTable; public long DirTable;
public int CodePage; public int CodePage;
} }

View File

@ -23,7 +23,6 @@
// IN THE SOFTWARE. // IN THE SOFTWARE.
// //
using GameRes.Formats.PkWare;
using GameRes.Formats.Strings; using GameRes.Formats.Strings;
using NAudio.SoundFont; using NAudio.SoundFont;
using System; using System;
@ -31,12 +30,18 @@ using System.Collections.Generic;
using System.ComponentModel.Composition; using System.ComponentModel.Composition;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Windows.Navigation;
namespace GameRes.Formats.DxLib namespace GameRes.Formats.DxLib
{ {
internal class DXA8PackedEntry : PackedEntry {
public bool HuffmanCompressed { get; set; }
}
[Export(typeof(ArchiveFormat))] [Export(typeof(ArchiveFormat))]
public class Dx8Opener : DxOpener public class Dx8Opener : DxOpener
{ {
@ -60,10 +65,8 @@ namespace GameRes.Formats.DxLib
internal class DxHeaderV8 :DxHeader internal class DxHeaderV8 :DxHeader
{ {
new public long FileTable;
new public long DirTable;
public DXA8Flags Flags; public DXA8Flags Flags;
public byte HuffmanKB; public byte HuffmanKB; // oddly used only in Compression process not in decompression.
//15 bytes of padding. //15 bytes of padding.
} }
@ -150,7 +153,7 @@ namespace GameRes.Formats.DxLib
var readyStr = new MemoryStream(headerBuffer); var readyStr = new MemoryStream(headerBuffer);
ArcView arcView = new ArcView(readyStr, "hdr",(uint)headerBuffer.LongLength); ArcView arcView = new ArcView(readyStr, "hdr",(uint)headerBuffer.LongLength);
List<Entry> entries; List<Entry> entries;
using (var indexStr = arcView.CreateStream(dx.IndexOffset, dx.IndexSize)) using (var indexStr = arcView.CreateStream(0, dx.IndexSize))
using (var reader = IndexReader.Create(dx, 8, indexStr)) using (var reader = IndexReader.Create(dx, 8, indexStr))
{ {
entries = reader.Read(); entries = reader.Read();
@ -213,10 +216,11 @@ namespace GameRes.Formats.DxLib
var size = m_input.ReadInt64(); var size = m_input.ReadInt64();
var packed_size = m_input.ReadInt64(); var packed_size = m_input.ReadInt64();
var huffman_packed_size = m_input.ReadInt64(); var huffman_packed_size = m_input.ReadInt64();
var entry = FormatCatalog.Instance.Create<PackedEntry>(Path.Combine(root, ExtractFileName(name_offset))); var entry = FormatCatalog.Instance.Create<DXA8PackedEntry>(Path.Combine(root, ExtractFileName(name_offset)));
entry.Offset = m_header.BaseOffset + offset; entry.Offset = m_header.BaseOffset + offset;
entry.UnpackedSize = (uint)size; entry.UnpackedSize = (uint)size;
entry.IsPacked = (-1 != packed_size) || -1 != huffman_packed_size; entry.IsPacked = -1 != packed_size;
entry.HuffmanCompressed = -1 != huffman_packed_size;
if (entry.IsPacked) if (entry.IsPacked)
entry.Size = (uint)(huffman_packed_size!=-1 ? huffman_packed_size:packed_size); entry.Size = (uint)(huffman_packed_size!=-1 ? huffman_packed_size:packed_size);
else else