From 30a3bf59d1127673c984d434564bd65c2d8f5c4c Mon Sep 17 00:00:00 2001 From: Mc-muffin <8714476+Mc-muffin@users.noreply.github.com> Date: Mon, 22 May 2023 20:48:10 -0500 Subject: [PATCH] fix SCPK and skit packing typos --- pythonlib/formats/scpk.py | 10 ++++++---- pythonlib/games/ToolsTOR.py | 4 ++-- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/pythonlib/formats/scpk.py b/pythonlib/formats/scpk.py index c0a6fe7..cbfe675 100644 --- a/pythonlib/formats/scpk.py +++ b/pythonlib/formats/scpk.py @@ -22,19 +22,21 @@ class Scpk(): self._rsce_pos = 0 - def from_path(self, path="") -> typing.Self: + @staticmethod + def from_path(path="") -> 'Scpk': with FileIO(path) as f: if f.read(4) != MAGIC: raise ValueError("Not an SCPK file!") - + + self = Scpk() self.unk1 = f.read_uint16() self.unk2 = f.read_uint16() - self.file_amount = f.read_uint32() + file_amount = f.read_uint32() assert f.read_uint32() == 0, "scpk padding is not zero!" # padding? self.files = [] sizes = [] - for _ in range(self.file_amount): + for _ in range(file_amount): sizes.append(f.read_uint32()) for i, size in enumerate(sizes): diff --git a/pythonlib/games/ToolsTOR.py b/pythonlib/games/ToolsTOR.py index 5b8cfff..b2a7572 100644 --- a/pythonlib/games/ToolsTOR.py +++ b/pythonlib/games/ToolsTOR.py @@ -654,7 +654,7 @@ class ToolsTOR(ToolsTales): # TODO: use pathlib for everything out_path = Path(self.skit_XML_patch) / "New" xml_path = Path(self.skit_XML_patch) / "XML" - pak2_path = Path(self.dat_archive_extract) / "SCPK" + pak2_path = Path(self.dat_archive_extract) / "PAK2" for file in tqdm(list(pak2_path.glob("*.pak2"))): with open(file, "rb") as f: @@ -841,7 +841,7 @@ class ToolsTOR(ToolsTales): scpk_path = Path(self.dat_archive_extract) / "SCPK" for file in tqdm(list(scpk_path.glob("*.scpk"))): - curr_scpk = Scpk().from_path(file) + curr_scpk = Scpk.from_path(file) old_rsce = Theirsce(curr_scpk.rsce) new_rsce = self.get_new_theirsce(old_rsce, xml_path / file.with_suffix(".xml").name) new_rsce.seek(0)