From cae15affee653e038a9dce7c7e34ded4ad00d570 Mon Sep 17 00:00:00 2001 From: Gabriel Date: Mon, 15 Sep 2025 09:56:40 +0200 Subject: [PATCH] [Baldur's Gate 3]: Various bug fixes (#193) * Add additional DLLs to the lslib retriever * Fix regex pattern for folder name in pak_parser * Ensure log directory is created if missing * Update pak file naming to include parent directory name --- games/baldursgate3/lslib_retriever.py | 3 +++ games/baldursgate3/pak_parser.py | 8 ++++++-- games/game_baldursgate3.py | 1 + 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/games/baldursgate3/lslib_retriever.py b/games/baldursgate3/lslib_retriever.py index 9a7b7af..5a031f0 100644 --- a/games/baldursgate3/lslib_retriever.py +++ b/games/baldursgate3/lslib_retriever.py @@ -25,9 +25,12 @@ class LSLibRetriever: "Divine.dll.config", "Divine.exe", "Divine.runtimeconfig.json", + "K4os.Compression.LZ4.dll", + "K4os.Compression.LZ4.Streams.dll", "LSLib.dll", "LSLibNative.dll", "LZ4.dll", + "Newtonsoft.Json.dll", "System.IO.Hashing.dll", "ZstdSharp.dll", } diff --git a/games/baldursgate3/pak_parser.py b/games/baldursgate3/pak_parser.py index e3757e4..7797df5 100644 --- a/games/baldursgate3/pak_parser.py +++ b/games/baldursgate3/pak_parser.py @@ -154,7 +154,11 @@ class BG3PakParser: f"pak with same name as packable dir exists in mod directory. not packing dir {file}" ) return "" - pak_path = self._utils.overwrite_path / f"Mods/{file.name}.pak" + parent_mod_name = file.parent.name.replace(" ", "_") + pak_path = ( + self._utils.overwrite_path + / f"Mods/{parent_mod_name}_{file.name}.pak" + ) build_pak = True if pak_path.exists(): pak_creation_time = os.path.getmtime(pak_path) @@ -249,7 +253,7 @@ class BG3PakParser: # 2. it has files in Mods// other than the meta.lsx file, or # 3. it has files in Public/ result = self.run_divine( - f'list-package --use-regex -x "(/{folder_name}/(?!meta\\.lsx))|(Public/Engine/Timeline/MaterialGroups)"', + f'list-package --use-regex -x "(/{re.escape(folder_name)}/(?!meta\\.lsx))|(Public/Engine/Timeline/MaterialGroups)"', file, ) self._mod_cache[file] = ( diff --git a/games/game_baldursgate3.py b/games/game_baldursgate3.py index 03bd8a0..fcc4497 100644 --- a/games/game_baldursgate3.py +++ b/games/game_baldursgate3.py @@ -179,6 +179,7 @@ class BG3Game(BasicGame, bg3_file_mapper.BG3FileMapper): def _on_finished_run(self, exec_path: str, exit_code: int): if "bin/bg3" not in exec_path: return + self.utils.log_dir.mkdir(parents=True, exist_ok=True) if self.utils.log_diff: for x in difflib.unified_diff( open(self.utils.modsettings_backup).readlines(),