diff --git a/core/io/file_access_pack.h b/core/io/file_access_pack.h index a54d395170..490778f203 100644 --- a/core/io/file_access_pack.h +++ b/core/io/file_access_pack.h @@ -32,6 +32,7 @@ #include "core/io/dir_access.h" #include "core/io/file_access.h" +#include "core/io/resource_uid.h" #include "core/string/print_string.h" #include "core/templates/hash_set.h" #include "core/templates/list.h" @@ -119,6 +120,15 @@ private: void _free_packed_dirs(PackedDir *p_dir); void _get_file_paths(PackedDir *p_dir, const String &p_parent_dir, HashSet &r_paths) const; + _FORCE_INLINE_ PathMD5 _get_simplified_path(const String &p_path) { + String simplified_path = p_path; + if (simplified_path.begins_with("uid://")) { + simplified_path = ResourceUID::uid_to_path(simplified_path); + } + simplified_path = simplified_path.simplify_path().trim_prefix("res://"); + return PathMD5(simplified_path.md5_buffer()); + } + public: void add_pack_source(PackSource *p_source); void add_path(const String &p_pkg_path, const String &p_path, uint64_t p_ofs, uint64_t p_size, const uint8_t *p_md5, PackSource *p_src, bool p_replace_files, bool p_encrypted = false, bool p_bundle = false, bool p_delta = false, const String &p_salt = String()); // for PackSource @@ -222,9 +232,7 @@ public: }; int64_t PackedData::get_size(const String &p_path) { - String simplified_path = p_path.simplify_path(); - PathMD5 pmd5(simplified_path.md5_buffer()); - HashMap::Iterator E = files.find(pmd5); + HashMap::Iterator E = files.find(_get_simplified_path(p_path)); if (!E) { return -1; // File not found. } @@ -235,9 +243,7 @@ int64_t PackedData::get_size(const String &p_path) { } Ref PackedData::try_open_path(const String &p_path, const Vector &p_decryption_key) { - String simplified_path = p_path.simplify_path().trim_prefix("res://"); - PathMD5 pmd5(simplified_path.md5_buffer()); - HashMap::Iterator E = files.find(pmd5); + HashMap::Iterator E = files.find(_get_simplified_path(p_path)); if (!E) { return nullptr; // Not found. } @@ -246,7 +252,7 @@ Ref PackedData::try_open_path(const String &p_path, const Vector