linter: varios

This commit is contained in:
2025-10-24 17:12:57 +02:00
parent 9979f31b4a
commit 636e4d932a
11 changed files with 136 additions and 106 deletions

View File

@@ -15,14 +15,14 @@ void AssetIntegrated::initWithResourcePack(const std::string& executable_path,
auto& loader = ResourceLoader::getInstance();
if (loader.initialize(resource_pack_path, true)) {
resource_pack_enabled = true;
std::cout << "Asset system initialized with resource pack: " << resource_pack_path << std::endl;
std::cout << "Asset system initialized with resource pack: " << resource_pack_path << '\n';
} else {
resource_pack_enabled = false;
std::cout << "Asset system initialized in fallback mode (filesystem)" << std::endl;
std::cout << "Asset system initialized in fallback mode (filesystem)" << '\n';
}
}
std::vector<uint8_t> AssetIntegrated::loadFile(const std::string& filename) {
auto AssetIntegrated::loadFile(const std::string& filename) -> std::vector<uint8_t> {
if (shouldUseResourcePack(filename) && resource_pack_enabled) {
// Intentar cargar del pack de recursos
auto& loader = ResourceLoader::getInstance();
@@ -45,7 +45,7 @@ std::vector<uint8_t> AssetIntegrated::loadFile(const std::string& filename) {
// Fallback: cargar del filesystem
std::ifstream file(filename, std::ios::binary | std::ios::ate);
if (!file) {
std::cerr << "Error: Could not open file: " << filename << std::endl;
std::cerr << "Error: Could not open file: " << filename << '\n';
return {};
}
@@ -54,25 +54,25 @@ std::vector<uint8_t> AssetIntegrated::loadFile(const std::string& filename) {
std::vector<uint8_t> data(file_size);
if (!file.read(reinterpret_cast<char*>(data.data()), file_size)) {
std::cerr << "Error: Could not read file: " << filename << std::endl;
std::cerr << "Error: Could not read file: " << filename << '\n';
return {};
}
return data;
}
bool AssetIntegrated::fileExists(const std::string& filename) const {
auto AssetIntegrated::fileExists(const std::string& filename) const -> bool {
if (shouldUseResourcePack(filename) && resource_pack_enabled) {
auto& loader = ResourceLoader::getInstance();
// Convertir ruta completa a ruta relativa para el pack
std::string relativePath = filename;
std::string relative_path = filename;
size_t data_pos = filename.find("data/");
if (data_pos != std::string::npos) {
relativePath = filename.substr(data_pos + 5);
relative_path = filename.substr(data_pos + 5);
}
if (loader.resourceExists(relativePath)) {
if (loader.resourceExists(relative_path)) {
return true;
}
}
@@ -81,24 +81,24 @@ bool AssetIntegrated::fileExists(const std::string& filename) const {
return std::filesystem::exists(filename);
}
std::string AssetIntegrated::getSystemPath(const std::string& filename) const {
auto AssetIntegrated::getSystemPath(const std::string& filename) -> std::string {
// Los archivos de sistema/config siempre van al filesystem
return filename;
}
bool AssetIntegrated::shouldUseResourcePack(const std::string& filepath) const {
auto AssetIntegrated::shouldUseResourcePack(const std::string& filepath) -> bool {
// Los archivos que NO van al pack:
// - Archivos de config/ (ahora están fuera de data/)
// - Archivos con absolute=true en assets.txt
// - Archivos de sistema (${SYSTEM_FOLDER})
if (filepath.find("/config/") != std::string::npos ||
filepath.find("config/") == 0) {
filepath.starts_with("config/")) {
return false;
}
if (filepath.find("/data/") != std::string::npos ||
filepath.find("data/") == 0) {
filepath.starts_with("data/")) {
return true;
}