From af6de003207511e4af18b09f7986bbca3f9f82eb Mon Sep 17 00:00:00 2001 From: Mc-muffin <8714476+Mc-muffin@users.noreply.github.com> Date: Fri, 19 May 2023 10:15:42 -0500 Subject: [PATCH] Fix wrong start offsets on DAT.BIN extraction And added cleaning before copy --- pythonlib/games/ToolsTOR.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/pythonlib/games/ToolsTOR.py b/pythonlib/games/ToolsTOR.py index 7921885..6918398 100644 --- a/pythonlib/games/ToolsTOR.py +++ b/pythonlib/games/ToolsTOR.py @@ -709,14 +709,21 @@ class ToolsTOR(ToolsTales): remainder = c & self.LOW_BITS start = c & self.HIGH_BITS end = (n & self.HIGH_BITS) - remainder - file_data[c] = end - start + file_data[start] = end - start return file_data # Extract the file DAT.BIN to the different directorties def extract_main_archive(self) -> None: - print("Extracting DAT bin files...") + print("Cleaning extract folder...") + for path in Path(self.dat_archive_extract).glob("**/*"): + if path.is_file(): + path.unlink() + elif path.is_dir(): + shutil.rmtree(path) + + print("Extracting DAT.BIN files...") with open( self.dat_bin_original, "rb") as f: for i, (offset, size) in enumerate(tqdm(self.get_datbin_file_data().items(), desc="Extracting files", unit="file")):