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

Method _save_settings_binary

utility/pcfg_loader.cpp:481–548  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

479}
480
481Error ProjectConfigLoader::_save_settings_binary(const String &p_file, const RBMap<String, List<String>> &proops, const uint32_t ver_major, const uint32_t ver_minor, const CustomMap &p_custom, const String &p_custom_features) {
482 Error err;
483 Ref<FileAccess> file = FileAccess::open(p_file, FileAccess::WRITE, &err);
484 ERR_FAIL_COND_V_MSG(err != OK, err, vformat("Couldn't save project.binary at '%s'.", p_file));
485
486 uint8_t hdr[4] = { 'E', 'C', 'F', 'G' };
487 file->store_buffer(hdr, 4);
488
489 int count = 0;
490
491 for (const KeyValue<String, List<String>> &E : proops) {
492 count += E.value.size();
493 }
494
495 if (!p_custom_features.is_empty()) {
496 // Store how many properties are saved, add one for custom features, which must always go first.
497 file->store_32(uint32_t(count + 1));
498 String key = CoreStringName(_custom_features);
499 file->store_pascal_string(key);
500
501 int len;
502 err = VariantDecoderCompat::encode_variant_compat(ver_major, p_custom_features, nullptr, len, false);
503 ERR_FAIL_COND_V(err != OK, err);
504
505 Vector<uint8_t> buff;
506 buff.resize(len);
507
508 err = VariantDecoderCompat::encode_variant_compat(ver_major, p_custom_features, buff.ptrw(), len, false);
509 ERR_FAIL_COND_V(err != OK, err);
510 file->store_32(uint32_t(len));
511 file->store_buffer(buff.ptr(), buff.size());
512
513 } else {
514 // Store how many properties are saved.
515 file->store_32(uint32_t(count));
516 }
517
518 for (const KeyValue<String, List<String>> &E : proops) {
519 for (const String &key : E.value) {
520 String k = key;
521 if (!E.key.is_empty()) {
522 k = E.key + "/" + k;
523 }
524 Variant value;
525 if (p_custom.has(k)) {
526 value = p_custom[k];
527 } else {
528 value = props[k].variant;
529 }
530
531 file->store_pascal_string(k);
532
533 int len;
534 err = VariantDecoderCompat::encode_variant_compat(ver_major, value, nullptr, len, true);
535 ERR_FAIL_COND_V_MSG(err != OK, ERR_INVALID_DATA, "Error when trying to encode Variant.");
536
537 Vector<uint8_t> buff;
538 buff.resize(len);

Callers

nothing calls this directly

Calls 3

store_bufferMethod · 0.45
sizeMethod · 0.45
resizeMethod · 0.45

Tested by

no test coverage detected