| 727 | } |
| 728 | |
| 729 | Error ResourceLoaderCompatBinary::load() { |
| 730 | if (error != OK) { |
| 731 | return error; |
| 732 | } |
| 733 | |
| 734 | for (int i = 0; i < external_resources.size(); i++) { |
| 735 | String path = external_resources[i].path; |
| 736 | |
| 737 | if (remaps.has(path)) { |
| 738 | path = remaps[path]; |
| 739 | } |
| 740 | |
| 741 | if (!path.contains("://") && path.is_relative_path()) { |
| 742 | // path is relative to file being loaded, so convert to a resource path |
| 743 | path = GDRESettings::get_singleton()->localize_path(res_path.get_base_dir().path_join(path)); |
| 744 | } |
| 745 | |
| 746 | external_resources.write[i].path = path; //remap happens here, not on load because on load it can actually be used for filesystem dock resource remap |
| 747 | external_resources.write[i].load_token = start_ext_load(path, external_resources[i].type, external_resources[i].uid, i); |
| 748 | if (external_resources[i].load_token.is_null()) { |
| 749 | if (!ResourceLoader::get_abort_on_missing_resources()) { |
| 750 | ResourceLoader::notify_dependency_error(local_path, path, external_resources[i].type); |
| 751 | } else { |
| 752 | error = ERR_FILE_MISSING_DEPENDENCIES; |
| 753 | ERR_FAIL_V_MSG(error, vformat("Can't load dependency: '%s'.", path)); |
| 754 | } |
| 755 | } |
| 756 | } |
| 757 | |
| 758 | for (int i = 0; i < internal_resources.size(); i++) { |
| 759 | bool main = i == (internal_resources.size() - 1); |
| 760 | |
| 761 | //maybe it is loaded already |
| 762 | String path; |
| 763 | String id; |
| 764 | |
| 765 | if (!main) { |
| 766 | path = internal_resources[i].path; |
| 767 | |
| 768 | if (path.begins_with("local://")) { |
| 769 | path = path.replace_first("local://", ""); |
| 770 | id = path; |
| 771 | path = res_path + "::" + path; |
| 772 | |
| 773 | internal_resources.write[i].path = path; // Update path. |
| 774 | } |
| 775 | |
| 776 | if (cache_mode == ResourceFormatLoader::CACHE_MODE_REUSE && ResourceCache::has(path)) { |
| 777 | Ref<Resource> cached = ResourceCache::get_ref(path); |
| 778 | if (cached.is_valid()) { |
| 779 | //already loaded, don't do anything |
| 780 | error = OK; |
| 781 | internal_index_cache[path] = cached; |
| 782 | continue; |
| 783 | } |
| 784 | } |
| 785 | } else { |
| 786 | if (cache_mode != ResourceFormatLoader::CACHE_MODE_IGNORE && !ResourceCache::has(res_path)) { |
no test coverage detected