diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2018-12-21 14:43:51 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-12-21 14:43:51 +0100 |
commit | 762b9b6bdbec24b0fa0fffd34e6e0afff7cf01fd (patch) | |
tree | de78b058903a58d4ce8450ec24044c6225d0b107 /core/project_settings.cpp | |
parent | 7b1cbe9874bbefbe70e338fcded18cbf56cccc2b (diff) | |
parent | 616beb1041cc5850b882e7cab64a6e19d00aef42 (diff) |
Merge pull request #24527 from akien-mga/pm-warn-config-version
ProjectManager: Warn when projects have different config_version
Diffstat (limited to 'core/project_settings.cpp')
-rw-r--r-- | core/project_settings.cpp | 26 |
1 files changed, 11 insertions, 15 deletions
diff --git a/core/project_settings.cpp b/core/project_settings.cpp index 031ac06063..f3368a5595 100644 --- a/core/project_settings.cpp +++ b/core/project_settings.cpp @@ -43,8 +43,6 @@ #include <zlib.h> -#define FORMAT_VERSION 4 - ProjectSettings *ProjectSettings::singleton = NULL; ProjectSettings *ProjectSettings::get_singleton() { @@ -271,9 +269,9 @@ bool ProjectSettings::_load_resource_pack(const String &p_pack) { return true; } -void ProjectSettings::_convert_to_last_version() { - if (!has_setting("config_version") || (int)get_setting("config_version") <= 3) { +void ProjectSettings::_convert_to_last_version(int p_from_version) { + if (p_from_version <= 3) { // Converts the actions from array to dictionary (array of events to dictionary with deadzone + events) for (Map<StringName, ProjectSettings::VariantContainer>::Element *E = props.front(); E; E = E->next()) { Variant value = E->get().variant; @@ -396,7 +394,6 @@ Error ProjectSettings::_setup(const String &p_path, const String &p_main_pack, b // Optional, we don't mind if it fails _load_settings_text("res://override.cfg"); } - return err; } @@ -443,10 +440,6 @@ Error ProjectSettings::_setup(const String &p_path, const String &p_main_pack, b if (resource_path.length() && resource_path[resource_path.length() - 1] == '/') resource_path = resource_path.substr(0, resource_path.length() - 1); // chop end - // If we're loading a project.godot from source code, we can operate some - // ProjectSettings conversions if need be. - _convert_to_last_version(); - return OK; } @@ -537,8 +530,8 @@ Error ProjectSettings::_load_settings_text(const String p_path) { int lines = 0; String error_text; - String section; + int config_version = 0; while (true) { @@ -549,6 +542,9 @@ Error ProjectSettings::_load_settings_text(const String p_path) { err = VariantParser::parse_tag_assign_eof(&stream, lines, error_text, next_tag, assign, value, NULL, true); if (err == ERR_FILE_EOF) { memdelete(f); + // If we're loading a project.godot from source code, we can operate some + // ProjectSettings conversions if need be. + _convert_to_last_version(config_version); return OK; } else if (err != OK) { ERR_PRINTS("Error parsing " + p_path + " at line " + itos(lines) + ": " + error_text + " File might be corrupted."); @@ -558,13 +554,13 @@ Error ProjectSettings::_load_settings_text(const String p_path) { if (assign != String()) { if (section == String() && assign == "config_version") { - int config_version = value; - if (config_version > FORMAT_VERSION) { + config_version = value; + if (config_version > CONFIG_VERSION) { memdelete(f); - ERR_FAIL_COND_V(config_version > FORMAT_VERSION, ERR_FILE_CANT_OPEN); + 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); } } else { - // config_version is checked and dropped if (section == String()) { set(assign, value); } else { @@ -740,7 +736,7 @@ Error ProjectSettings::_save_settings_text(const String &p_file, const Map<Strin file->store_line("; param=value ; assign values to parameters"); file->store_line(""); - file->store_string("config_version=" + itos(FORMAT_VERSION) + "\n"); + file->store_string("config_version=" + itos(CONFIG_VERSION) + "\n"); if (p_custom_features != String()) file->store_string("custom_features=\"" + p_custom_features + "\"\n"); file->store_string("\n"); |