rust/hedgewars-server/src/core/client.rs
changeset 15554 f1205f33bf5b
parent 15096 e935b1ad23f3
child 15591 4b2f3228f13b
equal deleted inserted replaced
15553:ede5f4ec48f3 15554:f1205f33bf5b
     1 use super::types::ClientId;
     1 use super::types::ClientId;
     2 use bitflags::*;
     2 use bitflags::*;
     3 
     3 
     4 bitflags! {
     4 bitflags! {
     5     pub struct ClientFlags: u16 {
     5     pub struct ClientFlags: u8 {
     6         const IS_ADMIN = 0b0000_0001;
     6         const IS_ADMIN = 0b0000_0001;
     7         const IS_MASTER = 0b0000_0010;
     7         const IS_MASTER = 0b0000_0010;
     8         const IS_READY = 0b0000_0100;
     8         const IS_READY = 0b0000_0100;
     9         const IS_IN_GAME = 0b0000_1000;
     9         const IS_IN_GAME = 0b0000_1000;
    10         const IS_JOINED_MID_GAME = 0b0001_0000;
    10         const IS_JOINED_MID_GAME = 0b0001_0000;
    11         const IS_CHECKER = 0b0010_0000;
    11         const IS_CONTRIBUTOR = 0b0010_0000;
    12         const IS_CONTRIBUTOR = 0b0100_0000;
    12         const HAS_SUPER_POWER = 0b0100_0000;
    13         const HAS_SUPER_POWER = 0b1000_0000;
    13         const IS_REGISTERED = 0b1000_0000;
    14         const IS_REGISTERED = 0b0001_0000_0000;
       
    15 
    14 
    16         const NONE = 0b0000_0000;
    15         const NONE = 0b0000_0000;
    17         const DEFAULT = Self::NONE.bits;
    16         const DEFAULT = Self::NONE.bits;
    18     }
    17     }
    19 }
    18 }
    64         self.contains(ClientFlags::IS_IN_GAME)
    63         self.contains(ClientFlags::IS_IN_GAME)
    65     }
    64     }
    66     pub fn is_joined_mid_game(&self) -> bool {
    65     pub fn is_joined_mid_game(&self) -> bool {
    67         self.contains(ClientFlags::IS_JOINED_MID_GAME)
    66         self.contains(ClientFlags::IS_JOINED_MID_GAME)
    68     }
    67     }
    69     pub fn is_checker(&self) -> bool {
       
    70         self.contains(ClientFlags::IS_CHECKER)
       
    71     }
       
    72     pub fn is_contributor(&self) -> bool {
    68     pub fn is_contributor(&self) -> bool {
    73         self.contains(ClientFlags::IS_CONTRIBUTOR)
    69         self.contains(ClientFlags::IS_CONTRIBUTOR)
    74     }
    70     }
    75     pub fn has_super_power(&self) -> bool {
    71     pub fn has_super_power(&self) -> bool {
    76         self.contains(ClientFlags::HAS_SUPER_POWER)
    72         self.contains(ClientFlags::HAS_SUPER_POWER)
    92         self.set(ClientFlags::IS_IN_GAME, value)
    88         self.set(ClientFlags::IS_IN_GAME, value)
    93     }
    89     }
    94     pub fn set_is_joined_mid_game(&mut self, value: bool) {
    90     pub fn set_is_joined_mid_game(&mut self, value: bool) {
    95         self.set(ClientFlags::IS_JOINED_MID_GAME, value)
    91         self.set(ClientFlags::IS_JOINED_MID_GAME, value)
    96     }
    92     }
    97     pub fn set_is_checker(&mut self, value: bool) {
       
    98         self.set(ClientFlags::IS_CHECKER, value)
       
    99     }
       
   100     pub fn set_is_contributor(&mut self, value: bool) {
    93     pub fn set_is_contributor(&mut self, value: bool) {
   101         self.set(ClientFlags::IS_CONTRIBUTOR, value)
    94         self.set(ClientFlags::IS_CONTRIBUTOR, value)
   102     }
    95     }
   103     pub fn set_has_super_power(&mut self, value: bool) {
    96     pub fn set_has_super_power(&mut self, value: bool) {
   104         self.set(ClientFlags::HAS_SUPER_POWER, value)
    97         self.set(ClientFlags::HAS_SUPER_POWER, value)