migrat Input a la ultima versió

cohesionats tots els metodes update de les escenes
This commit is contained in:
2025-11-01 22:28:51 +01:00
parent 1dd750ba0c
commit 824e7417ad
58 changed files with 26926 additions and 978 deletions
+49 -49
View File
@@ -15,10 +15,10 @@ namespace jdd {
// Entry metadata for each resource in the pack
struct ResourceEntry {
std::string filename; // Relative path within pack
uint64_t offset; // Byte offset in data block
uint64_t size; // Size in bytes
uint32_t checksum; // CRC32 checksum for verification
std::string filename; // Relative path within pack
uint64_t offset; // Byte offset in data block
uint64_t size; // Size in bytes
uint32_t checksum; // CRC32 checksum for verification
};
// Resource pack file format
@@ -26,67 +26,67 @@ struct ResourceEntry {
// Metadata: Count + array of ResourceEntry
// Data: Encrypted data block
class ResourcePack {
public:
ResourcePack() = default;
~ResourcePack() = default;
public:
ResourcePack() = default;
~ResourcePack() = default;
// Disable copy/move
ResourcePack(const ResourcePack&) = delete;
ResourcePack& operator=(const ResourcePack&) = delete;
ResourcePack(ResourcePack&&) = delete;
ResourcePack& operator=(ResourcePack&&) = delete;
// Disable copy/move
ResourcePack(const ResourcePack&) = delete;
ResourcePack& operator=(const ResourcePack&) = delete;
ResourcePack(ResourcePack&&) = delete;
ResourcePack& operator=(ResourcePack&&) = delete;
// Add a single file to the pack
auto addFile(const std::string& filepath, const std::string& pack_name) -> bool;
// Add a single file to the pack
auto addFile(const std::string& filepath, const std::string& pack_name) -> bool;
// Add all files from a directory recursively
auto addDirectory(const std::string& dir_path, const std::string& base_path = "")
-> bool;
// Add all files from a directory recursively
auto addDirectory(const std::string& dir_path, const std::string& base_path = "")
-> bool;
// Save the pack to a file
auto savePack(const std::string& pack_file) -> bool;
// Save the pack to a file
auto savePack(const std::string& pack_file) -> bool;
// Load a pack from a file
auto loadPack(const std::string& pack_file) -> bool;
// Load a pack from a file
auto loadPack(const std::string& pack_file) -> bool;
// Get a resource by name
auto getResource(const std::string& filename) -> std::vector<uint8_t>;
// Get a resource by name
auto getResource(const std::string& filename) -> std::vector<uint8_t>;
// Check if a resource exists
auto hasResource(const std::string& filename) const -> bool;
// Check if a resource exists
auto hasResource(const std::string& filename) const -> bool;
// Get list of all resources
auto getResourceList() const -> std::vector<std::string>;
// Get list of all resources
auto getResourceList() const -> std::vector<std::string>;
// Check if pack is loaded
auto isLoaded() const -> bool { return loaded_; }
// Check if pack is loaded
auto isLoaded() const -> bool { return loaded_; }
// Get pack statistics
auto getResourceCount() const -> size_t { return resources_.size(); }
auto getDataSize() const -> size_t { return data_.size(); }
// Get pack statistics
auto getResourceCount() const -> size_t { return resources_.size(); }
auto getDataSize() const -> size_t { return data_.size(); }
// Calculate overall pack checksum (for validation)
auto calculatePackChecksum() const -> uint32_t;
// Calculate overall pack checksum (for validation)
auto calculatePackChecksum() const -> uint32_t;
private:
static constexpr std::array<char, 4> MAGIC_HEADER = {'J', 'D', 'D', 'I'};
static constexpr uint32_t VERSION = 1;
static constexpr const char* DEFAULT_ENCRYPT_KEY = "JDDI_RESOURCES_2024";
private:
static constexpr std::array<char, 4> MAGIC_HEADER = {'J', 'D', 'D', 'I'};
static constexpr uint32_t VERSION = 1;
static constexpr const char* DEFAULT_ENCRYPT_KEY = "JDDI_RESOURCES_2024";
// Calculate CRC32 checksum
static auto calculateChecksum(const std::vector<uint8_t>& data) -> uint32_t;
// Calculate CRC32 checksum
static auto calculateChecksum(const std::vector<uint8_t>& data) -> uint32_t;
// XOR encryption/decryption
static void encryptData(std::vector<uint8_t>& data, const std::string& key);
static void decryptData(std::vector<uint8_t>& data, const std::string& key);
// XOR encryption/decryption
static void encryptData(std::vector<uint8_t>& data, const std::string& key);
static void decryptData(std::vector<uint8_t>& data, const std::string& key);
// Read file from disk
static auto readFile(const std::string& filepath) -> std::vector<uint8_t>;
// Read file from disk
static auto readFile(const std::string& filepath) -> std::vector<uint8_t>;
// Member data
std::unordered_map<std::string, ResourceEntry> resources_;
std::vector<uint8_t> data_; // Encrypted data block
bool loaded_{false};
// Member data
std::unordered_map<std::string, ResourceEntry> resources_;
std::vector<uint8_t> data_; // Encrypted data block
bool loaded_{false};
};
} // namespace jdd