MCPcopy Create free account
hub / github.com/GDRETools/gdsdecomp / _find_resources

Method _find_resources

compat/resource_compat_binary.cpp:2303–2399  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2301}
2302
2303void ResourceFormatSaverCompatBinaryInstance::_find_resources(const Variant &p_variant, bool p_main) {
2304 switch (p_variant.get_type()) {
2305 case Variant::OBJECT: {
2306 Ref<Resource> res = p_variant;
2307
2308 if (!CompatFormatLoader::resource_is_resource(res, ver_major) || res.is_null() || external_resources.has(res) || res->get_meta(SNAME("_skip_save_"), false)) {
2309 return;
2310 }
2311
2312 if (!p_main && (!bundle_resources) && !res->is_built_in()) {
2313 if (res->get_path() == path) {
2314 ERR_PRINT(vformat("Circular reference to resource being saved found: '%s' will be null next time it's loaded.", local_path));
2315 return;
2316 }
2317 int idx = external_resources.size();
2318 external_resources[res] = idx;
2319 return;
2320 }
2321
2322 if (resource_set.has(res)) {
2323 return;
2324 }
2325
2326 resource_set.insert(res);
2327
2328 List<PropertyInfo> property_list;
2329
2330 res->get_property_list(&property_list);
2331
2332 for (const PropertyInfo &E : property_list) {
2333 if (E.usage & PROPERTY_USAGE_STORAGE) {
2334 Variant value = res->get(E.name);
2335 if (E.usage & PROPERTY_USAGE_RESOURCE_NOT_PERSISTENT) {
2336 NonPersistentKey npk;
2337 npk.base = res;
2338 npk.property = E.name;
2339 non_persistent_map[npk] = value;
2340
2341 Ref<Resource> sres = value;
2342 if (sres.is_valid()) {
2343 resource_set.insert(sres);
2344 saved_resources.push_back(sres);
2345 } else {
2346 _find_resources(value);
2347 }
2348 } else {
2349 _find_resources(value);
2350 }
2351 }
2352 }
2353
2354 // COMPAT: get the missing resources too
2355 Dictionary missing_resources = res->get_meta(META_MISSING_RESOURCES, Dictionary());
2356 if (missing_resources.size()) {
2357 LocalVector<Variant> keys = missing_resources.get_key_list();
2358 for (Variant key : keys) {
2359 _find_resources(missing_resources[key]);
2360 }

Callers 1

Calls 10

_find_resourcesFunction · 0.85
get_property_listMethod · 0.80
push_backMethod · 0.80
get_typeMethod · 0.45
get_pathMethod · 0.45
sizeMethod · 0.45
insertMethod · 0.45
getMethod · 0.45
is_validMethod · 0.45
get_nameMethod · 0.45

Tested by 1