From 07bea28fa25e22fd8082a20c28a9f1ff99721279 Mon Sep 17 00:00:00 2001 From: zhenyan121 <3367366583@qq.com> Date: Wed, 15 Jul 2026 15:55:36 +0800 Subject: [PATCH] fix(input): reset key status on pause --- include/Cubed/gameplay/client_player.hpp | 2 +- include/Cubed/gameplay/client_world.hpp | 1 + src/gameplay/client_player.cpp | 12 ++++++++++++ src/gameplay/client_world.cpp | 2 +- src/scene/world_scene.cpp | 3 +++ 5 files changed, 18 insertions(+), 2 deletions(-) diff --git a/include/Cubed/gameplay/client_player.hpp b/include/Cubed/gameplay/client_player.hpp index fd6323a..9ec1387 100644 --- a/include/Cubed/gameplay/client_player.hpp +++ b/include/Cubed/gameplay/client_player.hpp @@ -68,7 +68,7 @@ public: void set_uuid(std::string_view uuid); std::string get_uuid() const; const std::string& get_name() const; - + void reset_key_status(); void init(std::string_view name); float yaw() const; diff --git a/include/Cubed/gameplay/client_world.hpp b/include/Cubed/gameplay/client_world.hpp index 7f45227..4e0dd32 100644 --- a/include/Cubed/gameplay/client_world.hpp +++ b/include/Cubed/gameplay/client_world.hpp @@ -85,6 +85,7 @@ public: void change_pool_threads(int threads); void reload_config(bool chunk_build = true); void request_chunk(); + void reset_key_status(); std::vector& planes(); const std::vector& render_snapshots() const; const std::vector& render_player_data() const; diff --git a/src/gameplay/client_player.cpp b/src/gameplay/client_player.cpp index cbc4393..388349d 100644 --- a/src/gameplay/client_player.cpp +++ b/src/gameplay/client_player.cpp @@ -634,6 +634,18 @@ std::string ClientPlayer::get_uuid() const { return m_uuid; } const std::string& ClientPlayer::get_name() const { return m_name; } + +void ClientPlayer::reset_key_status() { + m_mouse_state.left = false; + m_mouse_state.right = false; + m_move_state.left = false; + m_move_state.right = false; + m_move_state.back = false; + m_move_state.forward = false; + m_move_state.down = false; + m_move_state.up = false; +} + void ClientPlayer::init(std::string_view name) { m_name = name; diff --git a/src/gameplay/client_world.cpp b/src/gameplay/client_world.cpp index bb50659..f98a64f 100644 --- a/src/gameplay/client_world.cpp +++ b/src/gameplay/client_world.cpp @@ -670,7 +670,7 @@ void ClientWorld::request_chunk() { Logger::info("Send Chunk Request Success"); m_requesting_chunk = false; } - +void ClientWorld::reset_key_status() { m_player.reset_key_status(); } void ClientWorld::receive_chunk(std::vector raw_data, PacketHeader header) { diff --git a/src/scene/world_scene.cpp b/src/scene/world_scene.cpp index 5fc9490..e8b7d32 100644 --- a/src/scene/world_scene.cpp +++ b/src/scene/world_scene.cpp @@ -261,5 +261,8 @@ void WorldScene::set_pause(bool pause) { auto& window = m_scene_manager.app().window(); Logger::info("pause {}", m_paused); window.set_game_running(!m_paused); + if (m_paused) { + m_client_world.reset_key_status(); + } } } // namespace Cubed \ No newline at end of file