Skip to content

Commit 51a7fbd

Browse files
committed
Add WAD support to object_base
This allows WAD projects to use the auto-extraction feature: decomp-toolkit will extract all `object`s from a disc file or WAD file that exists in the configured `object_base`.
1 parent a6c7001 commit 51a7fbd

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

src/cmd/dol.rs

+12-6
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ use crate::{
5959
split::{is_linker_generated_object, split_obj, update_splits},
6060
IntoCow, ToCow,
6161
},
62-
vfs::{open_file, open_file_with_fs, open_fs, ArchiveKind, Vfs, VfsFile},
62+
vfs::{detect, open_file, open_file_with_fs, open_fs, ArchiveKind, FileFormat, Vfs, VfsFile},
6363
};
6464

6565
#[derive(FromArgs, PartialEq, Debug)]
@@ -2180,12 +2180,18 @@ pub fn find_object_base(config: &ProjectConfig) -> Result<ObjectBase> {
21802180
};
21812181
if is_file {
21822182
let mut file = open_file(&path, false)?;
2183-
let format = nodtool::nod::Disc::detect(file.as_mut())
2183+
let format = detect(file.as_mut())
21842184
.with_context(|| format!("Detecting file type for {}", path))?;
2185-
if let Some(format) = format {
2186-
file.rewind()?;
2187-
let fs = open_fs(file, ArchiveKind::Disc(format))?;
2188-
return Ok(ObjectBase::Vfs(path, fs));
2185+
match format {
2186+
FileFormat::Archive(ArchiveKind::Disc(format)) => {
2187+
let fs = open_fs(file, ArchiveKind::Disc(format))?;
2188+
return Ok(ObjectBase::Vfs(path, fs));
2189+
}
2190+
FileFormat::Archive(ArchiveKind::Wad) => {
2191+
let fs = open_fs(file, ArchiveKind::Wad)?;
2192+
return Ok(ObjectBase::Vfs(path, fs));
2193+
}
2194+
_ => {}
21892195
}
21902196
}
21912197
}

0 commit comments

Comments
 (0)