equal
deleted
inserted
replaced
60 bitflags! { |
60 bitflags! { |
61 pub struct RoomFlags: u8 { |
61 pub struct RoomFlags: u8 { |
62 const FIXED = 0b0000_0001; |
62 const FIXED = 0b0000_0001; |
63 const RESTRICTED_JOIN = 0b0000_0010; |
63 const RESTRICTED_JOIN = 0b0000_0010; |
64 const RESTRICTED_TEAM_ADD = 0b0000_0100; |
64 const RESTRICTED_TEAM_ADD = 0b0000_0100; |
65 const RESTRICTED_UNREGISTERED_PLAYERS = 0b0000_1000; |
65 const REGISTRATION_REQUIRED = 0b0000_1000; |
66 } |
66 } |
67 } |
67 } |
68 |
68 |
69 pub struct HwRoom { |
69 pub struct HwRoom { |
70 pub id: RoomId, |
70 pub id: RoomId, |
250 self.flags.contains(RoomFlags::RESTRICTED_JOIN) |
250 self.flags.contains(RoomFlags::RESTRICTED_JOIN) |
251 } |
251 } |
252 pub fn is_team_add_restricted(&self) -> bool { |
252 pub fn is_team_add_restricted(&self) -> bool { |
253 self.flags.contains(RoomFlags::RESTRICTED_TEAM_ADD) |
253 self.flags.contains(RoomFlags::RESTRICTED_TEAM_ADD) |
254 } |
254 } |
255 pub fn are_unregistered_players_restricted(&self) -> bool { |
255 pub fn is_registration_required(&self) -> bool { |
256 self.flags |
256 self.flags.contains(RoomFlags::REGISTRATION_REQUIRED) |
257 .contains(RoomFlags::RESTRICTED_UNREGISTERED_PLAYERS) |
|
258 } |
257 } |
259 |
258 |
260 pub fn set_is_fixed(&mut self, value: bool) { |
259 pub fn set_is_fixed(&mut self, value: bool) { |
261 self.flags.set(RoomFlags::FIXED, value) |
260 self.flags.set(RoomFlags::FIXED, value) |
262 } |
261 } |
265 } |
264 } |
266 pub fn set_team_add_restriction(&mut self, value: bool) { |
265 pub fn set_team_add_restriction(&mut self, value: bool) { |
267 self.flags.set(RoomFlags::RESTRICTED_TEAM_ADD, value) |
266 self.flags.set(RoomFlags::RESTRICTED_TEAM_ADD, value) |
268 } |
267 } |
269 pub fn set_unregistered_players_restriction(&mut self, value: bool) { |
268 pub fn set_unregistered_players_restriction(&mut self, value: bool) { |
270 self.flags |
269 self.flags.set(RoomFlags::REGISTRATION_REQUIRED, value) |
271 .set(RoomFlags::RESTRICTED_UNREGISTERED_PLAYERS, value) |
|
272 } |
270 } |
273 |
271 |
274 fn flags_string(&self) -> String { |
272 fn flags_string(&self) -> String { |
275 let mut result = "-".to_string(); |
273 let mut result = "-".to_string(); |
276 if self.game_info.is_some() { |
274 if self.game_info.is_some() { |
280 result += "p" |
278 result += "p" |
281 } |
279 } |
282 if self.is_join_restricted() { |
280 if self.is_join_restricted() { |
283 result += "j" |
281 result += "j" |
284 } |
282 } |
285 if self.are_unregistered_players_restricted() { |
283 if self.is_registration_required() { |
286 result += "r" |
284 result += "r" |
287 } |
285 } |
288 result |
286 result |
289 } |
287 } |
290 |
288 |