From d9800c1a28499d31d3bfd31ad010f225a9956a99 Mon Sep 17 00:00:00 2001 From: Robin Gustafsson Date: Tue, 1 Aug 2023 18:23:03 +0200 Subject: [PATCH] Block saving of Godot4 .pck files The PCK version 2 format is implemented for reading but not for writing. --- src/pck/PckFile.cpp | 7 ++++++- src/pck/PckFile.h | 3 ++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/pck/PckFile.cpp b/src/pck/PckFile.cpp index c178b3d..0e4c551 100644 --- a/src/pck/PckFile.cpp +++ b/src/pck/PckFile.cpp @@ -41,7 +41,7 @@ bool PckFile::Load() MinorGodotVersion = Read32(); PatchGodotVersion = Read32(); - if(FormatVersion > MAX_SUPPORTED_PCK_VERSION) { + if(FormatVersion > MAX_SUPPORTED_PCK_VERSION_LOAD) { std::cout << "ERROR: pck is unsupported version: " << FormatVersion << "\n"; return false; } @@ -112,6 +112,11 @@ bool PckFile::Load() // ------------------------------------ // bool PckFile::Save() { + if(FormatVersion > MAX_SUPPORTED_PCK_VERSION_SAVE) { + std::cout << "ERROR: cannot save pck version: " << FormatVersion << "\n"; + return false; + } + const auto tmpWrite = Path + ".write"; File = std::fstream(tmpWrite, std::ios::trunc | std::ios::out | std::ios::binary); diff --git a/src/pck/PckFile.h b/src/pck/PckFile.h index 68b13be..bb4cd12 100644 --- a/src/pck/PckFile.h +++ b/src/pck/PckFile.h @@ -17,7 +17,8 @@ constexpr uint32_t PCK_HEADER_MAGIC = 0x43504447; constexpr uint32_t PACK_DIR_ENCRYPTED = 1; // Highest pck version supported by this tool -constexpr int MAX_SUPPORTED_PCK_VERSION = 2; +constexpr int MAX_SUPPORTED_PCK_VERSION_LOAD = 2; +constexpr int MAX_SUPPORTED_PCK_VERSION_SAVE = 1; //! \brief A single pck file object. Handles reading and writing //!