refactor(log): migra els subsistemes restants i elimina iostream
Acaba la migració dels std::cout/cerr a Log::*:
- core/locale, core/ui/ui_config, core/rendering/{screen,text,gif,
surface, sprite/animated_sprite, sdl3gpu/*}.
- game/{options, debug_config, editor/editor_config, levels/level_manager,
map/{map,tilemap,paint_layer}, entities/entity_manager_loadlevel}.
Severitats coherents: warns per a configs absents amb fallback,
errors per a YAML malformat o E/S fallida, infos per a estats.
Resultat:
- 0 occurrences de std::cout/std::cerr a source/.
- Cap #include <iostream> orfà (eliminat de surface.cpp).
- Output funcional idèntic al històric; AEE_LOG filtra (ex.
`AEE_LOG=warn` només mostra warnings, `AEE_LOG=*:warn,Tag:info`
combina globals i overrides).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
5fce52e0ad
commit
c8882a3f6e
17 files changed
+83
-101
No files matched your search
@@ -1,11 +1,11 @@
|
|||||||
#include "core/locale/locale.hpp"
|
#include "core/locale/locale.hpp"
|
||||||
|
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <iostream>
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include "core/resources/resource_helper.hpp"
|
#include "core/resources/resource_helper.hpp"
|
||||||
#include "external/fkyaml_node.hpp"
|
#include "external/fkyaml_node.hpp"
|
||||||
|
#include "utils/log.hpp"
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
@@ -36,7 +36,7 @@ auto Locale::get() -> Locale& {
|
|||||||
void Locale::load(const std::string& file_path) {
|
void Locale::load(const std::string& file_path) {
|
||||||
auto bytes = Resource::Helper::loadFile(file_path);
|
auto bytes = Resource::Helper::loadFile(file_path);
|
||||||
if (bytes.empty()) {
|
if (bytes.empty()) {
|
||||||
std::cerr << "Locale: no s'ha pogut obrir " << file_path << '\n';
|
Log::error("Locale", "no s'ha pogut obrir {}", file_path);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -46,15 +46,15 @@ void Locale::load(const std::string& file_path) {
|
|||||||
auto yaml = fkyaml::node::deserialize(begin, end);
|
auto yaml = fkyaml::node::deserialize(begin, end);
|
||||||
strings_.clear();
|
strings_.clear();
|
||||||
flatten(yaml, "", strings_);
|
flatten(yaml, "", strings_);
|
||||||
std::cout << "Locale: " << strings_.size() << " traduccions des de " << file_path << '\n';
|
Log::info("Locale", "{} traduccions des de {}", strings_.size(), file_path);
|
||||||
} catch (const std::exception& e) {
|
} catch (const std::exception& e) {
|
||||||
std::cerr << "Locale: error parsejant " << file_path << ": " << e.what() << '\n';
|
Log::error("Locale", "error parsejant {}: {}", file_path, e.what());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
auto Locale::text(const std::string& key) const -> std::string {
|
auto Locale::text(const std::string& key) const -> std::string {
|
||||||
auto it = strings_.find(key);
|
auto it = strings_.find(key);
|
||||||
if (it != strings_.end()) { return it->second; }
|
if (it != strings_.end()) { return it->second; }
|
||||||
std::cerr << "Locale: clau no trobada: " << key << '\n';
|
Log::warn("Locale", "clau no trobada: {}", key);
|
||||||
return key;
|
return key;
|
||||||
}
|
}
|
||||||
@@ -1,10 +1,11 @@
|
|||||||
#include "core/rendering/gif.hpp"
|
#include "core/rendering/gif.hpp"
|
||||||
|
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <iostream>
|
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
#include "utils/log.hpp"
|
||||||
|
|
||||||
namespace GIF {
|
namespace GIF {
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
@@ -111,7 +112,7 @@ namespace GIF {
|
|||||||
while (cur_code != -1) {
|
while (cur_code != -1) {
|
||||||
out[dictionary[cur_code].len - 1] = dictionary[cur_code].byte;
|
out[dictionary[cur_code].len - 1] = dictionary[cur_code].byte;
|
||||||
if (dictionary[cur_code].prev == cur_code) {
|
if (dictionary[cur_code].prev == cur_code) {
|
||||||
std::cerr << "Internal error; self-reference detected." << '\n';
|
Log::error("GIF", "internal error; self-reference detected.");
|
||||||
throw std::runtime_error("Internal error in decompress: self-reference");
|
throw std::runtime_error("Internal error in decompress: self-reference");
|
||||||
}
|
}
|
||||||
cur_code = dictionary[cur_code].prev;
|
cur_code = dictionary[cur_code].prev;
|
||||||
@@ -155,8 +156,7 @@ namespace GIF {
|
|||||||
|
|
||||||
if (prev > -1 && code_length < LZW_MAX_CODE_LENGTH) {
|
if (prev > -1 && code_length < LZW_MAX_CODE_LENGTH) {
|
||||||
if (code > dictionary_ind) {
|
if (code > dictionary_ind) {
|
||||||
std::cerr << "code = " << std::hex << code
|
Log::error("GIF", "code = {:x}, but dictionary_ind = {}", code, dictionary_ind);
|
||||||
<< ", but dictionary_ind = " << dictionary_ind << '\n';
|
|
||||||
throw std::runtime_error("LZW error: code exceeds dictionary_ind.");
|
throw std::runtime_error("LZW error: code exceeds dictionary_ind.");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -167,8 +167,7 @@ namespace GIF {
|
|||||||
|
|
||||||
// Verifica que 'code' sea un índice válido antes de usarlo.
|
// Verifica que 'code' sea un índice válido antes de usarlo.
|
||||||
if (code < 0 || static_cast<size_t>(code) >= dictionary.size()) {
|
if (code < 0 || static_cast<size_t>(code) >= dictionary.size()) {
|
||||||
std::cerr << "Invalid LZW code " << code
|
Log::error("GIF", "invalid LZW code {}, dictionary size {}", code, dictionary.size());
|
||||||
<< ", dictionary size " << dictionary.size() << '\n';
|
|
||||||
throw std::runtime_error("LZW error: invalid code encountered");
|
throw std::runtime_error("LZW error: invalid code encountered");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -287,7 +286,7 @@ namespace GIF {
|
|||||||
} else if (block_type == IMAGE_DESCRIPTOR) {
|
} else if (block_type == IMAGE_DESCRIPTOR) {
|
||||||
return processImageDescriptor(buffer);
|
return processImageDescriptor(buffer);
|
||||||
} else {
|
} else {
|
||||||
std::cerr << "Unrecognized block type " << std::hex << static_cast<int>(block_type) << '\n';
|
Log::error("GIF", "unrecognized block type {:x}", static_cast<int>(block_type));
|
||||||
return std::vector<uint8_t>{};
|
return std::vector<uint8_t>{};
|
||||||
}
|
}
|
||||||
block_type = *buffer++;
|
block_type = *buffer++;
|
||||||
|
|||||||
@@ -6,13 +6,13 @@
|
|||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <iostream>
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <ranges>
|
#include <ranges>
|
||||||
|
|
||||||
#include "core/rendering/canvas.hpp"
|
#include "core/rendering/canvas.hpp"
|
||||||
#include "core/rendering/sdl3gpu/viewport.hpp"
|
#include "core/rendering/sdl3gpu/viewport.hpp"
|
||||||
#include "utils/defines.hpp"
|
#include "utils/defines.hpp"
|
||||||
|
#include "utils/log.hpp"
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
@@ -112,11 +112,11 @@ void Screen::createSdl() {
|
|||||||
backend->setVSync(config_.vsync);
|
backend->setVSync(config_.vsync);
|
||||||
if (backend->init(window_, canvas_width_, canvas_height_)) {
|
if (backend->init(window_, canvas_width_, canvas_height_)) {
|
||||||
gpu_driver_ = backend->getDriverName();
|
gpu_driver_ = backend->getDriverName();
|
||||||
std::cout << "Screen: path GPU actiu (driver: " << gpu_driver_ << ")\n";
|
Log::info("Screen", "path GPU actiu (driver: {})", gpu_driver_);
|
||||||
shader_backend_ = std::move(backend);
|
shader_backend_ = std::move(backend);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
std::cerr << "Screen: GPU no disponible, fallback a SDL_Renderer\n";
|
Log::warn("Screen", "GPU no disponible, fallback a SDL_Renderer");
|
||||||
}
|
}
|
||||||
gpu_driver_ = "sdl";
|
gpu_driver_ = "sdl";
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
#include "core/rendering/sdl3gpu/pipelines/crtpi_pipeline.hpp"
|
#include "core/rendering/sdl3gpu/pipelines/crtpi_pipeline.hpp"
|
||||||
|
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <iostream>
|
|
||||||
|
|
||||||
#include "core/rendering/sdl3gpu/shader_factory.hpp"
|
#include "core/rendering/sdl3gpu/shader_factory.hpp"
|
||||||
#include "core/rendering/sdl3gpu/viewport.hpp"
|
#include "core/rendering/sdl3gpu/viewport.hpp"
|
||||||
|
#include "utils/log.hpp"
|
||||||
|
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
#include "core/rendering/sdl3gpu/msl/crtpi_frag.msl.h"
|
#include "core/rendering/sdl3gpu/msl/crtpi_frag.msl.h"
|
||||||
@@ -29,7 +29,7 @@ namespace Rendering {
|
|||||||
SDL_GPUShader* frag = createShaderSPIRV(device_, kcrtpi_frag_spv, kcrtpi_frag_spv_size, "main", SDL_GPU_SHADERSTAGE_FRAGMENT, 1, 1);
|
SDL_GPUShader* frag = createShaderSPIRV(device_, kcrtpi_frag_spv, kcrtpi_frag_spv_size, "main", SDL_GPU_SHADERSTAGE_FRAGMENT, 1, 1);
|
||||||
#endif
|
#endif
|
||||||
if (vert == nullptr || frag == nullptr) {
|
if (vert == nullptr || frag == nullptr) {
|
||||||
std::cerr << "CrtPiPipeline: creació de shaders fallida: " << SDL_GetError() << '\n';
|
Log::error("CrtPiPipeline", "creació de shaders fallida: {}", SDL_GetError());
|
||||||
if (vert != nullptr) { SDL_ReleaseGPUShader(device_, vert); }
|
if (vert != nullptr) { SDL_ReleaseGPUShader(device_, vert); }
|
||||||
if (frag != nullptr) { SDL_ReleaseGPUShader(device_, frag); }
|
if (frag != nullptr) { SDL_ReleaseGPUShader(device_, frag); }
|
||||||
return false;
|
return false;
|
||||||
@@ -57,7 +57,7 @@ namespace Rendering {
|
|||||||
SDL_ReleaseGPUShader(device_, frag);
|
SDL_ReleaseGPUShader(device_, frag);
|
||||||
|
|
||||||
if (pipeline_ == nullptr) {
|
if (pipeline_ == nullptr) {
|
||||||
std::cerr << "CrtPiPipeline: creació del pipeline ha fallat: " << SDL_GetError() << '\n';
|
Log::error("CrtPiPipeline", "creació del pipeline ha fallat: {}", SDL_GetError());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,10 +2,10 @@
|
|||||||
|
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <iostream>
|
|
||||||
|
|
||||||
#include "core/rendering/sdl3gpu/shader_factory.hpp"
|
#include "core/rendering/sdl3gpu/shader_factory.hpp"
|
||||||
#include "core/rendering/sdl3gpu/viewport.hpp"
|
#include "core/rendering/sdl3gpu/viewport.hpp"
|
||||||
|
#include "utils/log.hpp"
|
||||||
|
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
#include "core/rendering/sdl3gpu/msl/postfx_frag.msl.h"
|
#include "core/rendering/sdl3gpu/msl/postfx_frag.msl.h"
|
||||||
@@ -59,11 +59,11 @@ namespace Rendering {
|
|||||||
const char* driver = preferred_driver_.empty() ? nullptr : preferred_driver_.c_str();
|
const char* driver = preferred_driver_.empty() ? nullptr : preferred_driver_.c_str();
|
||||||
device_ = SDL_CreateGPUDevice(FORMAT, false, driver);
|
device_ = SDL_CreateGPUDevice(FORMAT, false, driver);
|
||||||
if (device_ == nullptr) {
|
if (device_ == nullptr) {
|
||||||
std::cerr << "SDL3GPUShader: SDL_CreateGPUDevice ha fallat: " << SDL_GetError() << '\n';
|
Log::error("SDL3GPUShader", "SDL_CreateGPUDevice ha fallat: {}", SDL_GetError());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!SDL_ClaimWindowForGPUDevice(device_, window_)) {
|
if (!SDL_ClaimWindowForGPUDevice(device_, window_)) {
|
||||||
std::cerr << "SDL3GPUShader: SDL_ClaimWindowForGPUDevice ha fallat: " << SDL_GetError() << '\n';
|
Log::error("SDL3GPUShader", "SDL_ClaimWindowForGPUDevice ha fallat: {}", SDL_GetError());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
SDL_SetGPUSwapchainParameters(device_, window_, SDL_GPU_SWAPCHAINCOMPOSITION_SDR, bestPresentMode(vsync_));
|
SDL_SetGPUSwapchainParameters(device_, window_, SDL_GPU_SWAPCHAINCOMPOSITION_SDR, bestPresentMode(vsync_));
|
||||||
@@ -82,7 +82,7 @@ namespace Rendering {
|
|||||||
fragment_shader_ = createShaderSPIRV(device_, kpostfx_frag_spv, kpostfx_frag_spv_size, "main", SDL_GPU_SHADERSTAGE_FRAGMENT, 1, 1);
|
fragment_shader_ = createShaderSPIRV(device_, kpostfx_frag_spv, kpostfx_frag_spv_size, "main", SDL_GPU_SHADERSTAGE_FRAGMENT, 1, 1);
|
||||||
#endif
|
#endif
|
||||||
if (vertex_shader_ == nullptr || fragment_shader_ == nullptr) {
|
if (vertex_shader_ == nullptr || fragment_shader_ == nullptr) {
|
||||||
std::cerr << "SDL3GPUShader: SDL_CreateGPUShader ha fallat: " << SDL_GetError() << '\n';
|
Log::error("SDL3GPUShader", "SDL_CreateGPUShader ha fallat: {}", SDL_GetError());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@@ -105,7 +105,7 @@ namespace Rendering {
|
|||||||
|
|
||||||
pipeline_ = SDL_CreateGPUGraphicsPipeline(device_, &info);
|
pipeline_ = SDL_CreateGPUGraphicsPipeline(device_, &info);
|
||||||
if (pipeline_ == nullptr) {
|
if (pipeline_ == nullptr) {
|
||||||
std::cerr << "SDL3GPUShader: SDL_CreateGPUGraphicsPipeline ha fallat: " << SDL_GetError() << '\n';
|
Log::error("SDL3GPUShader", "SDL_CreateGPUGraphicsPipeline ha fallat: {}", SDL_GetError());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@@ -137,7 +137,7 @@ namespace Rendering {
|
|||||||
sampler_ = SDL_CreateGPUSampler(device_, &samp_info);
|
sampler_ = SDL_CreateGPUSampler(device_, &samp_info);
|
||||||
|
|
||||||
if (scene_texture_ == nullptr || upload_buffer_ == nullptr || sampler_ == nullptr) {
|
if (scene_texture_ == nullptr || upload_buffer_ == nullptr || sampler_ == nullptr) {
|
||||||
std::cerr << "SDL3GPUShader: creació de recursos GPU ha fallat: " << SDL_GetError() << '\n';
|
Log::error("SDL3GPUShader", "creació de recursos GPU ha fallat: {}", SDL_GetError());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
#include "core/rendering/sprite/animated_sprite.hpp"
|
#include "core/rendering/sprite/animated_sprite.hpp"
|
||||||
|
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <iostream>
|
|
||||||
#include <numeric>
|
#include <numeric>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
#include "core/rendering/surface.hpp"
|
#include "core/rendering/surface.hpp"
|
||||||
#include "core/resources/resource_cache.hpp"
|
#include "core/resources/resource_cache.hpp"
|
||||||
|
#include "utils/log.hpp"
|
||||||
|
|
||||||
// El parser pure de YAML d'animacions (parseAnimationsFromYaml + helpers)
|
// El parser pure de YAML d'animacions (parseAnimationsFromYaml + helpers)
|
||||||
// viu a `animated_sprite_parser.cpp` perquè és testable sense Surface ni
|
// viu a `animated_sprite_parser.cpp` perquè és testable sense Surface ni
|
||||||
@@ -74,10 +74,10 @@ AnimatedSprite::AnimatedSprite(const AnimationResource& cached_data) {
|
|||||||
if (!first.frames.empty()) { setClip(first.frames[0].rect); }
|
if (!first.frames.empty()) { setClip(first.frames[0].rect); }
|
||||||
}
|
}
|
||||||
} catch (const fkyaml::exception& e) {
|
} catch (const fkyaml::exception& e) {
|
||||||
std::cerr << "YAML parsing error in animation " << cached_data.name << ": " << e.what() << '\n';
|
Log::error("AnimatedSprite", "YAML parsing error in animation {}: {}", cached_data.name, e.what());
|
||||||
throw;
|
throw;
|
||||||
} catch (const std::exception& e) {
|
} catch (const std::exception& e) {
|
||||||
std::cerr << "Error loading animation " << cached_data.name << ": " << e.what() << '\n';
|
Log::error("AnimatedSprite", "Error loading animation {}: {}", cached_data.name, e.what());
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -140,7 +140,7 @@ void AnimatedSprite::setCurrentAnimation(const std::string& name) {
|
|||||||
if (current_animation_ == name) { return; }
|
if (current_animation_ == name) { return; }
|
||||||
auto it = animations_.find(name);
|
auto it = animations_.find(name);
|
||||||
if (it == animations_.end()) {
|
if (it == animations_.end()) {
|
||||||
std::cout << "** Warning: could not find \"" << name << "\" animation" << '\n';
|
Log::warn("AnimatedSprite", "could not find \"{}\" animation", name);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
current_animation_ = name;
|
current_animation_ = name;
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <iostream>
|
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,6 @@
|
|||||||
#include <SDL3/SDL.h>
|
#include <SDL3/SDL.h>
|
||||||
|
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
#include <iostream>
|
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
#include <string>
|
#include <string>
|
||||||
@@ -11,6 +10,7 @@
|
|||||||
#include "core/rendering/sprite/sprite.hpp"
|
#include "core/rendering/sprite/sprite.hpp"
|
||||||
#include "core/rendering/surface.hpp"
|
#include "core/rendering/surface.hpp"
|
||||||
#include "core/resources/resource_helper.hpp"
|
#include "core/resources/resource_helper.hpp"
|
||||||
|
#include "utils/log.hpp"
|
||||||
#include "utils/utils.hpp"
|
#include "utils/utils.hpp"
|
||||||
|
|
||||||
// Decodifica el pròxim codepoint UTF-8 de la cadena i avança 'pos' al byte
|
// Decodifica el pròxim codepoint UTF-8 de la cadena i avança 'pos' al byte
|
||||||
@@ -55,7 +55,7 @@ auto Text::loadTextFile(const std::string& file_path) -> std::shared_ptr<File> {
|
|||||||
|
|
||||||
auto file_data = Resource::Helper::loadFile(file_path);
|
auto file_data = Resource::Helper::loadFile(file_path);
|
||||||
if (file_data.empty()) {
|
if (file_data.empty()) {
|
||||||
std::cerr << "Error: Fitxer no trobat " << getFileName(file_path) << '\n';
|
Log::error("Text File", "fitxer no trobat: {}", getFileName(file_path));
|
||||||
throw std::runtime_error("Fitxer no trobat: " + getFileName(file_path));
|
throw std::runtime_error("Fitxer no trobat: " + getFileName(file_path));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
#include "core/ui/ui_config.hpp"
|
#include "core/ui/ui_config.hpp"
|
||||||
|
|
||||||
#include <iostream>
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <string_view>
|
#include <string_view>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
@@ -9,6 +8,7 @@
|
|||||||
#include "external/fkyaml_node.hpp"
|
#include "external/fkyaml_node.hpp"
|
||||||
#include "utils/defaults.hpp"
|
#include "utils/defaults.hpp"
|
||||||
#include "utils/easing.hpp"
|
#include "utils/easing.hpp"
|
||||||
|
#include "utils/log.hpp"
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
@@ -27,7 +27,7 @@ namespace {
|
|||||||
if (!node.contains(key)) { return; }
|
if (!node.contains(key)) { return; }
|
||||||
const int VALUE = node[key].get_value<int>();
|
const int VALUE = node[key].get_value<int>();
|
||||||
if (VALUE < 0 || VALUE > 255) {
|
if (VALUE < 0 || VALUE > 255) {
|
||||||
std::cerr << "UiConfig: índex '" << key << "'=" << VALUE << " fora de rang 0..255 — ignorat\n";
|
Log::warn("UiConfig", "índex '{}'={} fora de rang 0..255 — ignorat", key, VALUE);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
dst = static_cast<Uint8>(VALUE);
|
dst = static_cast<Uint8>(VALUE);
|
||||||
@@ -183,7 +183,7 @@ auto UiConfig::curveByName(const std::string& name) -> CurveFn {
|
|||||||
const auto& reg = curveRegistry();
|
const auto& reg = curveRegistry();
|
||||||
const auto IT = reg.find(name);
|
const auto IT = reg.find(name);
|
||||||
if (IT == reg.end()) {
|
if (IT == reg.end()) {
|
||||||
std::cerr << "UiConfig: corba '" << name << "' desconeguda — s'usa linear\n";
|
Log::warn("UiConfig", "corba '{}' desconeguda — s'usa linear", name);
|
||||||
return &Easing::linear;
|
return &Easing::linear;
|
||||||
}
|
}
|
||||||
return IT->second;
|
return IT->second;
|
||||||
@@ -192,7 +192,7 @@ auto UiConfig::curveByName(const std::string& name) -> CurveFn {
|
|||||||
void UiConfig::load(const std::string& file_path) {
|
void UiConfig::load(const std::string& file_path) {
|
||||||
auto bytes = Resource::Helper::loadFile(file_path);
|
auto bytes = Resource::Helper::loadFile(file_path);
|
||||||
if (bytes.empty()) {
|
if (bytes.empty()) {
|
||||||
std::cerr << "UiConfig: no s'ha pogut obrir " << file_path << " — s'usaran els defaults compilats\n";
|
Log::warn("UiConfig", "no s'ha pogut obrir {} — s'usaran els defaults compilats", file_path);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -345,8 +345,8 @@ void UiConfig::load(const std::string& file_path) {
|
|||||||
readCurve(n, "slide_out_curve", notifier_.slide_out_curve);
|
readCurve(n, "slide_out_curve", notifier_.slide_out_curve);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::cout << "UiConfig: carregat des de " << file_path << '\n';
|
Log::info("UiConfig", "carregat des de {}", file_path);
|
||||||
} catch (const std::exception& e) {
|
} catch (const std::exception& e) {
|
||||||
std::cerr << "UiConfig: error parsejant " << file_path << ": " << e.what() << '\n';
|
Log::error("UiConfig", "error parsejant {}: {}", file_path, e.what());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -3,11 +3,11 @@
|
|||||||
#include <exception>
|
#include <exception>
|
||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <iostream>
|
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include "external/fkyaml_node.hpp"
|
#include "external/fkyaml_node.hpp"
|
||||||
|
#include "utils/log.hpp"
|
||||||
|
|
||||||
namespace DebugConfig {
|
namespace DebugConfig {
|
||||||
|
|
||||||
@@ -53,12 +53,12 @@ namespace DebugConfig {
|
|||||||
if (!yaml.contains("start_scene")) { return StartScene::GAME; }
|
if (!yaml.contains("start_scene")) { return StartScene::GAME; }
|
||||||
const auto RAW = yaml["start_scene"].get_value<std::string>();
|
const auto RAW = yaml["start_scene"].get_value<std::string>();
|
||||||
if (!isKnown(RAW)) {
|
if (!isKnown(RAW)) {
|
||||||
std::cerr << "debug.yaml: start_scene \"" << RAW << "\" invàlid, arrancant a GAME\n";
|
Log::warn("debug.yaml", "start_scene \"{}\" invàlid, arrancant a GAME", RAW);
|
||||||
return StartScene::GAME;
|
return StartScene::GAME;
|
||||||
}
|
}
|
||||||
return fromName(RAW);
|
return fromName(RAW);
|
||||||
} catch (const std::exception& e) {
|
} catch (const std::exception& e) {
|
||||||
std::cerr << "debug.yaml: error parsejant: " << e.what() << " — arrancant a GAME\n";
|
Log::error("debug.yaml", "error parsejant: {} — arrancant a GAME", e.what());
|
||||||
return StartScene::GAME;
|
return StartScene::GAME;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -72,7 +72,7 @@ namespace DebugConfig {
|
|||||||
}
|
}
|
||||||
const auto CONTENT = readFile(file_path);
|
const auto CONTENT = readFile(file_path);
|
||||||
if (CONTENT.empty()) {
|
if (CONTENT.empty()) {
|
||||||
std::cerr << "debug.yaml: fitxer buit a " << file_path << ", arrancant a GAME\n";
|
Log::warn("debug.yaml", "fitxer buit a {}, arrancant a GAME", file_path);
|
||||||
return StartScene::GAME;
|
return StartScene::GAME;
|
||||||
}
|
}
|
||||||
return parseStartScene(CONTENT);
|
return parseStartScene(CONTENT);
|
||||||
@@ -85,12 +85,12 @@ namespace DebugConfig {
|
|||||||
if (!yaml.contains("starting_players")) { return StartingPlayers::BOTH; }
|
if (!yaml.contains("starting_players")) { return StartingPlayers::BOTH; }
|
||||||
const auto RAW = yaml["starting_players"].get_value<std::string>();
|
const auto RAW = yaml["starting_players"].get_value<std::string>();
|
||||||
if (!isKnownPlayers(RAW)) {
|
if (!isKnownPlayers(RAW)) {
|
||||||
std::cerr << "debug.yaml: starting_players \"" << RAW << "\" invàlid, arrancant amb BOTH\n";
|
Log::warn("debug.yaml", "starting_players \"{}\" invàlid, arrancant amb BOTH", RAW);
|
||||||
return StartingPlayers::BOTH;
|
return StartingPlayers::BOTH;
|
||||||
}
|
}
|
||||||
return playersFromName(RAW);
|
return playersFromName(RAW);
|
||||||
} catch (const std::exception& e) {
|
} catch (const std::exception& e) {
|
||||||
std::cerr << "debug.yaml: error parsejant starting_players: " << e.what() << " — arrancant amb BOTH\n";
|
Log::error("debug.yaml", "error parsejant starting_players: {} — arrancant amb BOTH", e.what());
|
||||||
return StartingPlayers::BOTH;
|
return StartingPlayers::BOTH;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -110,7 +110,7 @@ namespace DebugConfig {
|
|||||||
if (!yaml.contains("starting_level")) { return std::nullopt; }
|
if (!yaml.contains("starting_level")) { return std::nullopt; }
|
||||||
const auto& sl = yaml["starting_level"];
|
const auto& sl = yaml["starting_level"];
|
||||||
if (!sl.contains("pyramid") || !sl.contains("room")) {
|
if (!sl.contains("pyramid") || !sl.contains("room")) {
|
||||||
std::cerr << "debug.yaml: starting_level necessita els camps `pyramid` i `room` — ignorat\n";
|
Log::warn("debug.yaml", "starting_level necessita els camps `pyramid` i `room` — ignorat");
|
||||||
return std::nullopt;
|
return std::nullopt;
|
||||||
}
|
}
|
||||||
return StartingLevel{
|
return StartingLevel{
|
||||||
@@ -118,7 +118,7 @@ namespace DebugConfig {
|
|||||||
.room = sl["room"].get_value<int>(),
|
.room = sl["room"].get_value<int>(),
|
||||||
};
|
};
|
||||||
} catch (const std::exception& e) {
|
} catch (const std::exception& e) {
|
||||||
std::cerr << "debug.yaml: error parsejant starting_level: " << e.what() << " — ignorat\n";
|
Log::error("debug.yaml", "error parsejant starting_level: {} — ignorat", e.what());
|
||||||
return std::nullopt;
|
return std::nullopt;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -162,7 +162,7 @@ namespace DebugConfig {
|
|||||||
if (std::filesystem::exists(file_path, error)) { return; }
|
if (std::filesystem::exists(file_path, error)) { return; }
|
||||||
std::ofstream file(file_path);
|
std::ofstream file(file_path);
|
||||||
if (!file) {
|
if (!file) {
|
||||||
std::cerr << "debug.yaml: no s'ha pogut crear " << file_path << '\n';
|
Log::error("debug.yaml", "no s'ha pogut crear {}", file_path);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
file << "# debug.yaml — ajust personal de dev (no versionat).\n";
|
file << "# debug.yaml — ajust personal de dev (no versionat).\n";
|
||||||
@@ -173,7 +173,7 @@ namespace DebugConfig {
|
|||||||
file << "# clau, comença a la primera (P1-R1).\n";
|
file << "# clau, comença a la primera (P1-R1).\n";
|
||||||
file << "start_scene: GAME\n";
|
file << "start_scene: GAME\n";
|
||||||
file << "starting_players: BOTH\n";
|
file << "starting_players: BOTH\n";
|
||||||
std::cout << "debug.yaml: creat a " << file_path << " amb start_scene=GAME starting_players=BOTH\n";
|
Log::info("debug.yaml", "creat a {} amb start_scene=GAME starting_players=BOTH", file_path);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace DebugConfig
|
} // namespace DebugConfig
|
||||||
@@ -3,13 +3,13 @@
|
|||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
|
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <iostream>
|
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include "core/resources/resource_helper.hpp"
|
#include "core/resources/resource_helper.hpp"
|
||||||
#include "external/fkyaml_node.hpp"
|
#include "external/fkyaml_node.hpp"
|
||||||
#include "utils/defaults.hpp"
|
#include "utils/defaults.hpp"
|
||||||
|
#include "utils/log.hpp"
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
@@ -34,7 +34,7 @@ namespace {
|
|||||||
if (!s.empty() && s.front() == '#') { s.erase(0, 1); }
|
if (!s.empty() && s.front() == '#') { s.erase(0, 1); }
|
||||||
dst = static_cast<std::uint32_t>(std::stoul(s, nullptr, 0));
|
dst = static_cast<std::uint32_t>(std::stoul(s, nullptr, 0));
|
||||||
} catch (const std::exception& e) {
|
} catch (const std::exception& e) {
|
||||||
std::cerr << "EditorConfig: color '" << key << "' invàlid (" << e.what() << ") — ignorat\n";
|
Log::warn("EditorConfig", "color '{}' invàlid ({}) — ignorat", key, e.what());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -56,7 +56,7 @@ auto EditorConfig::get() -> EditorConfig& {
|
|||||||
void EditorConfig::load(const std::string& file_path) {
|
void EditorConfig::load(const std::string& file_path) {
|
||||||
auto bytes = Resource::Helper::loadFile(file_path);
|
auto bytes = Resource::Helper::loadFile(file_path);
|
||||||
if (bytes.empty()) {
|
if (bytes.empty()) {
|
||||||
std::cerr << "EditorConfig: no s'ha pogut obrir " << file_path << " — s'usaran els defaults compilats\n";
|
Log::warn("EditorConfig", "no s'ha pogut obrir {} — s'usaran els defaults compilats", file_path);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
@@ -76,9 +76,9 @@ void EditorConfig::load(const std::string& file_path) {
|
|||||||
readArgb(c, "picker_hover", picker_hover_argb_);
|
readArgb(c, "picker_hover", picker_hover_argb_);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::cout << "EditorConfig: carregat des de " << file_path << '\n';
|
Log::info("EditorConfig", "carregat des de {}", file_path);
|
||||||
} catch (const std::exception& e) {
|
} catch (const std::exception& e) {
|
||||||
std::cerr << "EditorConfig: error parsejant " << file_path << ": " << e.what() << '\n';
|
Log::error("EditorConfig", "error parsejant {}: {}", file_path, e.what());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,6 @@
|
|||||||
// stand-alone) enllacen `entity_manager.cpp` sense arrossegar aquest fitxer.
|
// stand-alone) enllacen `entity_manager.cpp` sense arrossegar aquest fitxer.
|
||||||
|
|
||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
#include <iostream>
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
@@ -22,6 +21,7 @@
|
|||||||
#include "game/entities/player.hpp"
|
#include "game/entities/player.hpp"
|
||||||
#include "game/map/map.hpp"
|
#include "game/map/map.hpp"
|
||||||
#include "utils/defaults.hpp"
|
#include "utils/defaults.hpp"
|
||||||
|
#include "utils/log.hpp"
|
||||||
|
|
||||||
// Render centralitzat al manager per confinar la dependència cap a
|
// Render centralitzat al manager per confinar la dependència cap a
|
||||||
// `Surface`. Les entitats exposen `getSurface()` + `getPixelRect()` i el
|
// `Surface`. Les entitats exposen `getSurface()` + `getPixelRect()` i el
|
||||||
@@ -237,12 +237,12 @@ namespace {
|
|||||||
try {
|
try {
|
||||||
tmpl = EntityLoader::loadTemplate(type);
|
tmpl = EntityLoader::loadTemplate(type);
|
||||||
} catch (const std::exception& e) {
|
} catch (const std::exception& e) {
|
||||||
std::cerr << "EntityManager: " << e.what() << '\n';
|
Log::error("EntityManager", "{}", e.what());
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
auto entity = EntityFactory::instance().create(type, tmpl);
|
auto entity = EntityFactory::instance().create(type, tmpl);
|
||||||
if (entity == nullptr) {
|
if (entity == nullptr) {
|
||||||
std::cerr << "EntityManager: tipus desconegut '" << type << "'\n";
|
Log::error("EntityManager", "tipus desconegut '{}'", type);
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
sprite_out = readSpriteInfo(tmpl, type);
|
sprite_out = readSpriteInfo(tmpl, type);
|
||||||
@@ -267,7 +267,7 @@ namespace {
|
|||||||
namespace {
|
namespace {
|
||||||
auto placeSarcophagus(EntityManager& manager, std::unique_ptr<Entity> entity, const SpriteInfo& sprite, const fkyaml::node& spawn) -> bool {
|
auto placeSarcophagus(EntityManager& manager, std::unique_ptr<Entity> entity, const SpriteInfo& sprite, const fkyaml::node& spawn) -> bool {
|
||||||
if (!spawn.contains("sarc_position")) {
|
if (!spawn.contains("sarc_position")) {
|
||||||
std::cerr << "EntityManager: sarcophagus sense sarc_position\n";
|
Log::error("EntityManager", "sarcophagus sense sarc_position");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
const auto& sp = spawn["sarc_position"];
|
const auto& sp = spawn["sarc_position"];
|
||||||
@@ -304,7 +304,7 @@ namespace {
|
|||||||
// un `Sarcophagus`. Usant el retorn de `release` al ctor del nou
|
// un `Sarcophagus`. Usant el retorn de `release` al ctor del nou
|
||||||
// `unique_ptr` evitem el lint `bugprone-unused-return-value`.
|
// `unique_ptr` evitem el lint `bugprone-unused-return-value`.
|
||||||
if (dynamic_cast<Sarcophagus*>(entity.get()) == nullptr) {
|
if (dynamic_cast<Sarcophagus*>(entity.get()) == nullptr) {
|
||||||
std::cerr << "EntityManager: la factory no ha creat un Sarcophagus\n";
|
Log::error("EntityManager", "la factory no ha creat un Sarcophagus");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
std::unique_ptr<Sarcophagus> sarc(static_cast<Sarcophagus*>(entity.release()));
|
std::unique_ptr<Sarcophagus> sarc(static_cast<Sarcophagus*>(entity.release()));
|
||||||
@@ -323,7 +323,7 @@ namespace {
|
|||||||
// queden tapats — comportament intencional.
|
// queden tapats — comportament intencional.
|
||||||
auto placeDoor(EntityManager& manager, std::unique_ptr<Entity> entity, const SpriteInfo& sprite) -> bool {
|
auto placeDoor(EntityManager& manager, std::unique_ptr<Entity> entity, const SpriteInfo& sprite) -> bool {
|
||||||
if (Map::door_col <= 0 || Map::tile_size <= 0) {
|
if (Map::door_col <= 0 || Map::tile_size <= 0) {
|
||||||
std::cerr << "EntityManager: door requereix `geometry.door_col` definit al mapa\n";
|
Log::error("EntityManager", "door requereix `geometry.door_col` definit al mapa");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
const float CENTER_X = static_cast<float>((Map::door_col * Map::tile_size) + Map::tilemap_origin_x) + (static_cast<float>(Map::tile_size) / 2.0F);
|
const float CENTER_X = static_cast<float>((Map::door_col * Map::tile_size) + Map::tilemap_origin_x) + (static_cast<float>(Map::tile_size) / 2.0F);
|
||||||
@@ -343,7 +343,7 @@ namespace {
|
|||||||
|
|
||||||
auto placeGeneric(EntityManager& manager, std::unique_ptr<Entity> entity, const std::string& type, const SpriteInfo& sprite, const std::string& anchor, const fkyaml::node& spawn) -> bool {
|
auto placeGeneric(EntityManager& manager, std::unique_ptr<Entity> entity, const std::string& type, const SpriteInfo& sprite, const std::string& anchor, const fkyaml::node& spawn) -> bool {
|
||||||
if (!spawn.contains("position")) {
|
if (!spawn.contains("position")) {
|
||||||
std::cerr << "EntityManager: " << type << " sense position\n";
|
Log::error("EntityManager", "{} sense position", type);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
const auto& p = spawn["position"];
|
const auto& p = spawn["position"];
|
||||||
@@ -444,10 +444,8 @@ void EntityManager::loadFromLevel(const std::string& level_yaml_path) {
|
|||||||
++decal_broadcast;
|
++decal_broadcast;
|
||||||
}
|
}
|
||||||
if (decal_broadcast > 0) {
|
if (decal_broadcast > 0) {
|
||||||
std::cout << "EntityManager: " << decal_broadcast
|
Log::info("EntityManager", "{} tile_painted broadcast inicial (decals de sòl)", decal_broadcast);
|
||||||
<< " tile_painted broadcast inicial (decals de sòl)\n";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::cout << "EntityManager: " << LOADED << " entitats carregades des de "
|
Log::info("EntityManager", "{} entitats carregades des de {}", LOADED, level_yaml_path);
|
||||||
<< level_yaml_path << '\n';
|
|
||||||
}
|
}
|
||||||
@@ -1,13 +1,13 @@
|
|||||||
#include "game/levels/level_manager.hpp"
|
#include "game/levels/level_manager.hpp"
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <iostream>
|
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
#include "core/resources/resource_helper.hpp"
|
#include "core/resources/resource_helper.hpp"
|
||||||
#include "external/fkyaml_node.hpp"
|
#include "external/fkyaml_node.hpp"
|
||||||
#include "utils/defaults.hpp"
|
#include "utils/defaults.hpp"
|
||||||
|
#include "utils/log.hpp"
|
||||||
|
|
||||||
namespace Levels {
|
namespace Levels {
|
||||||
|
|
||||||
@@ -46,8 +46,7 @@ namespace Levels {
|
|||||||
throw std::runtime_error("LevelManager: la seqüència de " + PATH + " és buida");
|
throw std::runtime_error("LevelManager: la seqüència de " + PATH + " és buida");
|
||||||
}
|
}
|
||||||
index_ = 0;
|
index_ = 0;
|
||||||
std::cout << "LevelManager: " << entries_.size() << " sales carregades de "
|
Log::info("LevelManager", "{} sales carregades de {} (començant a {})", entries_.size(), PATH, currentLabel());
|
||||||
<< PATH << " (començant a " << currentLabel() << ")\n";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
auto LevelManager::currentPath() const -> const std::string& {
|
auto LevelManager::currentPath() const -> const std::string& {
|
||||||
@@ -67,22 +66,20 @@ namespace Levels {
|
|||||||
auto LevelManager::advance() -> bool {
|
auto LevelManager::advance() -> bool {
|
||||||
if (index_ + 1 >= count()) { return false; }
|
if (index_ + 1 >= count()) { return false; }
|
||||||
++index_;
|
++index_;
|
||||||
std::cout << "LevelManager: avança a " << currentLabel()
|
Log::info("LevelManager", "avança a {} ({})", currentLabel(), currentPath());
|
||||||
<< " (" << currentPath() << ")\n";
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void LevelManager::restart() {
|
void LevelManager::restart() {
|
||||||
index_ = 0;
|
index_ = 0;
|
||||||
std::cout << "LevelManager: restart a " << currentLabel() << '\n';
|
Log::info("LevelManager", "restart a {}", currentLabel());
|
||||||
}
|
}
|
||||||
|
|
||||||
void LevelManager::setIndex(int new_index) {
|
void LevelManager::setIndex(int new_index) {
|
||||||
const int CLAMPED = std::clamp(new_index, 0, count() - 1);
|
const int CLAMPED = std::clamp(new_index, 0, count() - 1);
|
||||||
if (CLAMPED != index_) {
|
if (CLAMPED != index_) {
|
||||||
index_ = CLAMPED;
|
index_ = CLAMPED;
|
||||||
std::cout << "LevelManager: setIndex(" << new_index << ") → "
|
Log::info("LevelManager", "setIndex({}) → {} ({})", new_index, currentLabel(), currentPath());
|
||||||
<< currentLabel() << " (" << currentPath() << ")\n";
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -90,14 +87,11 @@ namespace Levels {
|
|||||||
for (std::size_t i = 0; i < entries_.size(); ++i) {
|
for (std::size_t i = 0; i < entries_.size(); ++i) {
|
||||||
if (entries_[i].pyramid == pyramid && entries_[i].room == room) {
|
if (entries_[i].pyramid == pyramid && entries_[i].room == room) {
|
||||||
index_ = static_cast<int>(i);
|
index_ = static_cast<int>(i);
|
||||||
std::cout << "LevelManager: starting_point P" << pyramid << "-R" << room
|
Log::info("LevelManager", "starting_point P{}-R{} trobat a l'índex {} ({})", pyramid, room, i, currentPath());
|
||||||
<< " trobat a l'índex " << i << " (" << currentPath() << ")\n";
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
std::cerr << "LevelManager: starting_point P" << pyramid << "-R" << room
|
Log::warn("LevelManager", "starting_point P{}-R{} no trobat a levels.yaml — es manté l'índex actual ({})", pyramid, room, currentLabel());
|
||||||
<< " no trobat a levels.yaml — es manté l'índex actual ("
|
|
||||||
<< currentLabel() << ")\n";
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
#include "game/map/map.hpp"
|
#include "game/map/map.hpp"
|
||||||
|
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <iostream>
|
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
|
|
||||||
#include "core/resources/resource_helper.hpp"
|
#include "core/resources/resource_helper.hpp"
|
||||||
#include "external/fkyaml_node.hpp"
|
#include "external/fkyaml_node.hpp"
|
||||||
|
#include "utils/log.hpp"
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
@@ -90,11 +90,7 @@ namespace Map {
|
|||||||
// canviarà el flag a true quan transiti a OPEN.
|
// canviarà el flag a true quan transiti a OPEN.
|
||||||
door_open = false;
|
door_open = false;
|
||||||
|
|
||||||
std::cout << "Map: geometria " << grid_cols << "x" << grid_rows
|
Log::info("Map", "geometria {}x{} sarcs {}x{} pitch {}x{} door_col {} des de {}", grid_cols, grid_rows, sarc_w, sarc_h, pitch_x, pitch_y, door_col, yaml_path);
|
||||||
<< " sarcs " << sarc_w << "x" << sarc_h
|
|
||||||
<< " pitch " << pitch_x << "x" << pitch_y
|
|
||||||
<< " door_col " << door_col
|
|
||||||
<< " des de " << yaml_path << '\n';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
auto getSarcRect(int col, int row) -> SDL_FRect {
|
auto getSarcRect(int col, int row) -> SDL_FRect {
|
||||||
|
|||||||
@@ -3,7 +3,6 @@
|
|||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <iostream>
|
|
||||||
#include <variant>
|
#include <variant>
|
||||||
|
|
||||||
#include "core/rendering/screen.hpp"
|
#include "core/rendering/screen.hpp"
|
||||||
@@ -11,6 +10,7 @@
|
|||||||
#include "core/resources/resource_cache.hpp"
|
#include "core/resources/resource_cache.hpp"
|
||||||
#include "game/map/map.hpp"
|
#include "game/map/map.hpp"
|
||||||
#include "game/map/tilemap.hpp"
|
#include "game/map/tilemap.hpp"
|
||||||
|
#include "utils/log.hpp"
|
||||||
|
|
||||||
// CONTRACTE BUS DE PINTAT
|
// CONTRACTE BUS DE PINTAT
|
||||||
// -----------------------
|
// -----------------------
|
||||||
@@ -89,9 +89,7 @@ PaintLayer::PaintLayer(const Tilemap& tilemap, EventBus* bus)
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
std::cout << "PaintLayer: " << cols_ << "x" << rows_ << " tiles ("
|
Log::info("PaintLayer", "{}x{} tiles ({}x{} px), tileset {}", cols_, rows_, width_px_, height_px_, tileset_path_);
|
||||||
<< width_px_ << "x" << height_px_ << " px), tileset "
|
|
||||||
<< tileset_path_ << '\n';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PaintLayer::~PaintLayer() {
|
PaintLayer::~PaintLayer() {
|
||||||
|
|||||||
@@ -3,7 +3,6 @@
|
|||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <iostream>
|
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
@@ -12,6 +11,7 @@
|
|||||||
#include "core/resources/resource_cache.hpp"
|
#include "core/resources/resource_cache.hpp"
|
||||||
#include "core/resources/resource_helper.hpp"
|
#include "core/resources/resource_helper.hpp"
|
||||||
#include "external/fkyaml_node.hpp"
|
#include "external/fkyaml_node.hpp"
|
||||||
|
#include "utils/log.hpp"
|
||||||
|
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
#include "game/map/tilemap_writer.hpp"
|
#include "game/map/tilemap_writer.hpp"
|
||||||
@@ -97,8 +97,7 @@ Tilemap::Tilemap(const std::string& yaml_path) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::cout << "Tilemap: " << cols_ << "x" << rows_ << " tiles ("
|
Log::info("Tilemap", "{}x{} tiles ({}x{} px) des de {}", cols_, rows_, width_px_, height_px_, yaml_path);
|
||||||
<< width_px_ << "x" << height_px_ << " px) des de " << yaml_path << '\n';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
|
|||||||
+11
-12
@@ -3,7 +3,6 @@
|
|||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <array>
|
#include <array>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <iostream>
|
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <string_view>
|
#include <string_view>
|
||||||
@@ -12,6 +11,7 @@
|
|||||||
#include "core/input/gamepad_manager.hpp"
|
#include "core/input/gamepad_manager.hpp"
|
||||||
#include "external/fkyaml_node.hpp"
|
#include "external/fkyaml_node.hpp"
|
||||||
#include "utils/defines.hpp"
|
#include "utils/defines.hpp"
|
||||||
|
#include "utils/log.hpp"
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
@@ -104,7 +104,7 @@ namespace {
|
|||||||
std::ofstream dst(path + ".bak", std::ios::binary);
|
std::ofstream dst(path + ".bak", std::ios::binary);
|
||||||
if (!dst) { return; }
|
if (!dst) { return; }
|
||||||
dst << src.rdbuf();
|
dst << src.rdbuf();
|
||||||
std::cout << "Options: còpia de seguretat a " << path << ".bak\n";
|
Log::info("Options", "còpia de seguretat a {}.bak", path);
|
||||||
}
|
}
|
||||||
|
|
||||||
void parseWindow(const fkyaml::node& yaml) {
|
void parseWindow(const fkyaml::node& yaml) {
|
||||||
@@ -463,7 +463,7 @@ namespace {
|
|||||||
try {
|
try {
|
||||||
auto yaml = fkyaml::node::deserialize(CONTENT);
|
auto yaml = fkyaml::node::deserialize(CONTENT);
|
||||||
if (!yaml.contains("presets") || !yaml["presets"].is_sequence()) {
|
if (!yaml.contains("presets") || !yaml["presets"].is_sequence()) {
|
||||||
std::cout << "Options: " << kind_label << " manca `presets:`; reescrivint amb defaults.\n";
|
Log::warn("Options", "{} manca `presets:`; reescrivint amb defaults.", kind_label);
|
||||||
backupFile(path);
|
backupFile(path);
|
||||||
presets = defaults_fn();
|
presets = defaults_fn();
|
||||||
return save_fn();
|
return save_fn();
|
||||||
@@ -475,15 +475,15 @@ namespace {
|
|||||||
presets.push_back(preset);
|
presets.push_back(preset);
|
||||||
}
|
}
|
||||||
if (presets.empty()) {
|
if (presets.empty()) {
|
||||||
std::cout << "Options: " << kind_label << " sense presets; reescrivint amb defaults.\n";
|
Log::warn("Options", "{} sense presets; reescrivint amb defaults.", kind_label);
|
||||||
backupFile(path);
|
backupFile(path);
|
||||||
presets = defaults_fn();
|
presets = defaults_fn();
|
||||||
return save_fn();
|
return save_fn();
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
} catch (const std::exception& e) {
|
} catch (const std::exception& e) {
|
||||||
std::cout << "Options: error parsejant " << kind_label << ": " << e.what() << '\n';
|
Log::error("Options", "error parsejant {}: {}", kind_label, e.what());
|
||||||
std::cout << "Options: reescrivint el fitxer amb presets per defecte.\n";
|
Log::info("Options", "reescrivint el fitxer amb presets per defecte.");
|
||||||
backupFile(path);
|
backupFile(path);
|
||||||
presets = defaults_fn();
|
presets = defaults_fn();
|
||||||
return save_fn();
|
return save_fn();
|
||||||
@@ -655,8 +655,7 @@ namespace Options {
|
|||||||
// amb els defaults de la versió nova. El fitxer original queda
|
// amb els defaults de la versió nova. El fitxer original queda
|
||||||
// a `<path>.bak` per si l'usuari volia preservar tuning manual.
|
// a `<path>.bak` per si l'usuari volia preservar tuning manual.
|
||||||
if (file_version != Texts::VERSION) {
|
if (file_version != Texts::VERSION) {
|
||||||
std::cout << "Options: config.yaml versió \"" << file_version
|
Log::warn("Options", "config.yaml versió \"{}\" != \"{}\"; reescrivint amb defaults.", file_version, Texts::VERSION);
|
||||||
<< "\" != \"" << Texts::VERSION << "\"; reescrivint amb defaults.\n";
|
|
||||||
backupFile(g_config_file_path);
|
backupFile(g_config_file_path);
|
||||||
return saveToFile();
|
return saveToFile();
|
||||||
}
|
}
|
||||||
@@ -679,8 +678,8 @@ namespace Options {
|
|||||||
if (CHANGED) { saveToFile(); }
|
if (CHANGED) { saveToFile(); }
|
||||||
return true;
|
return true;
|
||||||
} catch (const std::exception& e) {
|
} catch (const std::exception& e) {
|
||||||
std::cout << "Options: error parsejant config.yaml: " << e.what() << '\n';
|
Log::error("Options", "error parsejant config.yaml: {}", e.what());
|
||||||
std::cout << "Options: reescrivint el fitxer amb defaults.\n";
|
Log::info("Options", "reescrivint el fitxer amb defaults.");
|
||||||
backupFile(g_config_file_path);
|
backupFile(g_config_file_path);
|
||||||
return saveToFile();
|
return saveToFile();
|
||||||
}
|
}
|
||||||
@@ -843,7 +842,7 @@ namespace Options {
|
|||||||
const auto IT = std::ranges::find_if(g_crtpi_presets,
|
const auto IT = std::ranges::find_if(g_crtpi_presets,
|
||||||
[](const CrtPiPreset& preset) { return preset.name == g_video.shader.current_crtpi_preset; });
|
[](const CrtPiPreset& preset) { return preset.name == g_video.shader.current_crtpi_preset; });
|
||||||
if (IT == g_crtpi_presets.end()) {
|
if (IT == g_crtpi_presets.end()) {
|
||||||
std::cout << "Options: preset CrtPi \"" << g_video.shader.current_crtpi_preset << "\" no trobat; aplicant defaults.\n";
|
Log::warn("Options", "preset CrtPi \"{}\" no trobat; aplicant defaults.", g_video.shader.current_crtpi_preset);
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
@@ -871,7 +870,7 @@ namespace Options {
|
|||||||
const auto IT = std::ranges::find_if(g_postfx_presets,
|
const auto IT = std::ranges::find_if(g_postfx_presets,
|
||||||
[](const PostFXPreset& preset) { return preset.name == g_video.shader.current_postfx_preset; });
|
[](const PostFXPreset& preset) { return preset.name == g_video.shader.current_postfx_preset; });
|
||||||
if (IT == g_postfx_presets.end()) {
|
if (IT == g_postfx_presets.end()) {
|
||||||
std::cout << "Options: preset PostFX \"" << g_video.shader.current_postfx_preset << "\" no trobat; aplicant passthrough.\n";
|
Log::warn("Options", "preset PostFX \"{}\" no trobat; aplicant passthrough.", g_video.shader.current_postfx_preset);
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
|
|||||||
Reference in new issue
Block a user