You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-05 12:10:55 +00:00
csv import: generate positve UID for .translation and follow renames
Mask with INT64_MAX to avoid negative UIDs which cause bugs. If the generated .translation UID is already in use (renamed), overwrite that file instead.
This commit is contained in:
@@ -142,15 +142,23 @@ Error ResourceImporterCSVTranslation::import(ResourceUID::ID p_source_id, const
|
|||||||
}
|
}
|
||||||
|
|
||||||
String save_path = p_source_file.get_basename() + "." + translations[i]->get_locale() + ".translation";
|
String save_path = p_source_file.get_basename() + "." + translations[i]->get_locale() + ".translation";
|
||||||
|
ResourceUID::ID save_id = hash64_murmur3_64(translations[i]->get_locale().hash64(), p_source_id) & 0x7FFFFFFFFFFFFFFF;
|
||||||
|
bool uid_already_exists = ResourceUID::get_singleton()->has_id(save_id);
|
||||||
|
if (uid_already_exists) {
|
||||||
|
// Avoid creating a new file with a duplicate UID.
|
||||||
|
// Always use this UID, even if the user has moved it to a different path.
|
||||||
|
save_path = ResourceUID::get_singleton()->get_id_path(save_id);
|
||||||
|
}
|
||||||
|
|
||||||
ResourceSaver::save(xlt, save_path);
|
ResourceSaver::save(xlt, save_path);
|
||||||
if (r_gen_files) {
|
if (r_gen_files) {
|
||||||
r_gen_files->push_back(save_path);
|
r_gen_files->push_back(save_path);
|
||||||
}
|
}
|
||||||
|
if (!uid_already_exists) {
|
||||||
ResourceUID::ID save_id = hash64_murmur3_64(translations[i]->get_locale().hash64(), p_source_id);
|
// No need to call set_uid if save_path already refers to save_id.
|
||||||
ResourceSaver::set_uid(save_path, save_id);
|
ResourceSaver::set_uid(save_path, save_id);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user