From: Ian Jackson Date: Sat, 17 Oct 2020 17:12:28 +0000 (+0100) Subject: wip new account etc. X-Git-Tag: otter-0.2.0~622 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=7bd6ff0a6c6f7b5f1de2845b9a1a403bb700d379;p=otter.git wip new account etc. Signed-off-by: Ian Jackson --- 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)]