Skip to content

Commit

Permalink
Block saving of Godot4 .pck files
Browse files Browse the repository at this point in the history
The PCK version 2 format is implemented for reading but not for writing.
  • Loading branch information
rgson committed Aug 1, 2023
1 parent 897f88a commit d9800c1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
7 changes: 6 additions & 1 deletion src/pck/PckFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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);
Expand Down
3 changes: 2 additions & 1 deletion src/pck/PckFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
//!
Expand Down

0 comments on commit d9800c1

Please sign in to comment.