Skip to content

Commit 4302a0f

Browse files
committed
Fix Starfield support
The container format changed a bit. Fixes Z1ni#110
1 parent efdb670 commit 4302a0f

File tree

1 file changed

+17
-5
lines changed

1 file changed

+17
-5
lines changed

main.py

+17-5
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,9 @@ def get_save_paths(
323323
# It seems that the "BETHESDAPFH" file is a header which is padded to the next 16 byte boundary with the string "padding\0", where \0 is NUL.
324324
# The other files ("PnP", where n is a number starting from 0) are then concatenated into the SFS file, also with padding.
325325

326+
# As of at least Starfield version 1.9.51.0, the containers contain "toc" and one or more "BlobDataN" files (where N is a number starting from 0).
327+
# The new format seems to already include the padding.
328+
326329
temp_folder = Path(temp_dir.name) / "Starfield"
327330
temp_folder.mkdir()
328331

@@ -335,14 +338,23 @@ def get_save_paths(
335338
continue
336339
# Strip out the parent folder name
337340
sfs_name = path.name
338-
# Arrange the files: header as index 0, P0P as 1, P1P as 2, etc.
341+
# Arrange the files: header as index 0, P0P as 1, P1P as 2, etc. (or BlobData0, ... for the new format)
339342
parts = {}
343+
344+
is_new_format = "toc" in [f["name"] for f in container["files"]]
345+
340346
for file in container["files"]:
341-
if file["name"] == "BETHESDAPFH":
342-
parts[0] = file["path"]
347+
if file["name"] == "toc":
348+
continue
349+
if is_new_format:
350+
idx = int(file["name"].removeprefix("BlobData"))
343351
else:
344-
idx = int(file["name"].strip("P")) + 1
345-
parts[idx] = file["path"]
352+
if file["name"] == "BETHESDAPFH":
353+
idx = 0
354+
else:
355+
idx = int(file["name"].strip("P")) + 1
356+
parts[idx] = file["path"]
357+
346358
# Construct the SFS file
347359
sfs_path = temp_folder / sfs_name
348360
with sfs_path.open("wb") as sfs_f:

0 commit comments

Comments
 (0)