gameServer2/src/server/handlers/inroom.rs
changeset 13524 5359ff75da3a
parent 13523 8c5dd562c9f7
child 13525 d126d9a646ac
equal deleted inserted replaced
13523:8c5dd562c9f7 13524:5359ff75da3a
    33             None
    33             None
    34         }
    34         }
    35     }
    35     }
    36 }
    36 }
    37 
    37 
    38 fn by_msg(source: &Vec<u8>) -> ByMsg {
    38 fn by_msg(source: &[u8]) -> ByMsg {
    39     ByMsg {messages: &source[..]}
    39     ByMsg {messages: source}
    40 }
    40 }
    41 
    41 
    42 const VALID_MESSAGES: &[u8] =
    42 const VALID_MESSAGES: &[u8] =
    43     b"M#+LlRrUuDdZzAaSjJ,NpPwtgfhbc12345\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8A";
    43     b"M#+LlRrUuDdZzAaSjJ,NpPwtgfhbc12345\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8A";
    44 const NON_TIMED_MESSAGES: &[u8] = b"M#hb";
    44 const NON_TIMED_MESSAGES: &[u8] = b"M#hb";
    97         Part(None) => server.react(client_id, vec![
    97         Part(None) => server.react(client_id, vec![
    98             MoveToLobby("part".to_string())]),
    98             MoveToLobby("part".to_string())]),
    99         Part(Some(msg)) => server.react(client_id, vec![
    99         Part(Some(msg)) => server.react(client_id, vec![
   100             MoveToLobby(format!("part: {}", msg))]),
   100             MoveToLobby(format!("part: {}", msg))]),
   101         Chat(msg) => {
   101         Chat(msg) => {
       
   102             
   102             let actions = {
   103             let actions = {
   103                 let c = &mut server.clients[client_id];
   104                 let c = &mut server.clients[client_id];
   104                 let chat_msg = ChatMsg {nick: c.nick.clone(), msg: msg};
   105                 let chat_msg = ChatMsg {nick: c.nick.clone(), msg};
   105                 vec![chat_msg.send_all().in_room(room_id).but_self().action()]
   106                 vec![chat_msg.send_all().in_room(room_id).but_self().action()]
   106             };
   107             };
   107             server.react(client_id, actions);
   108             server.react(client_id, actions);
   108         },
   109         },
   109         Fix => {
   110         Fix => {
   177                 } else if r.game_info.is_some() {
   178                 } else if r.game_info.is_some() {
   178                     actions.push(Warn("Joining not possible: Round is in progress.".to_string()))
   179                     actions.push(Warn("Joining not possible: Round is in progress.".to_string()))
   179                 } else if r.is_team_add_restricted() {
   180                 } else if r.is_team_add_restricted() {
   180                     actions.push(Warn("This room currently does not allow adding new teams.".to_string()));
   181                     actions.push(Warn("This room currently does not allow adding new teams.".to_string()));
   181                 } else {
   182                 } else {
   182                     let team = r.add_team(c.id, info);
   183                     let team = r.add_team(c.id, *info);
   183                     c.teams_in_game += 1;
   184                     c.teams_in_game += 1;
   184                     c.clan = Some(team.color);
   185                     c.clan = Some(team.color);
   185                     actions.push(TeamAccepted(team.name.clone())
   186                     actions.push(TeamAccepted(team.name.clone())
   186                         .send_self().action());
   187                         .send_self().action());
   187                     actions.push(TeamAdd(HWRoom::team_info(&c, team))
   188                     actions.push(TeamAdd(HWRoom::team_info(&c, team))