Browse Source

Favor project.binary over project.godot

(cherry picked from commit 37d515e99c2da449397511cbc9b25fee84dd66fc)
Tomasz Chabora 4 years ago
parent
commit
c2a7df79ce
1 changed files with 16 additions and 10 deletions
  1. 16 10
      core/project_settings.cpp

+ 16 - 10
core/project_settings.cpp

@@ -612,20 +612,26 @@ Error ProjectSettings::_load_settings_text(const String &p_path) {
 }
 }
 
 
 Error ProjectSettings::_load_settings_text_or_binary(const String &p_text_path, const String &p_bin_path) {
 Error ProjectSettings::_load_settings_text_or_binary(const String &p_text_path, const String &p_bin_path) {
+	// Attempt first to load the binary project.godot file.
+	Error err = _load_settings_binary(p_bin_path);
+	if (err == OK) {
+		return OK;
+	} else if (err != ERR_FILE_NOT_FOUND) {
+		// If the file exists but can't be loaded, we want to know it.
+		ERR_PRINT("Couldn't load file '" + p_bin_path + "', error code " + itos(err) + ".");
+		return err;
+	}
 
 
-	// Attempt first to load the text-based project.godot file
-	Error err_text = _load_settings_text(p_text_path);
-	if (err_text == OK) {
+	// Fallback to text-based project.godot file if binary was not found.
+	err = _load_settings_text(p_text_path);
+	if (err == OK) {
 		return OK;
 		return OK;
-	} else if (err_text != ERR_FILE_NOT_FOUND) {
-		// If the text-based file exists but can't be loaded, we want to know it
-		ERR_PRINTS("Couldn't load file '" + p_text_path + "', error code " + itos(err_text) + ".");
-		return err_text;
+	} else if (err != ERR_FILE_NOT_FOUND) {
+		ERR_PRINT("Couldn't load file '" + p_text_path + "', error code " + itos(err) + ".");
+		return err;
 	}
 	}
 
 
-	// Fallback to binary project.binary file if text-based was not found
-	Error err_bin = _load_settings_binary(p_bin_path);
-	return err_bin;
+	return err;
 }
 }
 
 
 int ProjectSettings::get_order(const String &p_name) const {
 int ProjectSettings::get_order(const String &p_name) const {