diff options
Diffstat (limited to 'core/io/file_access_pack.cpp')
-rw-r--r-- | core/io/file_access_pack.cpp | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/core/io/file_access_pack.cpp b/core/io/file_access_pack.cpp index 74c5c1c191..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(); @@ -327,7 +334,7 @@ uint64_t FileAccessPack::get_buffer(uint8_t *p_dst, uint64_t p_length) const { to_read = (int64_t)pf.size - (int64_t)pos; } - pos += p_length; + pos += to_read; if (to_read <= 0) { return 0; @@ -455,7 +462,7 @@ String DirAccessPack::get_drive(int p_drive) { return ""; } -PackedData::PackedDir *DirAccessPack::_find_dir(String p_dir) { +PackedData::PackedDir *DirAccessPack::_find_dir(const String &p_dir) { String nd = p_dir.replace("\\", "/"); // Special handling since simplify_path() will forbid it @@ -491,7 +498,7 @@ PackedData::PackedDir *DirAccessPack::_find_dir(String p_dir) { } for (int i = 0; i < paths.size(); i++) { - String p = paths[i]; + const String &p = paths[i]; if (p == ".") { continue; } else if (p == "..") { |