From dc61323b2ce5478b1fc07581e64f7b7fcfdaf239 Mon Sep 17 00:00:00 2001 From: Joost Heitbrink Date: Sat, 30 Nov 2019 17:22:22 +0100 Subject: PCK: Set VERSION_PATCH in header, factor out header magic MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Unify pack file version and magic to avoid hardcoded literals. `version.py` now always includes `patch` even for the first release in a new stable branch (e.g. 3.2). The public name stays without the patch number, but `Engine.get_version_info()` already included `patch == 0`, and we can remove some extra handling of undefined `VERSION_PATCH` this way. Co-authored-by: Rémi Verschelde --- core/io/file_access_pack.cpp | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) (limited to 'core/io/file_access_pack.cpp') diff --git a/core/io/file_access_pack.cpp b/core/io/file_access_pack.cpp index bef92b938b..83ce03418a 100644 --- a/core/io/file_access_pack.cpp +++ b/core/io/file_access_pack.cpp @@ -34,8 +34,6 @@ #include -#define PACK_VERSION 1 - Error PackedData::add_pack(const String &p_path, bool p_replace_files) { for (int i = 0; i < sources.size(); i++) { @@ -140,16 +138,14 @@ bool PackedSourcePCK::try_open_pack(const String &p_path, bool p_replace_files) if (!f) return false; - //printf("try open %ls!\n", p_path.c_str()); - uint32_t magic = f->get_32(); - if (magic != 0x43504447) { + if (magic != PACK_HEADER_MAGIC) { //maybe at the end.... self contained exe f->seek_end(); f->seek(f->get_position() - 4); magic = f->get_32(); - if (magic != 0x43504447) { + if (magic != PACK_HEADER_MAGIC) { f->close(); memdelete(f); @@ -161,7 +157,7 @@ bool PackedSourcePCK::try_open_pack(const String &p_path, bool p_replace_files) f->seek(f->get_position() - ds - 8); magic = f->get_32(); - if (magic != 0x43504447) { + if (magic != PACK_HEADER_MAGIC) { f->close(); memdelete(f); @@ -172,9 +168,9 @@ bool PackedSourcePCK::try_open_pack(const String &p_path, bool p_replace_files) uint32_t version = f->get_32(); uint32_t ver_major = f->get_32(); uint32_t ver_minor = f->get_32(); - f->get_32(); // ver_rev + f->get_32(); // patch number, not used for validation. - if (version != PACK_VERSION) { + if (version != PACK_FORMAT_VERSION) { f->close(); memdelete(f); ERR_FAIL_V_MSG(false, "Pack version unsupported: " + itos(version) + "."); -- cgit v1.2.3