| 3497 | } |
| 3498 | |
| 3499 | Error ResourceFormatSaverCompatBinaryInstance::set_save_settings(const Ref<Resource> &p_resource, uint32_t p_flags) { |
| 3500 | using_script_class = true; |
| 3501 | using_uids = true; |
| 3502 | using_named_scene_ids = true; |
| 3503 | |
| 3504 | Ref<ResourceInfo> compat = ResourceInfo::get_info_from_resource(p_resource); |
| 3505 | ver_format = CompatFormatLoader::get_format_version_from_flags(p_flags); |
| 3506 | ver_major = CompatFormatLoader::get_ver_major_from_flags(p_flags); |
| 3507 | ver_minor = CompatFormatLoader::get_ver_minor_from_flags(p_flags); // ver_minor can be 0. |
| 3508 | bool set_format = ver_format != 0 && ver_major != 0; |
| 3509 | String original_path; |
| 3510 | if (compat.is_valid()) { |
| 3511 | original_path = compat->original_path; |
| 3512 | if (!set_format) { |
| 3513 | ver_format = compat->ver_format; |
| 3514 | ver_major = compat->ver_major; |
| 3515 | ver_minor = compat->ver_minor; |
| 3516 | } |
| 3517 | if (ver_major == 0) { |
| 3518 | WARN_PRINT("Resource has a major version of 0, this is not supported."); |
| 3519 | } |
| 3520 | String format = compat->resource_format; |
| 3521 | script_class = compat->script_class; |
| 3522 | using_script_class = compat->using_script_class(); |
| 3523 | using_compression = compat->is_compressed; |
| 3524 | big_endian = compat->stored_big_endian; |
| 3525 | using_uids = compat->using_uids; |
| 3526 | using_named_scene_ids = compat->using_named_scene_ids; |
| 3527 | using_real_t_double = compat->using_real_t_double; |
| 3528 | stored_use_real64 = compat->stored_use_real64; |
| 3529 | imd = compat->v2metadata; |
| 3530 | res_uid = compat->uid; |
| 3531 | if (format != "binary" && !set_format) { // text |
| 3532 | if (ver_major > 4 || (ver_major == 4 && ver_minor >= 3)) { |
| 3533 | ver_format = 6; |
| 3534 | } else if (using_script_class) { |
| 3535 | ver_format = 5; |
| 3536 | } else if (using_named_scene_ids || ver_major == 4) { |
| 3537 | // If we're using named_scene_ids, it's version 4 |
| 3538 | ver_format = 4; |
| 3539 | // else go by engine major version |
| 3540 | } else if (ver_major == 3) { |
| 3541 | ver_format = 3; |
| 3542 | } else if (ver_major == 2) { |
| 3543 | ver_format = 1; |
| 3544 | } else { |
| 3545 | ver_format = 0; |
| 3546 | } |
| 3547 | } |
| 3548 | } else { |
| 3549 | if (!set_format) { |
| 3550 | if (GDRESettings::get_singleton()->is_pack_loaded()) { |
| 3551 | WARN_PRINT("Non-loaded resource and did not set version info, using default for pack."); |
| 3552 | ver_major = GDRESettings::get_singleton()->get_ver_major(); |
| 3553 | ver_minor = GDRESettings::get_singleton()->get_ver_minor(); |
| 3554 | ver_format = ResourceFormatSaverCompatBinary::get_default_format_version(ver_major, ver_minor); |
| 3555 | } else { |
| 3556 | WARN_PRINT("Non-loaded resource and did not set version info, using default format version for current engine."); |
nothing calls this directly
no test coverage detected