rust/hedgewars-server/src/handlers/inroom.rs
changeset 15444 a158ff8f84ef
parent 15331 136023417164
child 15487 4cc9ec732392
equal deleted inserted replaced
15443:e7c059ac6e54 15444:a158ff8f84ef
    50 fn is_msg_valid(msg: &[u8], team_indices: &[u8]) -> bool {
    50 fn is_msg_valid(msg: &[u8], team_indices: &[u8]) -> bool {
    51     match msg {
    51     match msg {
    52         [size, typ, body..MAX] => {
    52         [size, typ, body..MAX] => {
    53             VALID_MESSAGES.contains(typ)
    53             VALID_MESSAGES.contains(typ)
    54                 && match body {
    54                 && match body {
    55                     [1...MAX_HEDGEHOGS_PER_TEAM, team, ..] if *typ == b'h' => {
    55                     [1..=MAX_HEDGEHOGS_PER_TEAM, team, ..] if *typ == b'h' => {
    56                         team_indices.contains(team)
    56                         team_indices.contains(team)
    57                     }
    57                     }
    58                     _ => *typ != b'h',
    58                     _ => *typ != b'h',
    59                 }
    59                 }
    60         }
    60         }
   270             Some((id, _)) if id != client_id => response
   270             Some((id, _)) if id != client_id => response
   271                 .add(Warning("You can't remove a team you don't own.".to_string()).send_self()),
   271                 .add(Warning("You can't remove a team you don't own.".to_string()).send_self()),
   272             Some((_, name)) => {
   272             Some((_, name)) => {
   273                 client.teams_in_game -= 1;
   273                 client.teams_in_game -= 1;
   274                 client.clan = room.find_team_color(client.id);
   274                 client.clan = room.find_team_color(client.id);
   275                 super::common::remove_teams(
   275                 let names = vec![name.to_string()];
   276                     room,
   276                 super::common::remove_teams(room, names, client.is_in_game(), response);
   277                     vec![name.to_string()],
       
   278                     client.is_in_game(),
       
   279                     response,
       
   280                 );
       
   281 
   277 
   282                 match room.game_info {
   278                 match room.game_info {
   283                     Some(ref info) if info.teams_in_game == 0 => {
   279                     Some(ref info) if info.teams_in_game == 0 => {
   284                         super::common::end_game(server, room_id, response)
   280                         super::common::end_game(server, room_id, response)
   285                     }
   281                     }
   436                         Some("/callvote pause: No game in progress!".to_string())
   432                         Some("/callvote pause: No game in progress!".to_string())
   437                     }
   433                     }
   438                 }
   434                 }
   439                 VoteType::NewSeed => None,
   435                 VoteType::NewSeed => None,
   440                 VoteType::HedgehogsPerTeam(number) => match number {
   436                 VoteType::HedgehogsPerTeam(number) => match number {
   441                     1...MAX_HEDGEHOGS_PER_TEAM => None,
   437                     1..=MAX_HEDGEHOGS_PER_TEAM => None,
   442                     _ => Some("/callvote hedgehogs: Specify number from 1 to 8.".to_string()),
   438                     _ => Some("/callvote hedgehogs: Specify number from 1 to 8.".to_string()),
   443                 },
   439                 },
   444             };
   440             };
   445 
   441 
   446             match error {
   442             match error {