diff options
author | nikitalita <69168929+nikitalita@users.noreply.github.com> | 2021-07-29 22:24:29 -0700 |
---|---|---|
committer | nikitalita <69168929+nikitalita@users.noreply.github.com> | 2021-07-29 22:24:29 -0700 |
commit | bc58bf5477bc06c5ddcda04a95c6b13e137eec88 (patch) | |
tree | 889261822def16f0be4dba884199ff5064bc34a8 /core/io | |
parent | 160601cc78d14d500095a5127d49c335b249141a (diff) |
Use constant for reserved field count
Diffstat (limited to 'core/io')
-rw-r--r-- | core/io/resource_format_binary.cpp | 6 | ||||
-rw-r--r-- | core/io/resource_format_binary.h | 2 |
2 files changed, 5 insertions, 3 deletions
diff --git a/core/io/resource_format_binary.cpp b/core/io/resource_format_binary.cpp index 144db697fb..619e4a2170 100644 --- a/core/io/resource_format_binary.cpp +++ b/core/io/resource_format_binary.cpp @@ -906,7 +906,7 @@ void ResourceLoaderBinary::open(FileAccess *p_f, bool p_no_resources, bool p_kee uid = ResourceUID::INVALID_ID; } - for (int i = 0; i < 11; i++) { + for (int i = 0; i < ResourceFormatSaverBinaryInstance::RESERVED_FIELDS; i++) { f->get_32(); //skip a few reserved fields } @@ -1209,7 +1209,7 @@ Error ResourceFormatLoaderBinary::rename_dependencies(const String &p_path, cons fw->store_32(flags); fw->store_64(uid_data); - for (int i = 0; i < 11; i++) { + for (int i = 0; i < ResourceFormatSaverBinaryInstance::RESERVED_FIELDS; i++) { fw->store_32(0); // reserved f->get_32(); } @@ -1902,7 +1902,7 @@ Error ResourceFormatSaverBinaryInstance::save(const String &p_path, const RES &p f->store_32(FORMAT_FLAG_NAMED_SCENE_IDS | FORMAT_FLAG_UIDS); ResourceUID::ID uid = ResourceSaver::get_resource_id_for_path(p_path, true); f->store_64(uid); - for (int i = 0; i < 11; i++) { + for (int i = 0; i < ResourceFormatSaverBinaryInstance::RESERVED_FIELDS; i++) { f->store_32(0); // reserved } diff --git a/core/io/resource_format_binary.h b/core/io/resource_format_binary.h index ac964d2053..a6e6d1848e 100644 --- a/core/io/resource_format_binary.h +++ b/core/io/resource_format_binary.h @@ -164,6 +164,8 @@ public: enum { FORMAT_FLAG_NAMED_SCENE_IDS = 1, FORMAT_FLAG_UIDS = 2, + // Amount of reserved 32-bit fields in resource header + RESERVED_FIELDS = 11 }; Error save(const String &p_path, const RES &p_resource, uint32_t p_flags = 0); static void write_variant(FileAccess *f, const Variant &p_property, Map<RES, int> &resource_map, Map<RES, int> &external_resources, Map<StringName, int> &string_map, const PropertyInfo &p_hint = PropertyInfo()); |