Skip to content

Commit

Permalink
Adjust pkg alignment for SR
Browse files Browse the repository at this point in the history
  • Loading branch information
dyceron committed Nov 24, 2023
1 parent 0e58da4 commit ada594b
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/mercury_engine_data_structures/formats/pkg.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ def __init__(self, target_game: Game):
self.int_size = typing.cast(construct.FormatField, Int32ul)
self._file_entry = _file_entry(target_game)
self.file_headers_type = PrefixedArray(self.int_size, self._file_entry).compile()
self.game = target_game

def _parse(self, stream, context, path) -> construct.Container:
# Skip over header size and data section size
Expand Down Expand Up @@ -114,8 +115,11 @@ def _build(self, obj: construct.Container, stream, context, path):
start_offset=start_offset,
end_offset=end_offset,
))
# Align to 8 bytes
pad = -(end_offset - start_offset) % 8
# Samus Returns aligns to 128 bytes, Dread aligns to 8 bytes
if self.game == Game.SAMUS_RETURNS:
pad = -(end_offset - start_offset) % 128

Check warning on line 120 in src/mercury_engine_data_structures/formats/pkg.py

View check run for this annotation

Codecov / codecov/patch

src/mercury_engine_data_structures/formats/pkg.py#L120

Added line #L120 was not covered by tests
else:
pad = -(end_offset - start_offset) % 8
construct.stream_write(stream, b"\x00" * pad, pad, path)

files_end = construct.stream_tell(stream, path)
Expand Down

0 comments on commit ada594b

Please sign in to comment.