rust/hedgewars-server/src/server/handlers/lobby.rs
changeset 14806 a1077e8d26f4
parent 14804 b3adc030104b
child 14808 0e64acbc3f8b
--- a/rust/hedgewars-server/src/server/handlers/lobby.rs	Wed Apr 10 19:30:08 2019 +0300
+++ b/rust/hedgewars-server/src/server/handlers/lobby.rs	Wed Apr 10 23:56:53 2019 +0300
@@ -64,12 +64,7 @@
         JoinRoom(name, _password) => {
             let room = server.rooms.iter().find(|(_, r)| r.name == name);
             let room_id = room.map(|(_, r)| r.id);
-            let nicks = server
-                .clients
-                .iter()
-                .filter(|(_, c)| c.room_id == room_id)
-                .map(|(_, c)| c.nick.clone())
-                .collect();
+
             let client = &mut server.clients[client_id];
 
             if let Some((_, room)) = room {
@@ -93,6 +88,7 @@
 
                     response.add(RoomJoined(vec![nick.clone()]).send_all().in_room(room_id));
                     response.add(ClientFlags(add_flags(&[Flags::InRoom]), vec![nick]).send_all());
+                    let nicks = server.collect_nicks(|(_, c)| c.room_id == Some(room_id));
                     response.add(RoomJoined(nicks).send_self());
 
                     let room = &server.rooms[room_id];