rust/hedgewars-server/src/server/core.rs
changeset 14700 216d39de1a44
parent 14699 25c564f77b7d
child 14701 8a45c90f4580
equal deleted inserted replaced
14699:25c564f77b7d 14700:216d39de1a44
    17 type Slab<T> = slab::Slab<T>;
    17 type Slab<T> = slab::Slab<T>;
    18 
    18 
    19 pub struct HWAnteClient {
    19 pub struct HWAnteClient {
    20     pub nick: Option<String>,
    20     pub nick: Option<String>,
    21     pub protocol_number: Option<NonZeroU16>,
    21     pub protocol_number: Option<NonZeroU16>,
       
    22     pub web_password: Option<String>,
    22     pub server_salt: String,
    23     pub server_salt: String,
    23     pub web_password: String,
       
    24 }
    24 }
    25 
    25 
    26 pub struct HWAnteroom {
    26 pub struct HWAnteroom {
    27     pub clients: IndexSlab<HWAnteClient>,
    27     pub clients: IndexSlab<HWAnteClient>,
    28 }
    28 }
    36     pub fn add_client(&mut self, client_id: ClientId, salt: String) {
    36     pub fn add_client(&mut self, client_id: ClientId, salt: String) {
    37         let client = HWAnteClient {
    37         let client = HWAnteClient {
    38             nick: None,
    38             nick: None,
    39             protocol_number: None,
    39             protocol_number: None,
    40             server_salt: salt,
    40             server_salt: salt,
    41             web_password: "".to_string(),
    41             web_password: None,
    42         };
    42         };
    43         self.clients.insert(client_id, client);
    43         self.clients.insert(client_id, client);
    44     }
    44     }
    45 
    45 
    46     pub fn remove_client(&mut self, client_id: ClientId) -> Option<HWAnteClient> {
    46     pub fn remove_client(&mut self, client_id: ClientId) -> Option<HWAnteClient> {
    47         let mut client = self.clients.remove(client_id);
    47         let mut client = self.clients.remove(client_id);
    48         if let Some(ref mut client) = client {
    48         if let Some(HWAnteClient { web_password: Some(ref mut password), ..}) = client {
    49             client
    49             password.replace_range(.., "🦔🦔🦔🦔🦔🦔🦔🦔");
    50                 .web_password
       
    51                 .replace_range(.., "🦔🦔🦔🦔🦔🦔🦔🦔");
       
    52         }
    50         }
    53         client
    51         client
    54     }
    52     }
    55 }
    53 }
    56 
    54