浏览代码

Merge pull request #42980 from KoBeWi/(ಥ-͜ʖಥ)

Favor project.binary over project.godot
Rémi Verschelde 5 年之前
父节点
当前提交
17cd5e845a
共有 1 个文件被更改,包括 17 次插入10 次删除
  1. 17 10
      core/project_settings.cpp

+ 17 - 10
core/project_settings.cpp

@@ -629,19 +629,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 text-based project.godot file
-	Error err_text = _load_settings_text(p_text_path);
-	if (err_text == OK) {
+	// 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;
+	}
+
+	// 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_PRINT("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 {