Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add compatible for open xbox sav file #164

Merged
merged 1 commit into from
Mar 16, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 9 additions & 2 deletions palworld_save_tools/palsav.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,14 @@ def decompress_sav_to_gvas(data: bytes) -> tuple[bytes, int]:
compressed_len = int.from_bytes(data[4:8], byteorder="little")
magic_bytes = data[8:11]
save_type = data[11]
data_start_offset = 12
# Check for magic bytes
if magic_bytes == b"CNK":
uncompressed_len = int.from_bytes(data[12:16], byteorder="little")
compressed_len = int.from_bytes(data[16:20], byteorder="little")
magic_bytes = data[20:23]
save_type = data[23]
data_start_offset = 24
if magic_bytes != MAGIC_BYTES:
if (
magic_bytes == b"\x00\x00\x00"
Expand All @@ -29,10 +36,10 @@ def decompress_sav_to_gvas(data: bytes) -> tuple[bytes, int]:
raise Exception(f"unhandled compression type: {save_type}")
if save_type == 0x31:
# Check if the compressed length is correct
if compressed_len != len(data) - 12:
if compressed_len != len(data) - data_start_offset:
raise Exception(f"incorrect compressed length: {compressed_len}")
# Decompress file
uncompressed_data = zlib.decompress(data[12:])
uncompressed_data = zlib.decompress(data[data_start_offset:])
if save_type == 0x32:
# Check if the compressed length is correct
if compressed_len != len(uncompressed_data):
Expand Down