chore(release): v0.21.0 — empaquetat de recursos (AE26) i neteja de fonts

- Nou format de pack AE26 v1 (XOR + djb2), eina `pack_resources`,
  regeneració automàtica de `build/resources.pack` a cada build.
- `Resource::Helper` amb init/shutdown, fallback a disc només en Debug
  (apunta al source tree); Release exigeix pack present.
- Callers de YAML migrats a `loadFile`+deserialize des de buffer.
- Arrel neta: el pack viu a `build/`, eliminat `sync_data`.
- Placeholder font -> `ari-w9500-condensed-display`; esborrades variants
  bold/condensed no usades a `data/fonts/`.
This commit is contained in:
JailDesigner committed 2026-04-23 08:51:21 +02:00
1 parent aeed0e01c2
commit 4da05b3d76
24 files changed
+574 -625

No files matched your search

+13 -11
View File
@@ -1,6 +1,5 @@
#include "game/entities/entity_loader.hpp"
#include <fstream>
#include <stdexcept>
#include <unordered_map>
@@ -31,23 +30,26 @@ namespace EntityLoader {
auto it = cache.find(name);
if (it != cache.end()) { return it->second; }
const std::string FULL = Resource::Helper::resolve(templatePath(name));
std::ifstream file(FULL);
if (!file.is_open()) {
throw std::runtime_error("EntityLoader: no s'ha pogut obrir " + FULL);
const auto PATH = templatePath(name);
auto bytes = Resource::Helper::loadFile(PATH);
if (bytes.empty()) {
throw std::runtime_error("EntityLoader: no s'ha pogut obrir " + PATH);
}
fkyaml::node node = fkyaml::node::deserialize(file);
const auto* begin = reinterpret_cast<const char*>(bytes.data());
const auto* end = begin + bytes.size();
fkyaml::node node = fkyaml::node::deserialize(begin, end);
cache.emplace(name, node);
return node;
}
auto readSpawns(const std::string& level_yaml_path) -> std::vector<fkyaml::node> {
const auto FULL = Resource::Helper::resolve(level_yaml_path);
std::ifstream file(FULL);
if (!file.is_open()) {
throw std::runtime_error("EntityLoader: no s'ha pogut obrir " + FULL);
auto bytes = Resource::Helper::loadFile(level_yaml_path);
if (bytes.empty()) {
throw std::runtime_error("EntityLoader: no s'ha pogut obrir " + level_yaml_path);
}
fkyaml::node root = fkyaml::node::deserialize(file);
const auto* begin = reinterpret_cast<const char*>(bytes.data());
const auto* end = begin + bytes.size();
fkyaml::node root = fkyaml::node::deserialize(begin, end);
std::vector<fkyaml::node> spawns;
if (!root.contains("entities")) { return spawns; }
const auto& list = root["entities"];
+7 -7
View File
@@ -4,7 +4,6 @@
#include <algorithm>
#include <cmath>
#include <fstream>
#include <stdexcept>
#include <utility>
@@ -47,18 +46,19 @@ namespace {
} // namespace
void Player::loadFrom(const std::string& yaml_path) {
const auto FULL = Resource::Helper::resolve(yaml_path);
std::ifstream file(FULL);
if (!file.is_open()) {
throw std::runtime_error("Player: no s'ha pogut obrir " + FULL);
auto bytes = Resource::Helper::loadFile(yaml_path);
if (bytes.empty()) {
throw std::runtime_error("Player: no s'ha pogut obrir " + yaml_path);
}
auto yaml = fkyaml::node::deserialize(file);
const auto* begin = reinterpret_cast<const char*>(bytes.data());
const auto* end = begin + bytes.size();
auto yaml = fkyaml::node::deserialize(begin, end);
sprite_w = yaml["frameWidth"].get_value<int>();
sprite_h = yaml["frameHeight"].get_value<int>();
if (!yaml.contains("collision")) {
throw std::runtime_error("Player: manca bloc `collision:` a " + FULL);
throw std::runtime_error("Player: manca bloc `collision:` a " + yaml_path);
}
const auto& c = yaml["collision"];
collision_size = c["size"].get_value<int>();