diff options
Diffstat (limited to 'core/project_settings.cpp')
-rw-r--r-- | core/project_settings.cpp | 35 |
1 files changed, 23 insertions, 12 deletions
diff --git a/core/project_settings.cpp b/core/project_settings.cpp index c86d1567dd..fc1a74801d 100644 --- a/core/project_settings.cpp +++ b/core/project_settings.cpp @@ -75,11 +75,19 @@ String ProjectSettings::localize_path(const String &p_path) const { memdelete(dir); - if (!cwd.begins_with(resource_path)) { + // Ensure that we end with a '/'. + // This is important to ensure that we do not wrongly localize the resource path + // in an absolute path that just happens to contain this string but points to a + // different folder (e.g. "/my/project" as resource_path would be contained in + // "/my/project_data", even though the latter is not part of res://. + // `plus_file("")` is an easy way to ensure we have a trailing '/'. + const String res_path = resource_path.plus_file(""); + + if (!cwd.begins_with(res_path)) { return p_path; }; - return cwd.replace_first(resource_path, "res:/"); + return cwd.replace_first(res_path, "res://"); } else { memdelete(dir); @@ -481,7 +489,7 @@ Error ProjectSettings::_load_settings_binary(const String p_path) { memdelete(f); ERR_EXPLAIN("Corrupted header in binary project.binary (not ECFG)"); - ERR_FAIL_V(ERR_FILE_CORRUPT;) + ERR_FAIL_V(ERR_FILE_CORRUPT); } uint32_t count = f->get_32(); @@ -558,7 +566,7 @@ Error ProjectSettings::_load_settings_text(const String p_path) { if (config_version > CONFIG_VERSION) { memdelete(f); ERR_EXPLAIN(vformat("Can't open project at '%s', its `config_version` (%d) is from a more recent and incompatible version of the engine. Expected config version: %d.", p_path, config_version, CONFIG_VERSION)); - ERR_FAIL_COND_V(config_version > CONFIG_VERSION, ERR_FILE_CANT_OPEN); + ERR_FAIL_V(ERR_FILE_CANT_OPEN); } } else { if (section == String()) { @@ -571,10 +579,6 @@ Error ProjectSettings::_load_settings_text(const String p_path) { section = next_tag.name; } } - - memdelete(f); - - return OK; } Error ProjectSettings::_load_settings_text_or_binary(const String p_text_path, const String p_bin_path) { @@ -632,7 +636,7 @@ Error ProjectSettings::_save_settings_binary(const String &p_file, const Map<Str if (err != OK) { ERR_EXPLAIN("Couldn't save project.binary at " + p_file); - ERR_FAIL_COND_V(err, err) + ERR_FAIL_COND_V(err, err); } uint8_t hdr[4] = { 'E', 'C', 'F', 'G' }; @@ -724,7 +728,7 @@ Error ProjectSettings::_save_settings_text(const String &p_file, const Map<Strin if (err) { ERR_EXPLAIN("Couldn't save project.godot - " + p_file); - ERR_FAIL_COND_V(err, err) + ERR_FAIL_COND_V(err, err); } file->store_line("; Engine configuration file."); @@ -859,8 +863,6 @@ Error ProjectSettings::save_custom(const String &p_path, const CustomMap &p_cust ERR_EXPLAIN("Unknown config file format: " + p_path); ERR_FAIL_V(ERR_FILE_UNRECOGNIZED); } - - return OK; } Variant _GLOBAL_DEF(const String &p_var, const Variant &p_default, bool p_restart_if_changed) { @@ -1007,6 +1009,15 @@ ProjectSettings::ProjectSettings() { GLOBAL_DEF("audio/default_bus_layout", "res://default_bus_layout.tres"); custom_prop_info["audio/default_bus_layout"] = PropertyInfo(Variant::STRING, "audio/default_bus_layout", PROPERTY_HINT_FILE, "*.tres"); + PoolStringArray extensions = PoolStringArray(); + extensions.push_back("gd"); + if (Engine::get_singleton()->has_singleton("GodotSharp")) + extensions.push_back("cs"); + extensions.push_back("shader"); + + GLOBAL_DEF("editor/search_in_file_extensions", extensions); + custom_prop_info["editor/search_in_file_extensions"] = PropertyInfo(Variant::POOL_STRING_ARRAY, "editor/search_in_file_extensions"); + action = Dictionary(); action["deadzone"] = Variant(0.5f); events = Array(); |