gameServer2/src/server/handlers/inroom.rs
changeset 13427 5fb27f94fc3b
parent 13424 81e0ed105f5d
child 13428 87a6cad20c90
equal deleted inserted replaced
13426:d1368c776a4f 13427:5fb27f94fc3b
    38                     vec![Warn("Illegal room name! A room name must be between 1-40 characters long, must not have a trailing or leading space and must not have any of these characters: $()*+?[]^{|}".to_string())]
    38                     vec![Warn("Illegal room name! A room name must be between 1-40 characters long, must not have a trailing or leading space and must not have any of these characters: $()*+?[]^{|}".to_string())]
    39                 } else if server.has_room(&new_name) {
    39                 } else if server.has_room(&new_name) {
    40                     vec![Warn("A room with the same name already exists.".to_string())]
    40                     vec![Warn("A room with the same name already exists.".to_string())]
    41                 } else {
    41                 } else {
    42                     let mut old_name = new_name.clone();
    42                     let mut old_name = new_name.clone();
    43                     if let (c, Some(r)) = server.client_and_room(client_id) {
    43                     if let (_, Some(r)) = server.client_and_room(client_id) {
    44                         swap(&mut r.name, &mut old_name);
    44                         swap(&mut r.name, &mut old_name);
    45                         vec![SendRoomUpdate(Some(old_name))]
    45                         vec![SendRoomUpdate(Some(old_name))]
    46                     } else {
    46                     } else {
    47                         Vec::new()
    47                         Vec::new()
    48                     }
    48                     }
    64             } else {
    64             } else {
    65                 Vec::new()
    65                 Vec::new()
    66             };
    66             };
    67             server.react(client_id, actions);
    67             server.react(client_id, actions);
    68         }
    68         }
    69         AddTeam(mut info) => {
    69         AddTeam(info) => {
    70             let mut actions = Vec::new();
    70             let mut actions = Vec::new();
    71             if let (c, Some(r)) = server.client_and_room(client_id) {
    71             if let (c, Some(r)) = server.client_and_room(client_id) {
    72                 let room_id = r.id;
    72                 let room_id = r.id;
    73                 if r.teams.len() >= r.team_limit as usize {
    73                 if r.teams.len() >= r.team_limit as usize {
    74                     actions.push(Warn("Too many teams!".to_string()))
    74                     actions.push(Warn("Too many teams!".to_string()))
   161             if let Some(id) = owner_id {
   161             if let Some(id) = owner_id {
   162                 server.clients[id].clan = Some(color);
   162                 server.clients[id].clan = Some(color);
   163             }
   163             }
   164 
   164 
   165             server.react(client_id, actions);
   165             server.react(client_id, actions);
       
   166         },
       
   167         Cfg(cfg) => {
       
   168             let actions = if let (c, Some(r)) = server.client_and_room(client_id) {
       
   169                 if !c.is_master {
       
   170                     vec![ProtocolError("You're not the room master!".to_string())]
       
   171                 } else {
       
   172                     r.set_config(cfg.clone());
       
   173                     vec![cfg.into_server_msg()
       
   174                         .send_all().in_room(r.id).but_self().action()]
       
   175                 }
       
   176             } else {
       
   177                 Vec::new()
       
   178             };
       
   179             server.react(client_id, actions);
   166         }
   180         }
   167         _ => warn!("Unimplemented!")
   181         _ => warn!("Unimplemented!")
   168     }
   182     }
   169 }
   183 }