summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorbruvzg <7645683+bruvzg@users.noreply.github.com>2024-02-10 21:58:08 +0200
committerbruvzg <7645683+bruvzg@users.noreply.github.com>2024-03-06 14:02:01 +0200
commitbf8ec7b81b33b81e8f2fc61143ace32a29be4130 (patch)
tree4e5eca4cf060d51cbf7cd638b738e2e295d59eed /core
parent72a31722fd9a2893567697dd9dff1b1eaace8980 (diff)
downloadredot-engine-bf8ec7b81b33b81e8f2fc61143ace32a29be4130.tar.gz
[Export] Use relative file base offset for embedded PCK.
Diffstat (limited to 'core')
-rw-r--r--core/io/file_access_pack.cpp7
-rw-r--r--core/io/file_access_pack.h3
2 files changed, 9 insertions, 1 deletions
diff --git a/core/io/file_access_pack.cpp b/core/io/file_access_pack.cpp
index 7595bc41f5..991b94db38 100644
--- a/core/io/file_access_pack.cpp
+++ b/core/io/file_access_pack.cpp
@@ -196,6 +196,8 @@ bool PackedSourcePCK::try_open_pack(const String &p_path, bool p_replace_files,
return false;
}
+ int64_t pck_start_pos = f->get_position() - 4;
+
uint32_t version = f->get_32();
uint32_t ver_major = f->get_32();
uint32_t ver_minor = f->get_32();
@@ -208,6 +210,7 @@ bool PackedSourcePCK::try_open_pack(const String &p_path, bool p_replace_files,
uint64_t file_base = f->get_64();
bool enc_directory = (pack_flags & PACK_DIR_ENCRYPTED);
+ bool rel_filebase = (pack_flags & PACK_REL_FILEBASE);
for (int i = 0; i < 16; i++) {
//reserved
@@ -216,6 +219,10 @@ bool PackedSourcePCK::try_open_pack(const String &p_path, bool p_replace_files,
int file_count = f->get_32();
+ if (rel_filebase) {
+ file_base += pck_start_pos;
+ }
+
if (enc_directory) {
Ref<FileAccessEncrypted> fae;
fae.instantiate();
diff --git a/core/io/file_access_pack.h b/core/io/file_access_pack.h
index c65e65d17d..0deacfebab 100644
--- a/core/io/file_access_pack.h
+++ b/core/io/file_access_pack.h
@@ -44,7 +44,8 @@
#define PACK_FORMAT_VERSION 2
enum PackFlags {
- PACK_DIR_ENCRYPTED = 1 << 0
+ PACK_DIR_ENCRYPTED = 1 << 0,
+ PACK_REL_FILEBASE = 1 << 1,
};
enum PackFileFlags {