b746578bc8
Sustituye en bloque las cabeceras de los archivos por una sola línea de copyright. Cero rastro de "Visente", "Sergi" o "1999" en el árbol del proyecto. Se eliminan también las variantes "© 2025 Port a C++20", "© 2025 Port a C++20 con SDL3" y "© 2025 Orni Attack" (con todas sus colas descriptivas como "Arquitectura de entidades" o "Sistema de física"), que en este punto eran ruido histórico. Aplicado con un par de sed (find -type f, excluyendo source/external y source/legacy): 1. \|^// © 1999 Visente i Sergi (versión Pascal)$|d 2. s|^// © 2025 (Port a C++20.*|Orni Attack.*)$|// © 2026 JailDesigner| Verificado: la única variante de cabecera tras el sweep es "// © 2026 JailDesigner". Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
82 lines
2.1 KiB
C++
82 lines
2.1 KiB
C++
// resource_helper.cpp - Implementació de funciones de ajuda
|
|
// © 2026 JailDesigner
|
|
|
|
#include "resource_helper.hpp"
|
|
|
|
#include <algorithm>
|
|
#include <iostream>
|
|
|
|
#include "resource_loader.hpp"
|
|
|
|
namespace Resource::Helper {
|
|
|
|
// Inicialitzar el sistema de recursos
|
|
bool initializeResourceSystem(const std::string& pack_file, bool fallback) {
|
|
return Loader::get().initialize(pack_file, fallback);
|
|
}
|
|
|
|
// Carregar un file
|
|
std::vector<uint8_t> loadFile(const std::string& filepath) {
|
|
// Normalitzar la ruta
|
|
std::string normalized = normalizePath(filepath);
|
|
|
|
// Carregar del sistema de recursos
|
|
return Loader::get().loadResource(normalized);
|
|
}
|
|
|
|
// Comprovar si existeix un file
|
|
bool fileExists(const std::string& filepath) {
|
|
std::string normalized = normalizePath(filepath);
|
|
return Loader::get().resourceExists(normalized);
|
|
}
|
|
|
|
// Obtenir ruta normalitzada per al paquet
|
|
// Elimina prefixos "data/", rutes absolutes, etc.
|
|
std::string getPackPath(const std::string& asset_path) {
|
|
std::string path = asset_path;
|
|
|
|
// Eliminar rutes absolutes (detectar / o C:\ al principi)
|
|
if (!path.empty() && path[0] == '/') {
|
|
// Buscar "data/" i agafar el que ve después
|
|
size_t data_pos = path.find("/data/");
|
|
if (data_pos != std::string::npos) {
|
|
path = path.substr(data_pos + 6); // Saltar "/data/"
|
|
}
|
|
}
|
|
|
|
// Eliminar "./" i "../" del principi
|
|
while (path.starts_with("./")) {
|
|
path = path.substr(2);
|
|
}
|
|
while (path.starts_with("../")) {
|
|
path = path.substr(3);
|
|
}
|
|
|
|
// Eliminar "data/" del principi
|
|
if (path.starts_with("data/")) {
|
|
path = path.substr(5);
|
|
}
|
|
|
|
// Eliminar "Resources/" (macOS bundles)
|
|
if (path.starts_with("Resources/")) {
|
|
path = path.substr(10);
|
|
}
|
|
|
|
// Convertir barres invertides a normals
|
|
std::ranges::replace(path, '\\', '/');
|
|
|
|
return path;
|
|
}
|
|
|
|
// Normalitzar ruta (alias de getPackPath)
|
|
std::string normalizePath(const std::string& path) {
|
|
return getPackPath(path);
|
|
}
|
|
|
|
// Comprovar si hay paquet carregat
|
|
bool isPackLoaded() {
|
|
return Loader::get().isPackLoaded();
|
|
}
|
|
|
|
} // namespace Resource::Helper
|