fix early room deletion
authoralfadur
Thu, 28 Mar 2024 00:25:22 +0300
changeset 16033 2871fc57a282
parent 16032 abea7f16a03b
child 16034 1fd65aad285d
fix early room deletion
rust/hedgewars-server/src/handlers/common.rs
--- a/rust/hedgewars-server/src/handlers/common.rs	Thu Mar 28 00:17:01 2024 +0300
+++ b/rust/hedgewars-server/src/handlers/common.rs	Thu Mar 28 00:25:22 2024 +0300
@@ -2,6 +2,7 @@
     actions::{Destination, DestinationGroup},
     Response,
 };
+use crate::core::server::HwRoomOrServer;
 use crate::handlers::actions::ToPendingMessage;
 use crate::{
     core::{
@@ -358,12 +359,14 @@
     let client = server.client(client_id);
     let nick = client.nick.clone();
 
-    if let Some((room_id, result)) = server
-        .get_room_control(client_id)
-        .into_room()
-        .map(|mut control| (control.room().id, control.leave_room()))
-    {
-        get_room_leave_result(server, server.room(room_id), &msg, result, response);
+    match server.get_room_control(client_id) {
+        HwRoomOrServer::Room(mut control) => {
+            let room_id = control.room().id;
+            let result = control.leave_room();
+            let server = control.server();
+            get_room_leave_result(server, server.room(room_id), &msg, result, response);
+        }
+        _ => (),
     }
 
     server.remove_client(client_id);