Skip to content

Commit ee84a5a

Browse files
committed
Merge pull request #107482 from nikitalita/fix-pck-misalign
PCKPacker: Fix first file being written mis-aligned
2 parents 60ba4ba + 6e823b4 commit ee84a5a

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

core/io/pck_packer.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,12 @@ Error PCKPacker::pck_start(const String &p_pck_path, int p_alignment, const Stri
111111
file->store_32(0); // Reserved.
112112
}
113113

114+
// Align for first file.
115+
int pad = _get_pad(alignment, file->get_position());
116+
for (int i = 0; i < pad; i++) {
117+
file->store_8(0);
118+
}
119+
114120
file_base = file->get_position();
115121
file->seek(file_base_ofs);
116122
file->store_64(file_base); // Update files base.

editor/export/editor_export_platform.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1966,6 +1966,12 @@ Error EditorExportPlatform::save_pack(const Ref<EditorExportPreset> &p_preset, b
19661966
f->store_32(0); // Reserved.
19671967
}
19681968

1969+
// Align for first file.
1970+
int file_padding = _get_pad(PCK_PADDING, f->get_position());
1971+
for (int i = 0; i < file_padding; i++) {
1972+
f->store_8(0);
1973+
}
1974+
19691975
uint64_t file_base = f->get_position();
19701976
f->seek(file_base_ofs);
19711977
f->store_64(file_base - pck_start_pos); // Update files base.

0 commit comments

Comments
 (0)