diff --git a/base/extract_rom.py b/base/extract_rom.py index d490f390..03c2547b 100644 --- a/base/extract_rom.py +++ b/base/extract_rom.py @@ -41,7 +41,10 @@ def _extract_data_recursive(folder: fnt.Folder, output_dir: Path) -> None: for child_file in folder.files: out_file = output_dir / child_file out_file.parent.mkdir(exist_ok=True, parents=True) - out_file.write_bytes(rom.files[folder.idOf(child_file)]) + file_id = folder.idOf(child_file) + if file_id is None: + raise Exception(f'ID of file {child_file} not found') + out_file.write_bytes(rom.files[file_id]) for child_folder_name, child_folder in folder.folders: _extract_data_recursive(child_folder, output_dir / child_folder_name) diff --git a/base/rebuild_rom.py b/base/rebuild_rom.py index f1bf5bb1..bee26a6f 100644 --- a/base/rebuild_rom.py +++ b/base/rebuild_rom.py @@ -74,7 +74,7 @@ def reinsert_overlays(rom: NintendoDSRom, overlay_directory: Path) -> None: # we'll handle adding the new overlay after this loop continue - ot[overlay_number].data = overlay_file.read_bytes() + ot[overlay_number].data = bytearray(overlay_file.read_bytes()) rom.files[ot[overlay_number].fileID] = ot[overlay_number].save(compress=False) print(f'Rebuilt overlay_{str(overlay_number).rjust(4, "0")}.bin') @@ -100,7 +100,7 @@ def reinsert_overlays(rom: NintendoDSRom, overlay_directory: Path) -> None: flags=0, ) ot[new_overlay_number] = new_overlay - rom.files.append(None) + rom.files.append(None) # type: ignore rom.files[new_overlay_file_id] = new_overlay.save(compress=False) print( f'Added new overlay_{str(new_overlay_number).rjust(4, "0")}.bin ' diff --git a/base/requirements.txt b/base/requirements.txt index 2cd7b527..e92305a1 100644 --- a/base/requirements.txt +++ b/base/requirements.txt @@ -1,4 +1,4 @@ click==8.1.3 -ndspy==4.1.0 +ndspy @ git+https://github.com/mike8699/ndspy.git@9d80480e8a3d65a389aac6f5d10978bd9113c977 Pillow==10.3.0 -zed @ git+https://github.com/phst-randomizer/zed.git@5ee969236bf3c3d0707da963e5edc818ddf246d3 +zed @ git+https://github.com/phst-randomizer/zed.git@e59a9653ea1344cbc147bab446821813200b9d19 diff --git a/pyproject.toml b/pyproject.toml index 1ef8cddf..51cff998 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -7,12 +7,12 @@ dependencies = [ "PySide6==6.6.1", "click==8.1.3", "inflection==0.5.1", - "ndspy==4.1.0", + "ndspy@git+https://github.com/mike8699/ndspy.git@9d80480e8a3d65a389aac6f5d10978bd9113c977", "ordered-set==4.1.0", "pydantic==2.4.2", "pyparsing==3.1.1", "vidua==0.4.5", - "zed@git+https://github.com/phst-randomizer/zed.git@5ee969236bf3c3d0707da963e5edc818ddf246d3", + "zed@git+https://github.com/phst-randomizer/zed.git@e59a9653ea1344cbc147bab446821813200b9d19", ] [project.optional-dependencies] diff --git a/scripts/dump_zmb.py b/scripts/dump_zmb.py index 35cc2654..e56a9bfa 100644 --- a/scripts/dump_zmb.py +++ b/scripts/dump_zmb.py @@ -20,7 +20,10 @@ output_dir = Path.cwd() / 'zmbs' output_dir.mkdir(exist_ok=True) - for folder in tqdm(rom.filenames.subfolder('Map').folders): + map_subfolder = rom.filenames.subfolder('Map') + assert map_subfolder is not None + + for folder in tqdm(map_subfolder.folders): folder_name = folder[0] file_path = f'Map/{folder_name}' for subfolder in folder: