Skip to content

Commit b15d407

Browse files
committed
(BND): detect compressed entries.
1 parent 4b60caa commit b15d407

File tree

1 file changed

+20
-4
lines changed

1 file changed

+20
-4
lines changed

Legacy/ShapeShifter/ArcBND.cs

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,12 @@
2727
using System.Collections.Generic;
2828
using System.ComponentModel.Composition;
2929
using System.IO;
30+
using GameRes.Compression;
3031
using GameRes.Utility;
3132

33+
// [000407][Shape Shifter] Tsubasa no Hatameki
34+
// [040326][Glastonbury] Assassin Lesson
35+
3236
namespace GameRes.Formats.ShapeShifter
3337
{
3438
#if DEBUG
@@ -52,8 +56,10 @@ public override ArcFile TryOpen (ArcView file)
5256
if (first_offset != 4 +(uint)count * 12)
5357
return null;
5458

55-
var base_name = Path.GetFileNameWithoutExtension (file.Name);
56-
string default_type = base_name == "SCR" ? "script" : "";
59+
var base_name = Path.GetFileNameWithoutExtension (file.Name).ToUpperInvariant();
60+
string default_type = base_name == "SCR" ? "script" :
61+
base_name == "VOICE" || base_name == "SE" ? "audio" :
62+
base_name == "PICT" ? "image" : "";
5763
uint index_offset = 4;
5864
var dir = new List<Entry> (count);
5965
for (int i = 0; i < count; ++i)
@@ -77,13 +83,23 @@ public override ArcFile TryOpen (ArcView file)
7783
return new ArcFile (file, this, dir);
7884
}
7985

86+
public override Stream OpenEntry (ArcFile arc, Entry entry)
87+
{
88+
var input = arc.File.CreateStream (entry.Offset, entry.Size, entry.Name);
89+
var pent = entry as PackedEntry;
90+
if (null == pent || !pent.IsPacked)
91+
return input;
92+
return new LzssStream (input);
93+
}
94+
8095
void DetectFileTypes (ArcView file, List<Entry> dir)
8196
{
82-
foreach (var entry in dir)
97+
foreach (PackedEntry entry in dir)
8398
{
8499
var offset = entry.Offset;
85100
var signature = file.View.ReadUInt32 (offset);
86-
if (0x4D42 == (signature & 0xFFFF)) // 'BM'
101+
if (entry.IsPacked && (0x4D42 == (signature & 0xFFFF)) || // 'BM'
102+
!entry.IsPacked && (0x4D4207 == (signature & 0xFFFF07)))
87103
{
88104
entry.Type = "image";
89105
entry.Name = Path.ChangeExtension (entry.Name, "bmp");

0 commit comments

Comments
 (0)