Priorize Embedded PCKs on loading

If existing, embedded PCKs are loaded before the pcks the engine might
find next to it.

Fixes #37568

(cherry picked from commit fba98950c7)
This commit is contained in:
HaSa1002 2020-04-16 18:41:59 +02:00 committed by Rémi Verschelde
parent da2ca9e22a
commit caadd761f2
1 changed files with 12 additions and 23 deletions

View File

@ -362,40 +362,29 @@ Error ProjectSettings::_setup(const String &p_path, const String &p_main_pack, b
// We need to test both possibilities as extensions for Linux binaries are optional // 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'). // (so both 'mygame.bin' and 'mygame' should be able to find 'mygame.pck').
bool found = false;
String exec_dir = exec_path.get_base_dir(); String exec_dir = exec_path.get_base_dir();
String exec_filename = exec_path.get_file(); String exec_filename = exec_path.get_file();
String exec_basename = exec_filename.get_basename(); String exec_basename = exec_filename.get_basename();
// Try to load data pack at the location of the executable // Attempt with PCK bundled into executable
// As mentioned above, we have two potential names to attempt bool found = _load_resource_pack(exec_path);
if (_load_resource_pack(exec_dir.plus_file(exec_basename + ".pck")) ||
_load_resource_pack(exec_dir.plus_file(exec_filename + ".pck"))) {
found = true;
} else {
// If we couldn't find them next to the executable, we attempt
// the current working directory. Same story, two tests.
if (_load_resource_pack(exec_basename + ".pck") ||
_load_resource_pack(exec_filename + ".pck")) {
found = true;
}
}
#ifdef OSX_ENABLED #ifdef OSX_ENABLED
// Attempt to load PCK from macOS .app bundle resources
if (!found) { if (!found) {
if (_load_resource_pack(OS::get_singleton()->get_bundle_resource_dir().plus_file(exec_basename + ".pck"))) { // Attempt to load PCK from macOS .app bundle resources
found = true; found = _load_resource_pack(OS::get_singleton()->get_bundle_resource_dir().plus_file(exec_basename + ".pck"));
}
} }
#endif #endif
// Attempt with PCK bundled into executable
if (!found) { if (!found) {
if (_load_resource_pack(exec_path)) { // Try to load data pack at the location of the executable
found = true; // As mentioned above, we have two potential names to attempt
found = _load_resource_pack(exec_dir.plus_file(exec_basename + ".pck")) || _load_resource_pack(exec_dir.plus_file(exec_filename + ".pck"));
if (!found) {
// If we couldn't find them next to the executable, we attempt
// the current working directory. Same story, two tests.
found = _load_resource_pack(exec_basename + ".pck") || _load_resource_pack(exec_filename + ".pck");
} }
} }