rust/hedgewars-server/src/handlers/inroom.rs
changeset 15570 e1c2ca38e511
parent 15563 d122b65bdf6f
child 15573 7478568cffbe
equal deleted inserted replaced
15569:863059f61793 15570:e1c2ca38e511
    46 
    46 
    47 const VALID_MESSAGES: &[u8] =
    47 const VALID_MESSAGES: &[u8] =
    48     b"M#+LlRrUuDdZzAaSjJ,NpPwtgfhbc12345\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8A";
    48     b"M#+LlRrUuDdZzAaSjJ,NpPwtgfhbc12345\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8A";
    49 const NON_TIMED_MESSAGES: &[u8] = b"M#hb";
    49 const NON_TIMED_MESSAGES: &[u8] = b"M#hb";
    50 
    50 
    51 #[cfg(canhazslicepatterns)]
       
    52 fn is_msg_valid(msg: &[u8], team_indices: &[u8]) -> bool {
    51 fn is_msg_valid(msg: &[u8], team_indices: &[u8]) -> bool {
    53     match msg {
    52     match msg {
    54         [size, typ, body @ ..] => {
    53         [size, typ, body @ ..] => {
    55             VALID_MESSAGES.contains(typ)
    54             VALID_MESSAGES.contains(typ)
    56                 && match body {
    55                 && match body {
    59                     }
    58                     }
    60                     _ => *typ != b'h',
    59                     _ => *typ != b'h',
    61                 }
    60                 }
    62         }
    61         }
    63         _ => false,
    62         _ => false,
    64     }
       
    65 }
       
    66 
       
    67 fn is_msg_valid(msg: &[u8], _team_indices: &[u8]) -> bool {
       
    68     if let Some(typ) = msg.get(1) {
       
    69         VALID_MESSAGES.contains(typ)
       
    70     } else {
       
    71         false
       
    72     }
    63     }
    73 }
    64 }
    74 
    65 
    75 fn is_msg_empty(msg: &[u8]) -> bool {
    66 fn is_msg_empty(msg: &[u8]) -> bool {
    76     msg.get(1).filter(|t| **t == b'+').is_some()
    67     msg.get(1).filter(|t| **t == b'+').is_some()