From 9c0460834032c370e3105a723c18a34f0bcc3d34 Mon Sep 17 00:00:00 2001 From: Flux Xu Date: Tue, 5 Nov 2024 16:11:59 -0500 Subject: [PATCH] Ignore LeaveReq before game start. --- crates/client/src/lan/game/lobby.rs | 8 ++------ crates/client/src/lan/game/proxy.rs | 7 ++----- 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/crates/client/src/lan/game/lobby.rs b/crates/client/src/lan/game/lobby.rs index 95b3231..ce6bd76 100644 --- a/crates/client/src/lan/game/lobby.rs +++ b/crates/client/src/lan/game/lobby.rs @@ -83,12 +83,8 @@ impl<'a> LobbyHandler<'a> { let pkt = next?; if let Some(pkt) = pkt { if pkt.type_id() == LeaveReq::PACKET_TYPE_ID { - if let Some(node_stream) = self.node_stream.as_mut() { - node_stream.report_slot_status(SlotClientStatus::Connected).await.ok(); - } - self.stream.send(Packet::simple(LeaveAck)?).await?; - self.stream.flush().await?; - return Ok(LobbyAction::Leave) + tracing::warn!("received leave request during lobby, ignoring"); + continue; } self.handle_packet(&mut join_state, base_t, pkt).await?; diff --git a/crates/client/src/lan/game/proxy.rs b/crates/client/src/lan/game/proxy.rs index 18c81a8..dbd1252 100644 --- a/crates/client/src/lan/game/proxy.rs +++ b/crates/client/src/lan/game/proxy.rs @@ -444,11 +444,8 @@ impl State { node_stream.report_slot_status(SlotClientStatus::Loaded).await?; }, LeaveReq::PACKET_TYPE_ID => { - tracing::debug!("leave: {:?}", my_slot_player_id); - node_stream.report_slot_status(SlotClientStatus::Connected).await.ok(); - stream.send(Packet::simple(LeaveAck)?).await?; - stream.flush().await?; - break; + tracing::warn!("received leave request during loading, ignoring"); + continue; } PongToHost::PACKET_TYPE_ID => {} _ => {