fix(input): reset key status on pause

This commit is contained in:
2026-07-15 15:55:36 +08:00
parent 94d3989e0a
commit 07bea28fa2
5 changed files with 18 additions and 2 deletions

View File

@@ -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;

View File

@@ -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<glm::vec4>& planes();
const std::vector<const ChunkRenderSnapshot*>& render_snapshots() const;
const std::vector<PlayerRenderData>& render_player_data() const;

View File

@@ -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;

View File

@@ -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<uint8_t> raw_data,
PacketHeader header) {

View File

@@ -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