chiark / gitweb /
wip new account etc.
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 17 Oct 2020 17:12:28 +0000 (18:12 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 17 Oct 2020 17:12:28 +0000 (18:12 +0100)
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
src/accounts.rs
src/gamestate.rs
src/global.rs
src/updates.rs

index 66e392b613073f0b50bea2ea9f160620e7936394..5e1201c60d7585b4ba828963f110e0952c3a71d9 100644 (file)
@@ -4,6 +4,8 @@
 
 use crate::imports::*;
 
+use parking_lot::{RwLock, const_rwlock};
+
 #[derive(Debug,Clone,Deserialize,Serialize)]
 #[derive(Eq,PartialEq,Ord,PartialOrd,Hash)]
 pub enum AccountScope {
@@ -70,3 +72,13 @@ impl FromStr for ScopedName {
     ScopedName { scope, scoped_name }
   }
 }
+
+#[deerive(Serialize,Deserialize)]
+pub struct AccountRecord {
+  pub nick: String,
+  pub timezone: String,
+  pub access: Box<dyn PlayerAccessSpec>,
+}
+
+static ACCOUNTS : RwLock<Option<HashMap<AccountName, AccountRecord>>>
+  = const_rwlock_new(None);
index 4983c42d9a1ea3a57234a51854fab9c0a1942187..69589cd96b9f93c4fbfe1819c493c31cfff9e401 100644 (file)
@@ -43,10 +43,10 @@ pub struct ZLevel {
 pub struct GameState {
   pub table_size : Pos,
   pub pieces : Pieces,
-  pub players : PlayerMap,
   pub gen : Generation,
   pub log : VecDeque<(Generation, Arc<CommittedLogEntry>)>,
   pub max_z : ZCoord,
+  pub players : DenseSlotMap<PlayerId, AccountName>>,
 }
 
 #[derive(Debug,Serialize,Deserialize)]
@@ -61,11 +61,8 @@ pub struct PieceState {
   pub gen_before_lastclient : Generation,
 }
 
-pub type PlayerMap = DenseSlotMap<PlayerId,PlayerState>;
-
 #[derive(Debug,Clone,Serialize,Deserialize)]
 pub struct PlayerState {
-  pub nick : String,
 }
 
 #[derive(Debug,Serialize,Deserialize)]
index 5522e281ade342acaec9c7d5f6888c84996966c8..bdf91e73d6df8071baf62097036f43ee5f1bb662 100644 (file)
@@ -35,11 +35,22 @@ pub struct Instance {
   pub gs : GameState,
   pub pieces : PiecesLoaded,
   pub clients : DenseSlotMap<ClientId,Client>,
-  pub updates : SecondarySlotMap<PlayerId, PlayerUpdates>,
+  pub players : SecondarySlotMap<PlayerId, PlayerRecord>,
   pub tokens_players : TokenRegistry<PlayerId>,
   pub tokens_clients : TokenRegistry<ClientId>,
 }
 
+pub struct PlayerRecord {
+  pub u: PlayerUpdates,
+  pub st: PlayerState,
+}
+
+pub struct PlayerState {
+  pub account: AccountName,
+  pub nick: String,
+  pub tz: Timezone,
+}
+
 #[derive(Debug,Serialize,Deserialize)]
 #[serde(transparent)]
 pub struct PiecesLoaded (ActualPiecesLoaded);
index 8c4418a4186e6ff7f056079f7e4bb0ea117a2f5c..060487af80055fa847c8df6c25b3fc174acb84e1 100644 (file)
@@ -30,7 +30,6 @@ pub type PlayerUpdatesLog =
 pub struct PlayerUpdates {
   log : PlayerUpdatesLog,
   cv : Arc<Condvar>,
-  pub tz: Timezone,
 }
 
 #[derive(Debug)]