From: Ian Jackson Date: Sat, 22 Aug 2020 22:35:57 +0000 (+0100) Subject: switch to results of otter reset X-Git-Tag: otter-0.2.0~1095 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=484f9c2eb2704b1c699c91ff9460ef42c4456787;p=otter.git switch to results of otter reset USER=rustcargo target/debug/otter --scope-server reset dummy --reset-table ~ian/Rustup/Game/server/demo/test.{table,game}.toml generates what is now in save/ however, the server doesn't load it ? --- diff --git a/TODO b/TODO index d6a35fce..892c6a38 100644 --- a/TODO +++ b/TODO @@ -1,3 +1,8 @@ +loading does not seem to work + +templates directory not found unless we symlink it + + token in main url client ? struct ? instance struct diff --git a/save/g-dummy b/save/g-dummy index 74968de2..70627252 100644 Binary files a/save/g-dummy and b/save/g-dummy differ diff --git a/src/bin/server.rs b/src/bin/server.rs index e014a764..03c55031 100644 --- a/src/bin/server.rs +++ b/src/bin/server.rs @@ -81,8 +81,6 @@ fn main() { set_config(config); }; - xxx_global_setup().expect("global setup failed"); - let cl = CommandListener::new()?; cl.spawn()?; diff --git a/src/gamestate.rs b/src/gamestate.rs index 73d03025..178c4381 100644 --- a/src/gamestate.rs +++ b/src/gamestate.rs @@ -192,25 +192,3 @@ pub fn make_pieceid_visible(p : PieceId) -> VisiblePieceId { let kd : slotmap::KeyData = p.into(); VisiblePieceId(kd) } - -pub fn xxx_gamestate_init() -> GameState { - let mut pieces = DenseSlotMap::with_key(); - let mut gen = Generation(0); - for (pos, p) in xxx_make_pieces().expect("make pieces") { - let pr = PieceState { - pos, p, - face : 0.into(), - held : None, - lastclient : Default::default(), - zlevel : ZLevel{ z: 0f64 .try_into().unwrap(), zg: gen }, - gen, - gen_before_lastclient : Generation(0), - }; - gen.increment(); - pieces.insert(pr); - } - GameState { table_size : DEFAULT_TABLE_SIZE, - pieces, gen, players : Default::default(), - max_z: ZCoord(0.), - log : Default::default(), } -} diff --git a/src/global.rs b/src/global.rs index 8ef6eca8..b6d2a9c6 100644 --- a/src/global.rs +++ b/src/global.rs @@ -818,28 +818,3 @@ impl Default for ServerConfig { toml::de::from_str("").expect("parse empty string as ServerConfig") } } - -// ========== ad-hoc and temporary ========== - -const XXX_PLAYERS_TOKENS : &[(&str, &str)] = &[ - ("kmqAKPwK4TfReFjMor8MJhdRPBcwIBpe", "alice"), - ("ccg9kzoTh758QrVE1xMY7BQWB36dNJTx", "bob"), -]; - -#[throws(AE)] -pub fn xxx_global_setup() { - let gs = xxx_gamestate_init(); - let gref = Instance::new(InstanceName { - scope: ManagementScope::Server, - scoped_name: "dummy".to_string() - }, gs)?; - let mut g = gref.lock()?; - for (token, nick) in XXX_PLAYERS_TOKENS { - let player = g.player_new(PlayerState { - nick : nick.to_string(), - })?; - g.player_access_register_fixed(player, RawToken(token.to_string()), - Authorised::authorise())?; - } - g.save_access_now().unwrap(); -} diff --git a/src/spec.rs b/src/spec.rs index e06f7a25..cbbe7ca0 100644 --- a/src/spec.rs +++ b/src/spec.rs @@ -2,7 +2,7 @@ use serde::{Serialize,Deserialize}; use fehler::throws; -use index_vec::{define_index_type,IndexVec,index_vec}; +use index_vec::{define_index_type,IndexVec}; use crate::gamestate::PieceSpec; use std::fmt::Debug; use implementation::PlayerAccessSpec; @@ -133,20 +133,3 @@ mod implementation { } } } - -#[allow(clippy::type_complexity)] -pub fn xxx_make_pieces() -> Result)>,crate::pieces::SVGProcessingError> { - use crate::imports::*; - Ok(vec![ - ([ 90, 80 ], - piece_specs::Disc { - diam : 20, - faces : index_vec![ ColourSpec("red".to_string()), ColourSpec("grey".to_string()) ], - }.load()?), - ([ 90, 60 ], - piece_specs::Square { - size : vec![20], - faces : index_vec![ ColourSpec("blue".to_string()), ColourSpec("grey".to_string()) ], - }.load()?), - ]) -}