Merge pull request #111858 from KoBeWi/IcOn.SvG

Improve determinism of UIDs
This commit is contained in:
Rémi Verschelde
2026-01-06 10:59:33 +01:00

View File

@@ -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();