fix(client_world): add direct exit flag to break connection error loop

This commit is contained in:
2026-07-17 13:04:52 +08:00
parent ec9e89886e
commit 643b702aee
3 changed files with 7 additions and 4 deletions

View File

@@ -727,7 +727,7 @@ AABB ClientWorld::get_block_aabb(const glm::ivec3& pos) {
AudioEngine& ClientWorld::get_audio() { return m_audio; }
Config& ClientWorld::get_config() { return m_config; }
WorldScene& ClientWorld::world_scene() { return m_world_scene; }
void ClientWorld::set_direct_exit() { m_exit_direct = true; }
void ClientWorld::request_exit() {
if (m_receive_exit) {
return;
@@ -738,7 +738,7 @@ void ClientWorld::request_exit() {
m_client->send(make_packet(*req));
int cnt = 0;
while (!m_receive_exit) {
if (m_client->is_connect_error()) {
if (m_client->is_connect_error() || m_exit_direct) {
break;
}
std::this_thread::sleep_for(milliseconds(DEFAULT_PER_TICK_TIME));

View File

@@ -20,6 +20,8 @@ WorldScene::~WorldScene() {
void WorldScene::update(float dt) {
if (m_client->is_connect_error()) {
set_error(m_client->get_error_string());
m_client->clear_error();
m_client_world.set_direct_exit();
}
if (m_error_ui.has_error()) {
m_error_ui.update(dt);
@@ -46,7 +48,6 @@ void WorldScene::update(float dt) {
if (m_paused) {
m_pasue_menu.update(dt);
} else {
m_hud_ui.update(dt);
}
}
@@ -290,6 +291,7 @@ void WorldScene::set_pause(bool pause) {
}
void WorldScene::set_error(std::string_view error) {
Logger::error("WorldScene Error Set {}", error);
m_error_ui.set_error(error);
set_pause(true);
}