From: Ian Jackson Date: Sun, 8 Nov 2020 12:17:01 +0000 (+0000) Subject: wip new game joining X-Git-Tag: otter-0.2.0~546 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=fd31fee041e9039e3bc769151a5d09692e132f9d;p=otter.git wip new game joining Signed-off-by: Ian Jackson --- diff --git a/src/bin/otter.rs b/src/bin/otter.rs index e22030dd..cff7739d 100644 --- a/src/bin/otter.rs +++ b/src/bin/otter.rs @@ -12,10 +12,11 @@ use std::cell::RefCell; use std::cell::Cell; type E = anyhow::Error; -type Insn = MgmtGameInstruction; -type Resp = MgmtGameResponse; +type Insn = MgmtGameInstruction; // xxx MGI +type Resp = MgmtGameResponse; // xxx MGR type AS = AccountScope; type APE = ArgumentParseError; +type TP = TablePermission; use argparse::action::ParseResult::Parsed; @@ -354,38 +355,39 @@ fn connect(ma: &MainOpts) -> Conn { chan } -const PLAYER_ALWAYS_PERMS : &[Perm] = [ +const PLAYER_ALWAYS_PERMS : &[TablePermission] = &[ TP::TestExistence, TP::ViewPublic, TP::AddPlayer, ]; -const PLAYER_DEFAULT_PERMS : &[Perm] = [ - TP::ChangePiecse +const PLAYER_DEFAULT_PERMS : &[TablePermission] = &[ + TP::ChangePieces, ]; fn setup_table(ma: &MainOpts, chan: &mut ConnForGame, spec: &TableSpec, purge_old_players: bool) -> Result<(),AE> { - let TableSpec { players, player_perms, timezone } = spec; + let TableSpec { players, player_perms, acl } = spec; let mut player_perms = player_perms.clone() - .unwrap_or(PLAYER_DEFAULT_PERMS.iter().collect()); + .unwrap_or(PLAYER_DEFAULT_PERMS.iter().cloned().collect()); player_perms.extend(PLAYER_ALWAYS_PERMS.iter()); - let mut acl = + let mut acl : RawAcl<_> = players.iter().map(|tps| AclEntry { - account_glob: tps.account_glob(); + account_glob: tps.account_glob(), allow: player_perms.clone(), - deny: default() + deny: default(), }) .chain( - spec.acl.iter() + spec.acl.ents.iter().cloned() ) .collect(); + let acl = acl.try_into()?; + let mut insns = vec![]; - insns.push(MGI::ClearLog); - insns.push(MGI::SetACL { acl }); - isnns.push(MGI::SetTimezone { tz: timezone.clone() }); + insns.push(Insn::ClearLog); + insns.push(Insn::SetACL { acl }); /* diff --git a/src/cmdlistener.rs b/src/cmdlistener.rs index d3e7ad2b..cc1454f1 100644 --- a/src/cmdlistener.rs +++ b/src/cmdlistener.rs @@ -502,6 +502,18 @@ fn execute_game_insn<'cs, 'igr, 'ig : 'igr>( Fine, ig_g) }, + ClearLog => { + let ag = AccountsGuard::lock(); + let (ig, _) = cs.check_acl(&ag, ig, PCH::Instance, &[TP::Super])?; + ig.gs.log.clear(); + (U{ pcs: vec![ ], + log: vec![ LogEntry { + html: Html(format!("{} cleared the log", &who)), + } ], + raw: None }, + Fine, ig) + }, + SetACL { acl } => { let ag = AccountsGuard::lock(); let (ig, _) = cs.check_acl(&ag, ig, PCH::Instance, &[TP::Super])?; diff --git a/src/spec.rs b/src/spec.rs index e5b9815a..04c2f1e7 100644 --- a/src/spec.rs +++ b/src/spec.rs @@ -74,7 +74,7 @@ pub enum TablePlayerSpec { AllLocal, } -type RawAcl = Vec>; +pub type RawAcl = Vec>; #[derive(Debug,Clone)] #[derive(Deserialize)] @@ -270,7 +270,7 @@ pub mod implementation { } impl TablePlayerSpec { - fn account_glob(&self) -> String { + pub fn account_glob(&self) -> String { fn scope_glob(scope: AccountScope) -> String { let mut out = "".to_string(); scope.display_name(&["*"], |s| Ok::<_,Impossible>(out += s)).unwrap();