Skip to content

Commit 1ff1ee4

Browse files
authored
[bg3] fix lslib extraction for newer versions (#211)
1 parent fda5d6a commit 1ff1ee4

1 file changed

Lines changed: 17 additions & 21 deletions

File tree

games/baldursgate3/lslib_retriever.py

Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,6 @@ def _needed_lslib_files(self):
2525
"Divine.dll.config",
2626
"Divine.exe",
2727
"Divine.runtimeconfig.json",
28-
"K4os.Compression.LZ4.dll",
29-
"K4os.Compression.LZ4.Streams.dll",
30-
"LSLib.dll",
31-
"LSLibNative.dll",
32-
"LZ4.dll",
33-
"Newtonsoft.Json.dll",
34-
"System.IO.Hashing.dll",
35-
"ZstdSharp.dll",
3628
}
3729
}
3830

@@ -129,25 +121,29 @@ def reporthook(block_num: int, block_size: int, total_size: int) -> None:
129121
else:
130122
dialog_message = "Extracting/Updating LSLib files..."
131123
win_title = "Extracting LSLib"
132-
x_progress = self._utils.create_progress_window(
133-
win_title, len(self._needed_lslib_files), msg=dialog_message
134-
)
135124
with zipfile.ZipFile(zip_path, "r") as zip_ref:
136-
for file in self._needed_lslib_files:
137-
if downloaded or not file.exists():
138-
shutil.move(
139-
zip_ref.extract(
140-
f"Packed/Tools/{file.name}", self._utils.tools_dir
141-
),
142-
file,
143-
)
125+
names = list(
126+
filter(
127+
lambda name: name.startswith("Packed/Tools"), zip_ref.namelist()
128+
)
129+
)
130+
qDebug(f"found files: {','.join(names)}")
131+
x_progress = self._utils.create_progress_window(
132+
win_title, len(names), msg=dialog_message
133+
)
134+
for file in names:
135+
shutil.move(
136+
zip_ref.extract(file, self._utils.tools_dir),
137+
self._utils.tools_dir,
138+
)
144139
x_progress.setValue(x_progress.value() + 1)
145140
QApplication.processEvents()
146141
if x_progress.wasCanceled():
142+
x_progress.close()
147143
qWarning("processing canceled by user")
148144
return False
149-
x_progress.close()
150-
shutil.rmtree(self._utils.tools_dir / "Packed", ignore_errors=True)
145+
x_progress.close()
146+
shutil.rmtree(self._utils.tools_dir / "Packed", ignore_errors=True)
151147
except Exception as e:
152148
qDebug(f"Extraction failed: {e}")
153149
err = QMessageBox(self._utils.main_window)

0 commit comments

Comments
 (0)