equal
deleted
inserted
replaced
16 pub struct HwAnteClient { |
16 pub struct HwAnteClient { |
17 pub nick: Option<String>, |
17 pub nick: Option<String>, |
18 pub protocol_number: Option<NonZeroU16>, |
18 pub protocol_number: Option<NonZeroU16>, |
19 pub server_salt: String, |
19 pub server_salt: String, |
20 pub is_checker: bool, |
20 pub is_checker: bool, |
|
21 pub is_local_admin: bool, |
21 } |
22 } |
22 |
23 |
23 pub struct HwAnteroom { |
24 pub struct HwAnteroom { |
24 pub clients: IndexSlab<HwAnteClient>, |
25 pub clients: IndexSlab<HwAnteClient>, |
25 } |
26 } |
28 pub fn new(clients_limit: usize) -> Self { |
29 pub fn new(clients_limit: usize) -> Self { |
29 let clients = IndexSlab::with_capacity(clients_limit); |
30 let clients = IndexSlab::with_capacity(clients_limit); |
30 HwAnteroom { clients } |
31 HwAnteroom { clients } |
31 } |
32 } |
32 |
33 |
33 pub fn add_client(&mut self, client_id: ClientId, salt: String) { |
34 pub fn add_client(&mut self, client_id: ClientId, salt: String, is_local_admin: bool) { |
34 let client = HwAnteClient { |
35 let client = HwAnteClient { |
35 nick: None, |
36 nick: None, |
36 protocol_number: None, |
37 protocol_number: None, |
37 server_salt: salt, |
38 server_salt: salt, |
38 is_checker: false, |
39 is_checker: false, |
|
40 is_local_admin, |
39 }; |
41 }; |
40 self.clients.insert(client_id, client); |
42 self.clients.insert(client_id, client); |
41 } |
43 } |
42 |
44 |
43 pub fn remove_client(&mut self, client_id: ClientId) -> Option<HwAnteClient> { |
45 pub fn remove_client(&mut self, client_id: ClientId) -> Option<HwAnteClient> { |
91 |
93 |
92 pub fn add_client(&mut self, client_id: ClientId, data: HwAnteClient) { |
94 pub fn add_client(&mut self, client_id: ClientId, data: HwAnteClient) { |
93 if let (Some(protocol), Some(nick)) = (data.protocol_number, data.nick) { |
95 if let (Some(protocol), Some(nick)) = (data.protocol_number, data.nick) { |
94 let mut client = HwClient::new(client_id, protocol.get(), nick); |
96 let mut client = HwClient::new(client_id, protocol.get(), nick); |
95 client.set_is_checker(data.is_checker); |
97 client.set_is_checker(data.is_checker); |
|
98 #[cfg(not(feature = "official-server"))] |
|
99 client.set_is_admin(data.is_local_admin); |
|
100 |
96 self.clients.insert(client_id, client); |
101 self.clients.insert(client_id, client); |
97 } |
102 } |
98 } |
103 } |
99 |
104 |
100 pub fn remove_client(&mut self, client_id: ClientId) { |
105 pub fn remove_client(&mut self, client_id: ClientId) { |