From 1af77aa69d29aa7d16b9233bf7f7c71bdc150f71 Mon Sep 17 00:00:00 2001 From: kobewi Date: Mon, 20 Oct 2025 23:45:11 +0200 Subject: [PATCH] Improve determinism of UIDs --- core/io/resource_uid.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/core/io/resource_uid.cpp b/core/io/resource_uid.cpp index 58b95f86973..80f04abd61f 100644 --- a/core/io/resource_uid.cpp +++ b/core/io/resource_uid.cpp @@ -134,7 +134,10 @@ ResourceUID::ID ResourceUID::create_id_for_path(const String &p_path) { RandomPCG rng; const String project_name = GLOBAL_GET("application/config/name"); - rng.seed(project_name.hash64() * p_path.hash64() * FileAccess::get_md5(p_path).hash64()); + // Use lowercase file name as random seed. + // This ensures that case differences don't cause UIDs to shift on case-insensitive filesystems. The downside is that identical files with different case + // (but otherwise identical name) will run into a hash collision, but this is a very rare scenario. + rng.seed(project_name.hash64() * p_path.to_lower().hash64() * FileAccess::get_md5(p_path).hash64()); while (true) { int64_t num1 = rng.rand();