refactor(log): migra game/scenes i game/ui a Log::
- logo_scene, title_scene, intro_scene, room_fsm: missatges de cicle d'escena com a Log::info amb tag "scene" o "RoomFsm". Eliminats els TODO obsolets sobre el logger pendent. - game_scene (16 logs): events del bus (LEVEL COMPLETE, PLAYER HIT, PLAYER KILLED) com a info; transicions de ROOM com a info; warns als casos d'àudio absent o música no arrencada. - hud (3 logs): init i events com a info. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
0b708f1515
commit
5fce52e0ad
6 files changed
+34
-46
No files matched your search
@@ -7,7 +7,6 @@
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <filesystem>
|
||||
#include <iostream>
|
||||
#include <iterator>
|
||||
#include <utility>
|
||||
#include <variant>
|
||||
@@ -41,6 +40,7 @@
|
||||
#include "utils/defaults.hpp"
|
||||
#include "utils/defines.hpp"
|
||||
#include "utils/easing.hpp"
|
||||
#include "utils/log.hpp"
|
||||
|
||||
namespace {
|
||||
|
||||
@@ -290,13 +290,12 @@ GameScene::GameScene(Config config)
|
||||
// re-emissions es filtren per estat per no re-entrar mai des d'una
|
||||
// transició ja en marxa.
|
||||
entity_manager_.getBus().subscribe("level_complete", [this](const Event& ev) {
|
||||
std::cout << "[LEVEL COMPLETE] player_id=" << ev.player_id << '\n';
|
||||
Log::info("LEVEL COMPLETE", "player_id={}", ev.player_id);
|
||||
if (state_ == RoomFsm::State::PLAYING) { setState(RoomFsm::State::ROOM_OUTRO); }
|
||||
});
|
||||
entity_manager_.getBus().subscribe("player_hit", [](const Event& ev) {
|
||||
const auto* dmg = std::get_if<int>(&ev.payload);
|
||||
std::cout << "[PLAYER HIT] player_id=" << ev.player_id
|
||||
<< " dmg=" << (dmg != nullptr ? *dmg : 0) << '\n';
|
||||
Log::info("PLAYER HIT", "player_id={} dmg={}", ev.player_id, dmg != nullptr ? *dmg : 0);
|
||||
});
|
||||
// `player_killed` el publica un hazard letal (mòmia amb
|
||||
// `kills_outright`) després del `player_hit`. Aquí resolem el
|
||||
@@ -556,8 +555,7 @@ void GameScene::loadRoom(const std::string& yaml_path) {
|
||||
hud_->setPyramidRoom(mgr.currentPyramid(), mgr.currentRoom());
|
||||
}
|
||||
|
||||
std::cout << "[ROOM] load " << yaml_path << ": entities reloaded, paint cleared, "
|
||||
<< ACTIVE_COUNT << " active player(s) disabled (awaiting spawn cinematic)\n";
|
||||
Log::info("ROOM", "load {}: entities reloaded, paint cleared, {} active player(s) disabled (awaiting spawn cinematic)", yaml_path, ACTIVE_COUNT);
|
||||
}
|
||||
|
||||
void GameScene::advanceToNextRoom() {
|
||||
@@ -565,7 +563,7 @@ void GameScene::advanceToNextRoom() {
|
||||
if (!mgr.advance()) {
|
||||
// Política temporal mentre no hi haja pantalla de "Fi de joc":
|
||||
// arribar al final del levels.yaml fa loop a la primera sala.
|
||||
std::cout << "[ROOM] final del levels.yaml — bucle a la primera sala\n";
|
||||
Log::info("ROOM", "final del levels.yaml — bucle a la primera sala");
|
||||
mgr.restart();
|
||||
}
|
||||
loadRoom(mgr.currentPath());
|
||||
@@ -576,9 +574,9 @@ void GameScene::enterRoomIntro() {
|
||||
// Anotem la transició al log si veníem d'un altre estat; si ja
|
||||
// estàvem a INTRO (cas típic d'un salt debug) també queda ben clar.
|
||||
if (state_ != RoomFsm::State::ROOM_INTRO) {
|
||||
std::cout << "[ROOM] " << RoomFsm::stateName(state_) << " -> ROOM_INTRO\n";
|
||||
Log::info("ROOM", "{} -> ROOM_INTRO", RoomFsm::stateName(state_));
|
||||
} else {
|
||||
std::cout << "[ROOM] ROOM_INTRO restart (cinemàtica reiniciada)\n";
|
||||
Log::info("ROOM", "ROOM_INTRO restart (cinemàtica reiniciada)");
|
||||
}
|
||||
state_ = RoomFsm::State::ROOM_INTRO;
|
||||
transition_ = {};
|
||||
@@ -602,7 +600,7 @@ void GameScene::enterRoomIntro() {
|
||||
|
||||
auto* audio = Audio::get();
|
||||
if (audio == nullptr) {
|
||||
std::cout << "[ROOM] INTRO: Audio absent — sense música, timeline només contra text\n";
|
||||
Log::warn("ROOM", "INTRO: Audio absent — sense música, timeline només contra text");
|
||||
return;
|
||||
}
|
||||
audio->stopMusic();
|
||||
@@ -611,10 +609,9 @@ void GameScene::enterRoomIntro() {
|
||||
if (Audio::getMusicState() == Audio::MusicState::PLAYING) {
|
||||
const int DUR_MS = Audio::getMusicDurationMs("room_intro.ogg");
|
||||
transition_config_.intro_music_tail_ms = std::max(0, DUR_MS - TEXT_TOTAL_MS);
|
||||
std::cout << "[ROOM] INTRO: música " << DUR_MS << " ms, music_tail "
|
||||
<< transition_config_.intro_music_tail_ms << " ms\n";
|
||||
Log::info("ROOM", "INTRO: música {} ms, music_tail {} ms", DUR_MS, transition_config_.intro_music_tail_ms);
|
||||
} else {
|
||||
std::cout << "[ROOM] INTRO: música no arrencada — timeline només contra text\n";
|
||||
Log::warn("ROOM", "INTRO: música no arrencada — timeline només contra text");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -638,7 +635,7 @@ void GameScene::respawnPlayersInstant() {
|
||||
state_ = RoomFsm::State::PLAYING;
|
||||
intro_completed_ = true;
|
||||
transition_ = {};
|
||||
std::cout << "[ROOM] post-editor: spawn instantani, estat -> PLAYING\n";
|
||||
Log::info("ROOM", "post-editor: spawn instantani, estat -> PLAYING");
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -671,11 +668,11 @@ void GameScene::triggerPlayerSpawn(std::size_t slot_index) {
|
||||
// al YAML, l'arma queda buida i el LAND és sec igualment.
|
||||
players_[slot_index]->armNextLandReverb(transition_config_.intro_land_reverb_preset);
|
||||
|
||||
std::cout << "[ROOM] spawn cinematic P" << (slot_index + 1) << ": airborne entry\n";
|
||||
Log::info("ROOM", "spawn cinematic P{}: airborne entry", slot_index + 1);
|
||||
}
|
||||
|
||||
void GameScene::dispatchPlayerKilled(int player_id) {
|
||||
std::cout << "[PLAYER KILLED] player_id=" << player_id << '\n';
|
||||
Log::info("PLAYER KILLED", "player_id={}", player_id);
|
||||
const auto IT = std::ranges::find_if(players_, [player_id](const auto& p) {
|
||||
return p && p->getId() == player_id;
|
||||
});
|
||||
@@ -713,7 +710,7 @@ void GameScene::spawnDuePlayers() {
|
||||
|
||||
void GameScene::setState(RoomFsm::State new_state) {
|
||||
if (new_state == state_) { return; }
|
||||
std::cout << "[ROOM] " << RoomFsm::stateName(state_) << " -> " << RoomFsm::stateName(new_state) << '\n';
|
||||
Log::info("ROOM", "{} -> {}", RoomFsm::stateName(state_), RoomFsm::stateName(new_state));
|
||||
state_ = new_state;
|
||||
transition_ = {};
|
||||
// Reset defensiu dels flags de cicle quan tornem a INTRO via aquest
|
||||
@@ -742,7 +739,7 @@ void GameScene::setState(RoomFsm::State new_state) {
|
||||
const int TEXT_TOTAL_MS = transition_config_.outro_text_enter_ms + transition_config_.outro_text_hold_ms + transition_config_.outro_text_exit_ms;
|
||||
transition_config_.outro_music_tail_ms = 0;
|
||||
if (audio == nullptr) {
|
||||
std::cout << "[ROOM] OUTRO: Audio absent — sense música, timeline només contra text\n";
|
||||
Log::warn("ROOM", "OUTRO: Audio absent — sense música, timeline només contra text");
|
||||
} else {
|
||||
audio->stopMusic();
|
||||
audio->setOnMusicEnded({});
|
||||
@@ -750,10 +747,9 @@ void GameScene::setState(RoomFsm::State new_state) {
|
||||
if (Audio::getMusicState() == Audio::MusicState::PLAYING) {
|
||||
const int DUR_MS = Audio::getMusicDurationMs("room_outro.ogg");
|
||||
transition_config_.outro_music_tail_ms = std::max(0, DUR_MS - TEXT_TOTAL_MS);
|
||||
std::cout << "[ROOM] OUTRO: música " << DUR_MS << " ms, music_tail "
|
||||
<< transition_config_.outro_music_tail_ms << " ms\n";
|
||||
Log::info("ROOM", "OUTRO: música {} ms, music_tail {} ms", DUR_MS, transition_config_.outro_music_tail_ms);
|
||||
} else {
|
||||
std::cout << "[ROOM] OUTRO: música no arrencada — timeline només contra text\n";
|
||||
Log::warn("ROOM", "OUTRO: música no arrencada — timeline només contra text");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1075,7 +1071,7 @@ void GameScene::handlePauseInput() {
|
||||
pause_.curve = GOING_TO_PAUSE ? UiConfig::get().pauseEnterCurve() : UiConfig::get().pauseExitCurve();
|
||||
pause_.state = GOING_TO_PAUSE ? PauseState::ENTERING : PauseState::EXITING;
|
||||
|
||||
std::cout << "[PAUSE] " << (GOING_TO_PAUSE ? "entering" : "exiting") << " from_scale=" << pause_.from_scale << " duration_ms=" << pause_.duration_ms << '\n';
|
||||
Log::info("PAUSE", "{} from_scale={} duration_ms={}", GOING_TO_PAUSE ? "entering" : "exiting", pause_.from_scale, pause_.duration_ms);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1212,7 +1208,7 @@ void GameScene::update(int delta_ms) {
|
||||
// (creuar → player_exited → level_complete → OUTRO) es manté.
|
||||
// Mateixos gates que el salt entre sales.
|
||||
if (pause_.state == PauseState::IDLE && !editor_.active() && detectOpenDoor()) {
|
||||
std::cout << "[DEBUG] força obertura de la porta\n";
|
||||
Log::info("DEBUG", "força obertura de la porta");
|
||||
entity_manager_.forceOpenDoor();
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
|
||||
#include <algorithm>
|
||||
#include <cstdint>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
|
||||
@@ -20,13 +19,12 @@
|
||||
#include "game/scenes/scene_flow.hpp"
|
||||
#include "utils/defaults.hpp"
|
||||
#include "utils/defines.hpp"
|
||||
#include "utils/log.hpp"
|
||||
|
||||
namespace {
|
||||
|
||||
constexpr int NAME_Y_OFFSET = -8;
|
||||
constexpr int TIMER_Y_OFFSET = 8;
|
||||
// TODO: migrar a un logger unificat quan es decideixi (veure INC-03 a
|
||||
// docs/audit-core-rendering.md).
|
||||
const char* const SCENE_NAME = "INTRO";
|
||||
|
||||
} // namespace
|
||||
@@ -34,7 +32,7 @@ namespace {
|
||||
IntroScene::IntroScene(std::shared_ptr<Text> font, DebugConfig::StartingPlayers starting_players)
|
||||
: font_(std::move(font)),
|
||||
starting_players_(starting_players) {
|
||||
std::cout << "[scene] " << SCENE_NAME << " start (players=" << DebugConfig::toString(starting_players_) << ")\n";
|
||||
Log::info("scene", "{} start (players={})", SCENE_NAME, DebugConfig::toString(starting_players_));
|
||||
}
|
||||
|
||||
IntroScene::~IntroScene() = default;
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
|
||||
#include <algorithm>
|
||||
#include <cstdint>
|
||||
#include <iostream>
|
||||
#include <utility>
|
||||
|
||||
#include "core/audio/audio.hpp"
|
||||
@@ -19,19 +18,17 @@
|
||||
#include "game/scenes/placeholder_input.hpp"
|
||||
#include "game/scenes/scene_flow.hpp"
|
||||
#include "utils/defines.hpp"
|
||||
#include "utils/log.hpp"
|
||||
|
||||
namespace {
|
||||
|
||||
// TODO: migrar a un logger unificat quan es decideixi (veure INC-03 a
|
||||
// docs/audit-core-rendering.md). De moment std::cout per rastrejar el
|
||||
// flux d'escenes als smoke runs.
|
||||
const char* const SCENE_NAME = "LOGO";
|
||||
|
||||
} // namespace
|
||||
|
||||
LogoScene::LogoScene(std::shared_ptr<Surface> logo, bool reset)
|
||||
: logo_(std::move(logo)) {
|
||||
std::cout << "[scene] " << SCENE_NAME << (reset ? " start (reset)\n" : " start\n");
|
||||
Log::info("scene", "{} start{}", SCENE_NAME, reset ? " (reset)" : "");
|
||||
if (reset) {
|
||||
if (auto* audio = Audio::get(); audio != nullptr) {
|
||||
audio->stopMusic();
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
#include "game/scenes/room_fsm.hpp"
|
||||
|
||||
#include <array>
|
||||
#include <iostream>
|
||||
#include <string_view>
|
||||
|
||||
#include "core/locale/locale.hpp"
|
||||
#include "core/resources/resource_helper.hpp"
|
||||
#include "external/fkyaml_node.hpp"
|
||||
#include "utils/log.hpp"
|
||||
|
||||
namespace {
|
||||
|
||||
@@ -28,7 +28,7 @@ namespace RoomFsm {
|
||||
|
||||
auto bytes = Resource::Helper::loadFile(yaml_path);
|
||||
if (bytes.empty()) {
|
||||
std::cout << "RoomFsm: " << yaml_path << " absent — uso fallbacks compilats\n";
|
||||
Log::warn("RoomFsm", "{} absent — uso fallbacks compilats", yaml_path);
|
||||
return cfg;
|
||||
}
|
||||
const auto* begin = reinterpret_cast<const char*>(bytes.data());
|
||||
@@ -83,9 +83,7 @@ namespace RoomFsm {
|
||||
cfg.text_panel_height_px = readChildInt(n, "height_px", cfg.text_panel_height_px);
|
||||
}
|
||||
|
||||
std::cout << "RoomFsm: timings carregats des de " << yaml_path
|
||||
<< " (intro fade " << cfg.intro_fade_in_ms
|
||||
<< "ms, outro fade " << cfg.outro_fade_out_ms << "ms)\n";
|
||||
Log::info("RoomFsm", "timings carregats des de {} (intro fade {}ms, outro fade {}ms)", yaml_path, cfg.intro_fade_in_ms, cfg.outro_fade_out_ms);
|
||||
return cfg;
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
|
||||
#include <algorithm>
|
||||
#include <cstdint>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
|
||||
@@ -26,6 +25,7 @@
|
||||
#include "utils/defaults.hpp"
|
||||
#include "utils/defines.hpp"
|
||||
#include "utils/easing.hpp"
|
||||
#include "utils/log.hpp"
|
||||
|
||||
namespace {
|
||||
|
||||
@@ -72,7 +72,7 @@ TitleScene::TitleScene(std::shared_ptr<Text> condensed_font, std::shared_ptr<Tex
|
||||
game_logo_(std::move(game_logo)),
|
||||
mini_logo_(std::move(mini_logo)),
|
||||
timer_ms_(UiConfig::get().titleDurationMs()) {
|
||||
std::cout << "[scene] " << SCENE_NAME << " start\n";
|
||||
Log::info("scene", "{} start", SCENE_NAME);
|
||||
const auto& hh = UiConfig::get().titleHeatHaze();
|
||||
if (hh.enabled) {
|
||||
heat_haze_.emplace(Effects::HeatHaze::Params{
|
||||
@@ -190,7 +190,7 @@ void TitleScene::enterStarting(DebugConfig::StartingPlayers players) {
|
||||
if (auto* audio = Audio::get(); audio != nullptr) {
|
||||
audio->fadeOutMusic(UiConfig::get().titleMusicFadeOutMs());
|
||||
}
|
||||
std::cout << "[scene] " << SCENE_NAME << " STARTING (players=" << DebugConfig::toString(players) << ")\n";
|
||||
Log::info("scene", "{} STARTING (players={})", SCENE_NAME, DebugConfig::toString(players));
|
||||
}
|
||||
|
||||
void TitleScene::tickIdle(int delta_ms, bool p1_start, bool p2_start) {
|
||||
@@ -255,7 +255,7 @@ void TitleScene::enterAttract() {
|
||||
if (attract_fade_) {
|
||||
attract_fade_->begin(UiConfig::get().titleAttractFadeToBlackMs());
|
||||
}
|
||||
std::cout << "[scene] " << SCENE_NAME << " ATTRACT_OUT\n";
|
||||
Log::info("scene", "{} ATTRACT_OUT", SCENE_NAME);
|
||||
}
|
||||
|
||||
void TitleScene::advanceToIntro(DebugConfig::StartingPlayers players) {
|
||||
|
||||
Reference in new issue
Block a user