diff options
Diffstat (limited to 'core/io')
-rw-r--r-- | core/io/file_access_pack.cpp | 14 | ||||
-rw-r--r-- | core/io/file_access_pack.h | 5 | ||||
-rw-r--r-- | core/io/pck_packer.cpp | 11 |
3 files changed, 16 insertions, 14 deletions
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 <stdio.h> -#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) + "."); diff --git a/core/io/file_access_pack.h b/core/io/file_access_pack.h index 6ced2b2d4d..b6ea9c158f 100644 --- a/core/io/file_access_pack.h +++ b/core/io/file_access_pack.h @@ -37,6 +37,11 @@ #include "core/os/file_access.h" #include "core/print_string.h" +// Godot's packed file magic header ("GDPC" in ASCII). +#define PACK_HEADER_MAGIC 0x43504447 +// The current packed file format version number. +#define PACK_FORMAT_VERSION 1 + class PackSource; class PackedData { diff --git a/core/io/pck_packer.cpp b/core/io/pck_packer.cpp index c317125c28..8bc73103e9 100644 --- a/core/io/pck_packer.cpp +++ b/core/io/pck_packer.cpp @@ -30,6 +30,7 @@ #include "pck_packer.h" +#include "core/io/file_access_pack.h" // PACK_HEADER_MAGIC, PACK_FORMAT_VERSION #include "core/os/file_access.h" #include "core/version.h" @@ -68,11 +69,11 @@ Error PCKPacker::pck_start(const String &p_file, int p_alignment) { alignment = p_alignment; - file->store_32(0x43504447); // MAGIC - file->store_32(1); // # version - file->store_32(VERSION_MAJOR); // # major - file->store_32(VERSION_MINOR); // # minor - file->store_32(0); // # revision + file->store_32(PACK_HEADER_MAGIC); + file->store_32(PACK_FORMAT_VERSION); + file->store_32(VERSION_MAJOR); + file->store_32(VERSION_MINOR); + file->store_32(VERSION_PATCH); for (int i = 0; i < 16; i++) { |