rust/hedgewars-server/src/server/core.rs
changeset 14786 8ecdb5c6bb2a
parent 14783 b3adc030104b
child 14789 18240b308505
--- a/rust/hedgewars-server/src/server/core.rs	Wed Apr 10 23:56:53 2019 +0300
+++ b/rust/hedgewars-server/src/server/core.rs	Thu Apr 11 01:13:29 2019 +0300
@@ -7,6 +7,7 @@
 use crate::utils;
 
 use crate::protocol::messages::HWProtocolMessage::Greeting;
+use bitflags::*;
 use log::*;
 use slab;
 use std::{borrow::BorrowMut, iter, num::NonZeroU16};
@@ -60,11 +61,18 @@
     }
 }
 
+bitflags! {
+    pub struct ServerFlags: u8 {
+        const REGISTERED_ONLY = 0b0000_1000;
+    }
+}
+
 pub struct HWServer {
     pub clients: IndexSlab<HWClient>,
     pub rooms: Slab<HWRoom>,
     pub anteroom: HWAnteroom,
     pub latest_protocol: u16,
+    pub flags: ServerFlags,
     pub greetings: ServerGreetings,
 }
 
@@ -78,6 +86,7 @@
             anteroom: HWAnteroom::new(clients_limit),
             greetings: ServerGreetings::new(),
             latest_protocol: 58,
+            flags: ServerFlags::empty(),
         }
     }
 
@@ -183,6 +192,14 @@
         let room_id = self.clients[self_id].room_id;
         self.collect_clients(|(id, c)| *id != self_id && c.room_id == room_id)
     }
+
+    pub fn is_registered_only(&self) -> bool {
+        self.flags.contains(ServerFlags::REGISTERED_ONLY)
+    }
+
+    pub fn set_is_registered_only(&mut self, value: bool) {
+        self.flags.set(ServerFlags::REGISTERED_ONLY, value)
+    }
 }
 
 fn allocate_room(rooms: &mut Slab<HWRoom>) -> &mut HWRoom {