From 7bd6ff0a6c6f7b5f1de2845b9a1a403bb700d379 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Sat, 17 Oct 2020 18:12:28 +0100 Subject: [PATCH] wip new account etc. Signed-off-by: Ian Jackson --- src/accounts.rs | 12 ++++++++++++ src/gamestate.rs | 5 +---- src/global.rs | 13 ++++++++++++- src/updates.rs | 1 - 4 files changed, 25 insertions(+), 6 deletions(-) diff --git a/src/accounts.rs b/src/accounts.rs index 66e392b6..5e1201c6 100644 --- a/src/accounts.rs +++ b/src/accounts.rs @@ -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, +} + +static ACCOUNTS : RwLock>> + = const_rwlock_new(None); diff --git a/src/gamestate.rs b/src/gamestate.rs index 4983c42d..69589cd9 100644 --- a/src/gamestate.rs +++ b/src/gamestate.rs @@ -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)>, pub max_z : ZCoord, + pub players : DenseSlotMap>, } #[derive(Debug,Serialize,Deserialize)] @@ -61,11 +61,8 @@ pub struct PieceState { pub gen_before_lastclient : Generation, } -pub type PlayerMap = DenseSlotMap; - #[derive(Debug,Clone,Serialize,Deserialize)] pub struct PlayerState { - pub nick : String, } #[derive(Debug,Serialize,Deserialize)] diff --git a/src/global.rs b/src/global.rs index 5522e281..bdf91e73 100644 --- a/src/global.rs +++ b/src/global.rs @@ -35,11 +35,22 @@ pub struct Instance { pub gs : GameState, pub pieces : PiecesLoaded, pub clients : DenseSlotMap, - pub updates : SecondarySlotMap, + pub players : SecondarySlotMap, pub tokens_players : TokenRegistry, pub tokens_clients : TokenRegistry, } +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); diff --git a/src/updates.rs b/src/updates.rs index 8c4418a4..060487af 100644 --- a/src/updates.rs +++ b/src/updates.rs @@ -30,7 +30,6 @@ pub type PlayerUpdatesLog = pub struct PlayerUpdates { log : PlayerUpdatesLog, cv : Arc, - pub tz: Timezone, } #[derive(Debug)] -- 2.30.2