From cea5492abc7a15c7ea310623738a09bf5a29d838 Mon Sep 17 00:00:00 2001 From: Sergio Valor Date: Thu, 2 Apr 2026 19:55:28 +0200 Subject: [PATCH] =?UTF-8?q?fix:=20bug=20que=20feia=20que=20en=20el=20edito?= =?UTF-8?q?r,=20al=20canviar=20d'habitaci=C3=B3=20el=20renderInfo=20tornar?= =?UTF-8?q?a=20a=20eixir?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source/game/editor/map_editor.cpp | 30 +++++++++++++++++------------ source/game/editor/map_editor.hpp | 2 ++ source/game/ui/console_commands.cpp | 1 + 3 files changed, 21 insertions(+), 12 deletions(-) diff --git a/source/game/editor/map_editor.cpp b/source/game/editor/map_editor.cpp index 8570596..9a64d18 100644 --- a/source/game/editor/map_editor.cpp +++ b/source/game/editor/map_editor.cpp @@ -122,7 +122,7 @@ void MapEditor::toggleMiniMap() { mini_map_ = std::make_unique(parseColor(settings_.minimap_bg), parseColor(settings_.minimap_conn)); mini_map_->on_navigate = [this](const std::string& room_name) { mini_map_visible_ = false; - // Navegar a la room (usa changeRoomWithEditor vía GameControl) + reenter_ = true; if (GameControl::exit_editor) { GameControl::exit_editor(); } if (GameControl::change_room && GameControl::change_room(room_name)) { if (GameControl::enter_editor) { GameControl::enter_editor(); } @@ -175,14 +175,19 @@ void MapEditor::enter(std::shared_ptr room, std::shared_ptr player yaml_backup_ = yaml_; // Copia profunda para revert } - // Guardar estado de invencibilidad y forzarla - invincible_before_editor_ = Options::cheats.invincible; + if (!reenter_) { + // Solo guardar estado previo en el primer enter (no en re-enter tras cambio de room) + invincible_before_editor_ = Options::cheats.invincible; + render_info_before_editor_ = RenderInfo::get()->isActive(); + } + reenter_ = false; + + // Forzar invencibilidad Options::cheats.invincible = Options::Cheat::State::ENABLED; player_->setColor(); - // Guardar estado de render_info y aplicar el setting del editor - render_info_before_editor_ = RenderInfo::get()->isActive(); - if (settings_.show_render_info != render_info_before_editor_) { + // Aplicar el setting de render_info del editor + if (settings_.show_render_info != RenderInfo::get()->isActive()) { RenderInfo::get()->toggle(); } @@ -209,13 +214,14 @@ void MapEditor::exit() { active_ = false; - // Restaurar invencibilidad - Options::cheats.invincible = invincible_before_editor_; - player_->setColor(); + if (!reenter_) { + // Solo restaurar en el exit final (no en cambio de room) + Options::cheats.invincible = invincible_before_editor_; + player_->setColor(); - // Restaurar render_info - if (RenderInfo::get()->isActive() != render_info_before_editor_) { - RenderInfo::get()->toggle(); + if (RenderInfo::get()->isActive() != render_info_before_editor_) { + RenderInfo::get()->toggle(); + } } // Restaurar prompt de la consola y limpiar estado diff --git a/source/game/editor/map_editor.hpp b/source/game/editor/map_editor.hpp index 743ec51..29bd0cb 100644 --- a/source/game/editor/map_editor.hpp +++ b/source/game/editor/map_editor.hpp @@ -49,6 +49,7 @@ class MapEditor { auto showGrid(bool show) -> std::string; [[nodiscard]] auto isGridEnabled() const -> bool { return settings_.grid; } void toggleMiniMap(); + void setReenter(bool value) { reenter_ = value; } auto setMiniMapBg(const std::string& color) -> std::string; auto setMiniMapConn(const std::string& color) -> std::string; @@ -150,6 +151,7 @@ class MapEditor { // Estado previo (para restaurar al salir) Options::Cheat::State invincible_before_editor_{Options::Cheat::State::DISABLED}; bool render_info_before_editor_{false}; + bool reenter_{false}; // true cuando es un re-enter tras cambio de room (no tocar render_info) }; #endif // _DEBUG diff --git a/source/game/ui/console_commands.cpp b/source/game/ui/console_commands.cpp index 57765af..0e1a9b4 100644 --- a/source/game/ui/console_commands.cpp +++ b/source/game/ui/console_commands.cpp @@ -570,6 +570,7 @@ static auto changeRoomWithEditor(const std::string& room_file) -> std::string { // Si el editor está activo, salir primero (guarda y recarga la room actual) if (EDITOR_WAS_ACTIVE && GameControl::exit_editor) { + MapEditor::get()->setReenter(true); GameControl::exit_editor(); }