summaryrefslogtreecommitdiff
path: root/core/project_settings.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'core/project_settings.cpp')
-rw-r--r--core/project_settings.cpp34
1 files changed, 23 insertions, 11 deletions
diff --git a/core/project_settings.cpp b/core/project_settings.cpp
index fc1a74801d..c1d4967f55 100644
--- a/core/project_settings.cpp
+++ b/core/project_settings.cpp
@@ -83,6 +83,10 @@ String ProjectSettings::localize_path(const String &p_path) const {
// `plus_file("")` is an easy way to ensure we have a trailing '/'.
const String res_path = resource_path.plus_file("");
+ // DirAccess::get_current_dir() is not guaranteed to return a path that with a trailing '/',
+ // so we must make sure we have it as well in order to compare with 'res_path'.
+ cwd = cwd.plus_file("");
+
if (!cwd.begins_with(res_path)) {
return p_path;
};
@@ -343,17 +347,17 @@ Error ProjectSettings::_setup(const String &p_path, const String &p_main_pack, b
return err;
}
- // Attempt with exec_name.pck
- // (This is the usual case when distributing a Godot game.)
-
- // Based on the OS, it can be the exec path + '.pck' (Linux w/o extension, macOS in .app bundle)
- // or the exec path's basename + '.pck' (Windows).
- // We need to test both possibilities as extensions for Linux binaries are optional
- // (so both 'mygame.bin' and 'mygame' should be able to find 'mygame.pck').
-
String exec_path = OS::get_singleton()->get_executable_path();
if (exec_path != "") {
+ // Attempt with exec_name.pck
+ // (This is the usual case when distributing a Godot game.)
+
+ // Based on the OS, it can be the exec path + '.pck' (Linux w/o extension, macOS in .app bundle)
+ // or the exec path's basename + '.pck' (Windows).
+ // We need to test both possibilities as extensions for Linux binaries are optional
+ // (so both 'mygame.bin' and 'mygame' should be able to find 'mygame.pck').
+
bool found = false;
String exec_dir = exec_path.get_base_dir();
@@ -375,6 +379,14 @@ Error ProjectSettings::_setup(const String &p_path, const String &p_main_pack, b
}
}
+ // Attempt with PCK bundled into executable
+
+ if (!found) {
+ if (_load_resource_pack(exec_path)) {
+ found = true;
+ }
+ }
+
// If we opened our package, try and load our project
if (found) {
Error err = _load_settings_text_or_binary("res://project.godot", "res://project.binary");
@@ -475,7 +487,7 @@ void ProjectSettings::set_registering_order(bool p_enable) {
registering_order = p_enable;
}
-Error ProjectSettings::_load_settings_binary(const String p_path) {
+Error ProjectSettings::_load_settings_binary(const String &p_path) {
Error err;
FileAccess *f = FileAccess::open(p_path, FileAccess::READ, &err);
@@ -518,7 +530,7 @@ Error ProjectSettings::_load_settings_binary(const String p_path) {
return OK;
}
-Error ProjectSettings::_load_settings_text(const String p_path) {
+Error ProjectSettings::_load_settings_text(const String &p_path) {
Error err;
FileAccess *f = FileAccess::open(p_path, FileAccess::READ, &err);
@@ -581,7 +593,7 @@ 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);