From 25f06a1c98c446e3ae4e6f0ab5bb989f77d29c83 Mon Sep 17 00:00:00 2001 From: scientificworld Date: Wed, 7 Jan 2026 12:02:14 +0800 Subject: [PATCH] chore: code enhancement --- ArcFormats/Nexas/ArcPAC.cs | 15 +++++++++++---- Legacy/Duke/ArcDAT.cs | 5 ++++- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/ArcFormats/Nexas/ArcPAC.cs b/ArcFormats/Nexas/ArcPAC.cs index c62c6977..2aa5fded 100644 --- a/ArcFormats/Nexas/ArcPAC.cs +++ b/ArcFormats/Nexas/ArcPAC.cs @@ -45,7 +45,14 @@ namespace GameRes.Formats.NeXAS None2, Zstd, ZstdOrNone, - NeedDecryptionOnly = 0xFDFD, // magic number, no actual meaning + NeedDecryptionOnly = 0xFDFD, // internal magic number + } + + internal interface INexasIndexReader + { + Compression PackType { get; } + + List Read (); } public class PacArchive : ArcFile @@ -82,7 +89,7 @@ namespace GameRes.Formats.NeXAS return null; List dir = null; - dynamic reader = new IndexReader (file, PacEncoding.Get()); + INexasIndexReader reader = new IndexReader (file, PacEncoding.Get()); try { dir = reader.Read(); @@ -103,7 +110,7 @@ namespace GameRes.Formats.NeXAS return new PacArchive (file, this, dir, reader.PackType); } - internal sealed class IndexReader + internal sealed class IndexReader : INexasIndexReader { ArcView m_file; int m_count; @@ -205,7 +212,7 @@ namespace GameRes.Formats.NeXAS } } - internal sealed class OldIndexReader + internal sealed class OldIndexReader : INexasIndexReader { ArcView m_file; uint m_header_size; diff --git a/Legacy/Duke/ArcDAT.cs b/Legacy/Duke/ArcDAT.cs index 2a5d70d3..ffb6f9ee 100644 --- a/Legacy/Duke/ArcDAT.cs +++ b/Legacy/Duke/ArcDAT.cs @@ -42,8 +42,11 @@ namespace GameRes.Formats.Duke public override ArcFile TryOpen (ArcView file) { + if (!file.Name.HasExtension (".dat")) + return null; + int count = (int)(file.View.ReadUInt32 (0) ^ 0xfa261efb); - if (!file.Name.HasExtension (".dat") || !IsSaneCount (count)) + if (!IsSaneCount (count)) return null; uint index_offset = 4;