1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-22 15:06:45 +00:00

PCK: Set VERSION_PATCH in header, factor out header magic

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 <rverschelde@gmail.com>
This commit is contained in:
Joost Heitbrink
2019-11-30 17:22:22 +01:00
committed by Rémi Verschelde
parent 8454804972
commit dc61323b2c
10 changed files with 38 additions and 39 deletions

View File

@@ -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) + ".");