From 6930c18d2a5eb95ee1327ae29c6791d9f7172dcb Mon Sep 17 00:00:00 2001 From: Joshua Goins Date: Mon, 12 May 2025 16:00:23 -0400 Subject: [PATCH] Prevent the chat connection from always forcing a log out This is just a band-aid fix, we really need to the separate the chat connection from the rest of the zone connection logic. But this will at least stop some annoyances when logging out. --- src/bin/kawari-world.rs | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/bin/kawari-world.rs b/src/bin/kawari-world.rs index d4dc701..f9a795d 100644 --- a/src/bin/kawari-world.rs +++ b/src/bin/kawari-world.rs @@ -134,6 +134,9 @@ async fn client_loop( let mut lua_player = LuaPlayer::default(); + // TODO: this is terrible, just have a separate zone/chat connection + let mut is_zone_connection = false; + let mut buf = vec![0; RECEIVE_BUFFER_SIZE]; loop { tokio::select! { @@ -145,7 +148,7 @@ async fn client_loop( if n == 0 { let now = Instant::now(); if now.duration_since(connection.last_keep_alive) > Duration::from_secs(5) { - tracing::info!("Connection was killed because of timeout"); + tracing::info!("Connection {:#?} was killed because of timeout", client_handle.id); break; } } @@ -166,6 +169,8 @@ async fn client_loop( } if connection_type == ConnectionType::Zone { + is_zone_connection = true; + // collect actor data connection.initialize(actor_id).await; @@ -883,7 +888,7 @@ async fn client_loop( } }, Err(_) => { - tracing::info!("Connection was killed because of a network error!"); + tracing::info!("Connection {:#?} was killed because of a network error!", client_handle.id); break; }, } @@ -905,8 +910,14 @@ async fn client_loop( } // forcefully log out the player if they weren't logging out but force D/C'd - if connection.player_data.actor_id != 0 && !connection.gracefully_logged_out { - tracing::info!("Forcefully logging out player..."); + if connection.player_data.actor_id != 0 + && !connection.gracefully_logged_out + && is_zone_connection + { + tracing::info!( + "Forcefully logging out connection {:#?}...", + client_handle.id + ); connection.begin_log_out().await; connection .handle