rust/hedgewars-server/src/handlers/common.rs
changeset 16030 8ba2b5007c29
parent 16029 d9f1b239b6d7
child 16031 e915ed28726e
equal deleted inserted replaced
16029:d9f1b239b6d7 16030:8ba2b5007c29
   104     response.add(rooms_msg.send_self());
   104     response.add(rooms_msg.send_self());
   105 }
   105 }
   106 
   106 
   107 pub fn get_room_join_data<'a, I: Iterator<Item = &'a HwClient> + Clone>(
   107 pub fn get_room_join_data<'a, I: Iterator<Item = &'a HwClient> + Clone>(
   108     client: &HwClient,
   108     client: &HwClient,
       
   109     master: Option<&HwClient>,
   109     room: &HwRoom,
   110     room: &HwRoom,
   110     room_clients: I,
   111     room_clients: I,
   111     response: &mut Response,
   112     response: &mut Response,
   112 ) {
   113 ) {
   113     #[inline]
   114     #[inline]
   232             }
   233             }
   233         }
   234         }
   234 
   235 
   235         get_room_config_impl(room.config(), Destination::ToSelf, response);
   236         get_room_config_impl(room.config(), Destination::ToSelf, response);
   236     }
   237     }
       
   238 
       
   239     get_room_update(None, room, master, response);
   237 }
   240 }
   238 
   241 
   239 pub fn get_room_join_error(error: JoinRoomError, response: &mut Response) {
   242 pub fn get_room_join_error(error: JoinRoomError, response: &mut Response) {
   240     use super::strings::*;
   243     use super::strings::*;
   241     match error {
   244     match error {
   329                 }
   332                 }
   330             }
   333             }
   331 
   334 
   332             get_remove_teams_data(room.id, was_in_game, removed_teams, response);
   335             get_remove_teams_data(room.id, was_in_game, removed_teams, response);
   333 
   336 
       
   337             let master = new_master.or(Some(client.id)).map(|id| server.client(id));
       
   338 
   334             response.add(
   339             response.add(
   335                 RoomUpdated(room.name.clone(), room.info(Some(&client)))
   340                 RoomUpdated(room.name.clone(), room.info(master))
   336                     .send_all()
   341                     .send_all()
   337                     .with_protocol(room.protocol_number),
   342                     .with_protocol(room.protocol_number),
   338             );
   343             );
   339         }
   344         }
   340     }
   345     }
   357     response.add(Bye(msg).send_self());
   362     response.add(Bye(msg).send_self());
   358     response.remove_client(client_id);
   363     response.remove_client(client_id);
   359 }
   364 }
   360 
   365 
   361 pub fn get_room_update(
   366 pub fn get_room_update(
   362     room_name: Option<String>,
   367     old_name: Option<String>,
   363     room: &HwRoom,
   368     room: &HwRoom,
   364     master: Option<&HwClient>,
   369     master: Option<&HwClient>,
   365     response: &mut Response,
   370     response: &mut Response,
   366 ) {
   371 ) {
   367     let update_msg = RoomUpdated(room_name.unwrap_or(room.name.clone()), room.info(master));
   372     let update_msg = RoomUpdated(old_name.unwrap_or(room.name.clone()), room.info(master));
   368     response.add(update_msg.send_all().with_protocol(room.protocol_number));
   373     response.add(update_msg.send_all().with_protocol(room.protocol_number));
   369 }
   374 }
   370 
   375 
   371 pub fn get_room_config_impl(
   376 pub fn get_room_config_impl(
   372     config: &RoomConfig,
   377     config: &RoomConfig,