93 room: &mut HWRoom, |
92 room: &mut HWRoom, |
94 team_names: Vec<String>, |
93 team_names: Vec<String>, |
95 is_in_game: bool, |
94 is_in_game: bool, |
96 response: &mut Response, |
95 response: &mut Response, |
97 ) { |
96 ) { |
98 let mut game_ended = false; |
|
99 if let Some(ref mut info) = room.game_info { |
97 if let Some(ref mut info) = room.game_info { |
100 for team_name in &team_names { |
98 for team_name in &team_names { |
101 info.left_teams.push(team_name.clone()); |
99 info.left_teams.push(team_name.clone()); |
102 |
100 |
103 if is_in_game { |
101 if is_in_game { |
184 |
184 |
185 pub fn exit_room(server: &mut HWServer, client_id: ClientId, response: &mut Response, msg: &str) { |
185 pub fn exit_room(server: &mut HWServer, client_id: ClientId, response: &mut Response, msg: &str) { |
186 let client = &mut server.clients[client_id]; |
186 let client = &mut server.clients[client_id]; |
187 |
187 |
188 if let Some(room_id) = client.room_id { |
188 if let Some(room_id) = client.room_id { |
189 if room_id != server.lobby_id { |
189 let room = &mut server.rooms[room_id]; |
190 let room = &mut server.rooms[room_id]; |
190 |
191 |
191 remove_client_from_room(client, room, response, msg); |
192 remove_client_from_room(client, room, response, msg); |
192 |
193 client.room_id = Some(server.lobby_id); |
193 if !room.is_fixed() && room.master_id == None { |
194 |
194 if let Some(new_master_id) = server.room_clients(room_id).first().cloned() { |
195 if !room.is_fixed() && room.master_id == None { |
195 let new_master_nick = server.clients[new_master_id].nick.clone(); |
196 if let Some(new_master_id) = server.room_clients(room_id).first().cloned() { |
196 let room = &mut server.rooms[room_id]; |
197 let new_master_nick = server.clients[new_master_id].nick.clone(); |
197 room.master_id = Some(new_master_id); |
198 let room = &mut server.rooms[room_id]; |
198 server.clients[new_master_id].set_is_master(true); |
199 room.master_id = Some(new_master_id); |
199 |
200 server.clients[new_master_id].set_is_master(true); |
200 if room.protocol_number < 42 { |
201 |
201 room.name = new_master_nick.clone(); |
202 if room.protocol_number < 42 { |
|
203 room.name = new_master_nick.clone(); |
|
204 } |
|
205 |
|
206 room.set_join_restriction(false); |
|
207 room.set_team_add_restriction(false); |
|
208 room.set_unregistered_players_restriction(true); |
|
209 |
|
210 response.add( |
|
211 ClientFlags("+h".to_string(), vec![new_master_nick]) |
|
212 .send_all() |
|
213 .in_room(room.id), |
|
214 ); |
|
215 } |
202 } |
|
203 |
|
204 room.set_join_restriction(false); |
|
205 room.set_team_add_restriction(false); |
|
206 room.set_unregistered_players_restriction(true); |
|
207 |
|
208 response.add( |
|
209 ClientFlags("+h".to_string(), vec![new_master_nick]) |
|
210 .send_all() |
|
211 .in_room(room.id), |
|
212 ); |
216 } |
213 } |
217 } |
214 } |
218 } |
215 } |
219 } |
216 } |
220 |
217 |
221 pub fn remove_client(server: &mut HWServer, response: &mut Response, msg: String) { |
218 pub fn remove_client(server: &mut HWServer, response: &mut Response, msg: String) { |
222 let client_id = response.client_id(); |
219 let client_id = response.client_id(); |
223 let lobby_id = server.lobby_id; |
|
224 let client = &mut server.clients[client_id]; |
220 let client = &mut server.clients[client_id]; |
225 let (nick, room_id) = (client.nick.clone(), client.room_id); |
221 let (nick, room_id) = (client.nick.clone(), client.room_id); |
226 |
222 |
227 exit_room(server, client_id, response, &msg); |
223 exit_room(server, client_id, response, &msg); |
228 |
224 |