rust/hedgewars-server/src/server/handlers/loggingin.rs
changeset 14694 08a8605bafaf
parent 14693 6e6632068a33
child 14704 932ff7683653
equal deleted inserted replaced
14693:6e6632068a33 14694:08a8605bafaf
    49             if client.room_id != None {
    49             if client.room_id != None {
    50                 unreachable!()
    50                 unreachable!()
    51             } else if !client.nick.is_empty() {
    51             } else if !client.nick.is_empty() {
    52                 response.add(Error("Nickname already provided.".to_string()).send_self());
    52                 response.add(Error("Nickname already provided.".to_string()).send_self());
    53             } else if is_name_illegal(&nick) {
    53             } else if is_name_illegal(&nick) {
    54                 // ByeClient("Illegal nickname! Nicknames 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())
    54                 super::common::remove_client(server, response, "Illegal nickname! Nicknames 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())
    55             } else {
    55             } else {
    56                 client.nick = nick.clone();
    56                 client.nick = nick.clone();
    57                 response.add(Nick(nick).send_self());
    57                 response.add(Nick(nick).send_self());
    58                 //CheckRegistered
    58 
       
    59                 if client.protocol_number > 0 {
       
    60                     //CheckRegistered
       
    61                 }
       
    62             }
       
    63         }
       
    64         HWProtocolMessage::Proto(proto) => {
       
    65             let client = &mut server.clients[client_id];
       
    66             if client.protocol_number != 0 {
       
    67                 response.add(Error("Protocol already known.".to_string()).send_self());
       
    68             } else if proto == 0 {
       
    69                 response.add(Error("Bad number.".to_string()).send_self());
       
    70             } else {
       
    71                 client.protocol_number = proto;
       
    72                 response.add(Proto(proto).send_self());
       
    73 
       
    74                 if client.nick != "" {
       
    75                     // CheckRegistered
       
    76                 }
    59             }
    77             }
    60         }
    78         }
    61         #[cfg(feature = "official-server")]
    79         #[cfg(feature = "official-server")]
    62         HWProtocolMessage::Password(hash, salt) => {
    80         HWProtocolMessage::Password(hash, salt) => {
    63             let c = &server.clients[client_id];
    81             let c = &server.clients[client_id];
    66             let server_hash = get_hash(c, &c.server_salt, &salt);
    84             let server_hash = get_hash(c, &c.server_salt, &salt);
    67             if client_hash == server_hash {
    85             if client_hash == server_hash {
    68                 response.add(ServerAuth(format!("{:x}", server_hash)).send_self());
    86                 response.add(ServerAuth(format!("{:x}", server_hash)).send_self());
    69             //JoinLobby
    87             //JoinLobby
    70             } else {
    88             } else {
    71                 //ByeClient("Authentication failed".to_string())
    89                 super::common::remove_client(server, response, "Authentication failed".to_string())
    72             };
    90             };
    73         }
       
    74         HWProtocolMessage::Proto(proto) => {
       
    75             let client = &mut server.clients[client_id];
       
    76             if client.protocol_number != 0 {
       
    77                 response.add(Error("Protocol already known.".to_string()).send_self());
       
    78             } else if proto == 0 {
       
    79                 response.add(Error("Bad number.".to_string()).send_self());
       
    80             } else {
       
    81                 client.protocol_number = proto;
       
    82                 response.add(Proto(proto).send_self());
       
    83                 // CheckRegistered
       
    84             }
       
    85         }
    91         }
    86         #[cfg(feature = "official-server")]
    92         #[cfg(feature = "official-server")]
    87         HWProtocolMessage::Checker(protocol, nick, password) => {
    93         HWProtocolMessage::Checker(protocol, nick, password) => {
    88             let c = &mut server.clients[client_id];
    94             let c = &mut server.clients[client_id];
    89             c.nick = nick;
    95             c.nick = nick;