From 5c8dee7b03caa896b2794fc3ca030fd7651b4ab1 Mon Sep 17 00:00:00 2001 From: Crsky Date: Thu, 2 Apr 2026 05:58:19 +0800 Subject: [PATCH] refactor: Rename & Format --- ArcFormats/Nexas/ArcPAC.cs | 58 +++++++++++++++++++------------------- 1 file changed, 29 insertions(+), 29 deletions(-) diff --git a/ArcFormats/Nexas/ArcPAC.cs b/ArcFormats/Nexas/ArcPAC.cs index dafe3d40..ea2da638 100644 --- a/ArcFormats/Nexas/ArcPAC.cs +++ b/ArcFormats/Nexas/ArcPAC.cs @@ -81,7 +81,7 @@ namespace GameRes.Formats.NeXAS Settings = new[] { PacEncoding }; } - EncodingSetting PacEncoding = new EncodingSetting ("NexasEncodingCP", "DefaultEncoding"); + readonly EncodingSetting PacEncoding = new EncodingSetting ("NexasEncodingCP", "DefaultEncoding"); public override ArcFile TryOpen (ArcView file) { @@ -89,17 +89,17 @@ namespace GameRes.Formats.NeXAS return null; List dir = null; - INexasIndexReader reader = new IndexReader (file, PacEncoding.Get()); + INexasIndexReader reader = new IndexReaderV1 (file, PacEncoding.Get ()); try { - dir = reader.Read(); + dir = reader.Read (); } catch {} if (null == dir) { - reader = new OldIndexReader (file); - dir = reader.Read(); + reader = new IndexReaderV0 (file); + dir = reader.Read (); if (null == dir) return null; @@ -110,18 +110,18 @@ namespace GameRes.Formats.NeXAS return new PacArchive (file, this, dir, reader.PackType); } - internal sealed class IndexReader : INexasIndexReader + internal sealed class IndexReaderV1 : INexasIndexReader { - ArcView m_file; - int m_count; - int m_pack_type; - Encoding m_encoding; + readonly ArcView m_file; + readonly int m_count; + readonly int m_pack_type; + readonly Encoding m_encoding; const int MaxNameLength = 0x40; public Compression PackType { get { return (Compression)m_pack_type; } } - public IndexReader (ArcView file, Encoding enc) + public IndexReaderV1 (ArcView file, Encoding enc) { m_file = file; m_count = file.View.ReadInt32 (4); @@ -139,10 +139,10 @@ namespace GameRes.Formats.NeXAS bool success = false; try { - success = ReadV0(); + success = ReadV0 (); } catch { /* ignore parse errors */ } - if (!success && !ReadV1()) + if (!success && !ReadV1 ()) return null; return m_dir; } @@ -165,7 +165,7 @@ namespace GameRes.Formats.NeXAS bool ReadV0 () { - using (var input = m_file.CreateStream()) + using (var input = m_file.CreateStream ()) { input.Position = 0xC; if (ReadFromStream (input, 0x20)) @@ -177,16 +177,16 @@ namespace GameRes.Formats.NeXAS bool ReadFromStream (IBinaryStream index, int name_length) { - m_dir.Clear(); + m_dir.Clear (); for (int i = 0; i < m_count; ++i) { var name = index.ReadCString (name_length, m_encoding); if (string.IsNullOrWhiteSpace (name)) return false; var entry = FormatCatalog.Instance.Create (name); - entry.Offset = index.ReadUInt32(); - entry.UnpackedSize = index.ReadUInt32(); - entry.Size = index.ReadUInt32(); + entry.Offset = index.ReadUInt32 (); + entry.UnpackedSize = index.ReadUInt32 (); + entry.Size = index.ReadUInt32 (); if (!entry.CheckPlacement (m_file.MaxOffset)) return false; switch (m_pack_type) @@ -212,14 +212,14 @@ namespace GameRes.Formats.NeXAS } } - internal sealed class OldIndexReader : INexasIndexReader + internal sealed class IndexReaderV0 : INexasIndexReader { - ArcView m_file; - uint m_header_size; + readonly ArcView m_file; + readonly uint m_header_size; public Compression PackType { get { return Compression.NeedDecryptionOnly; } } - public OldIndexReader (ArcView file) + public IndexReaderV0 (ArcView file) { m_file = file; m_header_size = file.View.ReadUInt32 (3); @@ -230,25 +230,25 @@ namespace GameRes.Formats.NeXAS public List Read () { m_dir = new List (); - using (var input = m_file.CreateStream()) + using (var input = m_file.CreateStream ()) { input.Position = 7; while (input.Position < m_header_size) { byte c; - List name_buffer = new List(); + List name_buffer = new List (); while (true) { - c = (byte)input.ReadByte(); + c = (byte)input.ReadByte (); if (c == 0) break; name_buffer.Add ((byte)~c); } - var name = Binary.GetCString (name_buffer.ToArray(), 0); + var name = Binary.GetCString (name_buffer.ToArray (), 0); if (string.IsNullOrWhiteSpace (name)) return null; var entry = FormatCatalog.Instance.Create (name); - entry.Offset = input.ReadUInt32() + m_header_size; - entry.Size = input.ReadUInt32(); + entry.Offset = input.ReadUInt32 () + m_header_size; + entry.Size = input.ReadUInt32 (); if (!entry.CheckPlacement (m_file.MaxOffset)) return null; m_dir.Add (entry); @@ -314,7 +314,7 @@ namespace GameRes.Formats.NeXAS { var dst = new byte[unpacked_size]; var decoder = new HuffmanDecoder (packed, dst); - return decoder.Unpack(); + return decoder.Unpack (); } static private byte[] ZstdDecompress (Stream s, uint unpackedSize)