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

Method load

compat/resource_compat_text.cpp:507–1135  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

505}
506
507Error ResourceLoaderCompatText::load() {
508 if (error != OK) {
509 return error;
510 }
511
512 while (true) {
513 if (next_tag.name != "ext_resource") {
514 break;
515 }
516
517 if (!next_tag.fields.has("path")) {
518 error = ERR_FILE_CORRUPT;
519 error_text = "Missing 'path' in external resource tag";
520 _printerr();
521 return error;
522 }
523
524 if (!next_tag.fields.has("type")) {
525 error = ERR_FILE_CORRUPT;
526 error_text = "Missing 'type' in external resource tag";
527 _printerr();
528 return error;
529 }
530
531 if (!next_tag.fields.has("id")) {
532 error = ERR_FILE_CORRUPT;
533 error_text = "Missing 'id' in external resource tag";
534 _printerr();
535 return error;
536 }
537
538 String path = next_tag.fields["path"];
539 String type = next_tag.fields["type"];
540 String id = next_tag.fields["id"];
541
542 ResourceUID::ID uid = ResourceUID::INVALID_ID;
543
544 if (next_tag.fields.has("uid")) {
545 String uidt = next_tag.fields["uid"];
546 uid = ResourceUID::get_singleton()->text_to_id(uidt);
547 // UID Stuff
548 // clang-format off
549 if (is_real_load()){
550 if (uid != ResourceUID::INVALID_ID && ResourceUID::get_singleton()->has_id(uid)) {
551 // If a UID is found and the path is valid, it will be used, otherwise, it falls back to the path.
552 path = ResourceUID::get_singleton()->get_id_path(uid);
553 } else {
554#ifdef TOOLS_ENABLED
555 // Silence a warning that can happen during the initial filesystem scan due to cache being regenerated.
556 if (ResourceLoader::get_resource_uid(path) != uid) {
557 WARN_PRINT(String(res_path + ":" + itos(lines) + " - ext_resource, invalid UID: " + uidt + " - using text path instead: " + path).utf8().get_data());
558 }
559#else
560 WARN_PRINT(String(res_path + ":" + itos(lines) + " - ext_resource, invalid UID: " + uidt + " - using text path instead: " + path).utf8().get_data());
561#endif
562 }
563 }
564 // clang-format on

Callers 1

custom_loadMethod · 0.45

Calls 15

get_refFunction · 0.85
localize_pathMethod · 0.80
reset_stateMethod · 0.80
set_pathMethod · 0.80
setMethod · 0.80
set_on_resourceMethod · 0.80
get_dataMethod · 0.45
containsMethod · 0.45
is_validMethod · 0.45
set_original_classMethod · 0.45
get_typeMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected