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>();
+8 -8
View File
@@ -1,6 +1,5 @@
#include "game/map/map.hpp"
#include <fstream>
#include <iostream>
#include <stdexcept>
@@ -22,14 +21,15 @@ namespace {
namespace Map {
void 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("Map: no s'ha pogut obrir " + FULL);
auto bytes = Resource::Helper::loadFile(yaml_path);
if (bytes.empty()) {
throw std::runtime_error("Map: 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);
if (!yaml.contains("geometry")) {
throw std::runtime_error("Map: manca bloc `geometry:` a " + FULL);
throw std::runtime_error("Map: manca bloc `geometry:` a " + yaml_path);
}
const auto& g = yaml["geometry"];
@@ -78,7 +78,7 @@ namespace Map {
std::cout << "Map: geometria " << grid_cols << "x" << grid_rows
<< " sarcs " << sarc_w << "x" << sarc_h
<< " pitch " << pitch_x << "x" << pitch_y
<< " des de " << FULL << '\n';
<< " des de " << yaml_path << '\n';
}
auto getSarcRect(int col, int row) -> SDL_FRect {
+7 -8
View File
@@ -2,7 +2,6 @@
#include <algorithm>
#include <cstddef>
#include <fstream>
#include <iostream>
#include <sstream>
#include <stdexcept>
@@ -68,13 +67,13 @@ namespace {
} // namespace
Tilemap::Tilemap(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("Tilemap: no s'ha pogut obrir " + FULL);
auto bytes = Resource::Helper::loadFile(yaml_path);
if (bytes.empty()) {
throw std::runtime_error("Tilemap: 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);
const auto TILESET_PATH = yaml["tileset"].get_value<std::string>();
const auto TILE_SIZE = yaml["tile_size"].get_value<int>();
@@ -113,7 +112,7 @@ Tilemap::Tilemap(const std::string& yaml_path) {
}
std::cout << "Tilemap: " << COLS << "x" << ROWS << " tiles ("
<< width_px_ << "x" << height_px_ << " px) des de " << FULL << '\n';
<< width_px_ << "x" << height_px_ << " px) des de " << yaml_path << '\n';
}
void Tilemap::render() const {