diff options
Diffstat (limited to 'core/io/file_access_pack.h')
-rw-r--r-- | core/io/file_access_pack.h | 34 |
1 files changed, 31 insertions, 3 deletions
diff --git a/core/io/file_access_pack.h b/core/io/file_access_pack.h index a4c750bf3c..5fcc79aaf4 100644 --- a/core/io/file_access_pack.h +++ b/core/io/file_access_pack.h @@ -60,8 +60,34 @@ private: Set<String> files; }; + struct PathMD5 { + uint64_t a; + uint64_t b; + bool operator < (const PathMD5& p_md5) const { + + if (p_md5.a == a) { + return b < p_md5.b; + } else { + return a < p_md5.a; + } + } + + bool operator == (const PathMD5& p_md5) const { + return a == p_md5.a && b == p_md5.b; + }; + + PathMD5() { + a = b = 0; + }; + + PathMD5(const Vector<uint8_t> p_buf) { + a = *((uint64_t*)&p_buf[0]); + b = *((uint64_t*)&p_buf[8]); + }; + }; + + Map<PathMD5,PackedFile> files; - Map<String,PackedFile> files; Vector<PackSource*> sources; PackedDir *root; @@ -151,7 +177,9 @@ public: FileAccess *PackedData::try_open_path(const String& p_path) { - Map<String,PackedFile>::Element *E=files.find(p_path); + //print_line("try open path " + p_path); + PathMD5 pmd5(p_path.md5_buffer()); + Map<PathMD5,PackedFile>::Element *E=files.find(pmd5); if (!E) return NULL; //not found if (E->get().offset==0) @@ -162,7 +190,7 @@ FileAccess *PackedData::try_open_path(const String& p_path) { bool PackedData::has_path(const String& p_path) { - return files.has(p_path); + return files.has(PathMD5(p_path.md5_buffer())); } |