65 .clients |
65 .clients |
66 .iter() |
66 .iter() |
67 .filter(|(_, c)| c.room_id == room_id) |
67 .filter(|(_, c)| c.room_id == room_id) |
68 .map(|(_, c)| c.nick.clone()) |
68 .map(|(_, c)| c.nick.clone()) |
69 .collect(); |
69 .collect(); |
70 let c = &mut server.clients[client_id]; |
70 let client = &mut server.clients[client_id]; |
71 |
71 |
72 if let Some((_, r)) = room { |
72 if let Some((_, room)) = room { |
73 if c.protocol_number != r.protocol_number { |
73 if client.protocol_number != room.protocol_number { |
74 response.add( |
74 response.add( |
75 Warning("Room version incompatible to your Hedgewars version!".to_string()) |
75 Warning("Room version incompatible to your Hedgewars version!".to_string()) |
76 .send_self(), |
76 .send_self(), |
77 ); |
77 ); |
78 } else if r.is_join_restricted() { |
78 } else if room.is_join_restricted() { |
79 response.add( |
79 response.add( |
80 Warning( |
80 Warning( |
81 "Access denied. This room currently doesn't allow joining.".to_string(), |
81 "Access denied. This room currently doesn't allow joining.".to_string(), |
82 ) |
82 ) |
83 .send_self(), |
83 .send_self(), |
84 ); |
84 ); |
85 } else if r.players_number == u8::max_value() { |
85 } else if room.players_number == u8::max_value() { |
86 response.add(Warning("This room is already full".to_string()).send_self()); |
86 response.add(Warning("This room is already full".to_string()).send_self()); |
87 } else if let Some(room_id) = room_id { |
87 } else if let Some(room_id) = room_id { |
88 let nick = c.nick.clone(); |
88 let nick = client.nick.clone(); |
89 server.move_to_room(client_id, room_id); |
89 server.move_to_room(client_id, room_id); |
90 |
90 |
91 response.add(RoomJoined(vec![nick.clone()]).send_all().in_room(room_id)); |
91 response.add(RoomJoined(vec![nick.clone()]).send_all().in_room(room_id)); |
92 response.add(ClientFlags("+i".to_string(), vec![nick]).send_all()); |
92 response.add(ClientFlags("+i".to_string(), vec![nick]).send_all()); |
93 response.add(RoomJoined(nicks).send_self()); |
93 response.add(RoomJoined(nicks).send_self()); |