From: Ian Jackson Date: Sun, 31 Jan 2021 22:43:36 +0000 (+0000) Subject: hidden: Abolish Lens X-Git-Tag: otter-0.4.0~576 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=8a5249de5de46433b56fc98e02b7f4a8f2896094;p=otter.git hidden: Abolish Lens This is never used for anything and can be simply deleted now. Signed-off-by: Ian Jackson --- diff --git a/daemon/api.rs b/daemon/api.rs index 646d4097..b60281a3 100644 --- a/daemon/api.rs +++ b/daemon/api.rs @@ -40,7 +40,6 @@ struct ApiPieceOpArgs<'a> { player: PlayerId, piece: PieceId, p: &'a dyn Piece, - lens: &'a dyn Lens /* used for LogEntry and PieceId but not Pos */ } trait ApiPieceOp : Debug { @@ -85,10 +84,10 @@ impl<'r> Responder<'r> for OnlineErrorResponse { } } -fn log_did_to_piece( +fn log_did_to_piece( occults: &GameOccults, player: PlayerId, - gpl: &mut GPlayerState, _lens: &L, + gpl: &mut GPlayerState, piece: PieceId, pc: &PieceState, p: &dyn Piece, did: &str, ) -> Vec { @@ -119,7 +118,6 @@ fn api_piece_op(form : Json>) let iplayers = &g.iplayers; let _ = iplayers.byid(player)?; let gpl = gs.players.byid(player)?; - let lens = TransparentLens { }; let piece = vpiece_decode(gs, player, gpl, form.piece) .ok_or(OE::PieceGone)?; use ApiPieceOpError::*; @@ -141,21 +139,20 @@ fn api_piece_op(form : Json>) form.op.op(ApiPieceOpArgs { gs, player, piece, p: p.as_ref(), - lens: &lens, })?; Ok::<_,ApiPieceOpError>(update) })() { Err(ReportViaUpdate(poe)) => { PrepareUpdatesBuffer::piece_report_error( &mut ig, poe, - piece, vec![], POEPP::Unprocessed, client, form.cseq, &lens + piece, vec![], POEPP::Unprocessed, client, form.cseq, )?; debug!("api_piece_op Err(RVU): {:?}", &form); }, Err(PartiallyProcessed(poe, logents)) => { PrepareUpdatesBuffer::piece_report_error( &mut ig, poe, - piece, logents, POEPP::Partially, client, form.cseq, &lens + piece, logents, POEPP::Partially, client, form.cseq, )?; debug!("api_piece_op Err(PP): {:?}", &form); }, @@ -168,7 +165,7 @@ fn api_piece_op(form : Json>) Some((wrc, client, form.cseq)), Some(1 + log.len())); - buf.piece_update(piece, ops, &lens); + buf.piece_update(piece, ops); buf.log_updates(log); debug!("api_piece_op OK: {:?}", &form); @@ -226,7 +223,7 @@ api_route!{ } #[throws(ApiPieceOpError)] fn op(&self, a: ApiPieceOpArgs) -> PieceUpdate { - let ApiPieceOpArgs { gs,player,piece,p,lens, .. } = a; + let ApiPieceOpArgs { gs,player,piece,p, .. } = a; let gpl = gs.players.byid_mut(player)?; let pc = gs.pieces.byid_mut(piece)?; @@ -235,7 +232,7 @@ api_route!{ let update = PieceUpdateOp::ModifyQuiet(()); let logents = log_did_to_piece( - &gs.occults, player, gpl, lens, piece, pc, p, + &gs.occults, player, gpl, piece, pc, p, "grasped" ); @@ -286,7 +283,7 @@ api_route!{ } #[throws(ApiPieceOpError)] fn op(&self, a: ApiPieceOpArgs) -> PieceUpdate { - let ApiPieceOpArgs { gs,player,piece,p,lens, .. } = a; + let ApiPieceOpArgs { gs,player,piece,p, .. } = a; let gpl = gs.players.byid_mut(player).unwrap(); let pc = gs.pieces.byid_mut(piece).unwrap(); @@ -295,7 +292,7 @@ api_route!{ let update = PieceUpdateOp::Modify(()); let logents = log_did_to_piece( - &gs.occults, player, gpl, lens, piece, pc, p, + &gs.occults, player, gpl, piece, pc, p, "released" ); @@ -349,12 +346,12 @@ api_route!{ #[throws(ApiPieceOpError)] fn op(&self, a: ApiPieceOpArgs) -> PieceUpdate { - let ApiPieceOpArgs { gs,player,piece,p,lens, .. } = a; + let ApiPieceOpArgs { gs,player,piece,p, .. } = a; let pc = gs.pieces.byid_mut(piece).unwrap(); let gpl = gs.players.byid_mut(player).unwrap(); pc.angle = PieceAngle::Compass(self.0); let logents = log_did_to_piece( - &gs.occults, player, gpl, lens, piece, pc, p, + &gs.occults, player, gpl, piece, pc, p, "rotated" ); let update = PieceUpdateOp::Modify(()); @@ -369,13 +366,13 @@ api_route!{ #[throws(ApiPieceOpError)] fn op(&self, a: ApiPieceOpArgs) -> PieceUpdate { - let ApiPieceOpArgs { gs,player,piece,p,lens, .. } = a; + let ApiPieceOpArgs { gs,player,piece,p, .. } = a; let pc = gs.pieces.byid_mut(piece).unwrap(); let gpl = gs.players.byid_mut(player).unwrap(); pc.pinned = self.0; let update = PieceUpdateOp::Modify(()); let logents = log_did_to_piece( - &gs.occults, player, gpl, lens, piece, pc, p, + &gs.occults, player, gpl, piece, pc, p, if pc.pinned { "pinned" } else { "unpinned" }, ); (WhatResponseToClientOp::Predictable, @@ -393,7 +390,7 @@ api_route!{ } #[throws(ApiPieceOpError)] fn op(&self, a: ApiPieceOpArgs) -> PieceUpdate { - let ApiPieceOpArgs { gs,player,piece,p,lens, .. } = a; + let ApiPieceOpArgs { gs,player,piece,p, .. } = a; '_normal_global_ops__not_loop: loop { let pc = gs.pieces.byid_mut(piece)?; let gpl = gs.players.byid_mut(player)?; @@ -406,7 +403,7 @@ api_route!{ wrc, PieceUpdateOp::Modify(()), log_did_to_piece( - &gs.occults, player, gpl, lens, piece, pc, p, + &gs.occults, player, gpl, piece, pc, p, "flipped" ), ).into() @@ -423,7 +420,7 @@ api_route!{ }; } - p.ui_operation(gs, player, piece, &self.opname, self.wrc, lens)? + p.ui_operation(gs, player, piece, &self.opname, self.wrc)? } } diff --git a/daemon/cmdlistener.rs b/daemon/cmdlistener.rs index 43d65cd0..06da931c 100644 --- a/daemon/cmdlistener.rs +++ b/daemon/cmdlistener.rs @@ -820,8 +820,7 @@ impl UpdateHandler { let estimate = updates.pcs.len() + updates.log.len(); let mut buf = PrepareUpdatesBuffer::new(g, None, Some(estimate)); for (upiece, uuop) in updates.pcs { - let lens = TransparentLens { }; - buf.piece_update(upiece, PUO::Simple(uuop), &lens); + buf.piece_update(upiece, PUO::Simple(uuop)); } buf.log_updates(updates.log); buf.raw_updates(raw); @@ -836,8 +835,7 @@ impl UpdateHandler { Bulk(bulk) => { let mut buf = PrepareUpdatesBuffer::new(g, None, None); for (upiece, uuop) in bulk.pieces { - let lens = TransparentLens { }; - buf.piece_update(upiece, PUO::Simple(uuop), &lens); + buf.piece_update(upiece, PUO::Simple(uuop)); } if bulk.logs { diff --git a/src/gamestate.rs b/src/gamestate.rs index d53d85bb..d50baaed 100644 --- a/src/gamestate.rs +++ b/src/gamestate.rs @@ -129,8 +129,7 @@ pub trait Piece: Outline + Send + Debug { fn ui_operation(&self, _gs: &mut GameState, _player: PlayerId, _piece: PieceId, - _opname: &str, _wrc: WhatResponseToClientOp, - _lens: &dyn Lens) + _opname: &str, _wrc: WhatResponseToClientOp) -> PieceUpdateResult { throw!(OE::BadOperation) } diff --git a/src/global.rs b/src/global.rs index 7adfea36..29fa9c51 100644 --- a/src/global.rs +++ b/src/global.rs @@ -697,11 +697,10 @@ impl<'ig> InstanceGuard<'ig> { }))(); } - let lens = TransparentLens { }; let estimate = updated_pieces.len() + 1; let mut buf = PrepareUpdatesBuffer::new(self, None , Some(estimate)); for &piece in &updated_pieces { - buf.piece_update(piece, PieceUpdateOp::Modify(()).into(), &lens); + buf.piece_update(piece, PieceUpdateOp::Modify(()).into()); } buf.finish(); diff --git a/src/imports.rs b/src/imports.rs index e04dbde1..467fe9e6 100644 --- a/src/imports.rs +++ b/src/imports.rs @@ -92,7 +92,6 @@ pub use crate::gamestate::*; pub use crate::global::*; pub use crate::hidden::*; pub use crate::keydata::*; -pub use crate::lens::*; pub use crate::mgmtchannel::*; pub use crate::nwtemplates; pub use crate::pieces::*; diff --git a/src/lens.rs b/src/lens.rs deleted file mode 100644 index 50536ad0..00000000 --- a/src/lens.rs +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2020-2021 Ian Jackson and contributors to Otter -// SPDX-License-Identifier: AGPL-3.0-or-later -// There is NO WARRANTY. - -use crate::imports::*; - -// this ios going to be replaced with new "hidden" machiner -// -// For now, we are firstly removing all calls to everything except -// new_hidden_todo. -// -// Then we'll adjust all call sites of new_hidden_todo too and Lens -// can be abolished. - -pub trait Lens : Debug { -} -#[derive(Debug)] -pub struct TransparentLens { -} -impl Lens for TransparentLens { -} - diff --git a/src/lib.rs b/src/lib.rs index 9d208927..2fa2beb9 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -15,7 +15,6 @@ pub mod global; pub mod hidden; pub mod imports; pub mod keydata; -pub mod lens; pub mod mgmtchannel; pub mod nwtemplates; pub mod pieces; diff --git a/src/updates.rs b/src/updates.rs index 95b6e567..9b753e1c 100644 --- a/src/updates.rs +++ b/src/updates.rs @@ -432,13 +432,13 @@ impl<'r> PrepareUpdatesBuffer<'r> { error: PieceOpError, piece: PieceId, logents: Vec, partially: PieceOpErrorPartiallyProcessed, - client: ClientId, cseq: ClientSequence, - lens: &dyn Lens) -> Result<(),OE> { + client: ClientId, cseq: ClientSequence) + -> Result<(),OE> { let by_client = (WRC::Unpredictable, client, cseq); let mut buf = PrepareUpdatesBuffer::new(ig, Some(by_client), None); let ops = PUO::Simple(PieceUpdateOp::Modify(())); let state = buf.piece_update_fallible( - piece, ops, lens, |pc, gen, _by_client| { + piece, ops, |pc, gen, _by_client| { match partially { POEPP::Unprocessed => { } POEPP::Partially => { pc.gen = gen; pc.lastclient = default(); } @@ -458,8 +458,8 @@ impl<'r> PrepareUpdatesBuffer<'r> { pc: &mut PieceState, p: &Box, op: PieceUpdateOp<(),()>, - pri: &PieceRenderInstructions, - _lens: &dyn Lens) -> PreparedPieceUpdate + pri: &PieceRenderInstructions) + -> PreparedPieceUpdate { max_z.update_max(&pc.zlevel.z); @@ -484,7 +484,6 @@ impl<'r> PrepareUpdatesBuffer<'r> { #[throws(InternalError)] fn piece_update_fallible(&mut self, piece: PieceId, ops: PieceUpdateOps, - lens: &dyn Lens, gen_update: GUF) -> PreparedUpdateEntry_Piece where GUF: FnOnce(&mut PieceState, Generation, &IsResponseToClientOp) @@ -511,7 +510,7 @@ impl<'r> PrepareUpdatesBuffer<'r> { (Some(pc), Some(p)) => { let pri = piece_pri(&gs.occults, player, gpl, piece, *pc); Self::piece_update_player( - &mut gs.max_z, pc, p, ops, &pri, lens + &mut gs.max_z, pc, p, ops, &pri )? } _ => PreparedPieceUpdate { @@ -530,13 +529,12 @@ impl<'r> PrepareUpdatesBuffer<'r> { } } - pub fn piece_update(&mut self, piece: PieceId, ops: PieceUpdateOps, - lens: &dyn Lens) { + pub fn piece_update(&mut self, piece: PieceId, ops: PieceUpdateOps) { // Caller needs us to be infallible since it is too late by // this point to back out a game state change. let update = self.piece_update_fallible( - piece, ops, lens, + piece, ops, |pc, gen, by_client| { match *by_client { @@ -556,8 +554,8 @@ impl<'r> PrepareUpdatesBuffer<'r> { }) .map(|update| PUE::Piece(update)) .unwrap_or_else(|e| { - error!("piece update error! piece={:?} lens={:?} error={:?}", - piece, &lens, &e); + error!("piece update error! piece={:?} error={:?}", + piece, &e); PreparedUpdateEntry::Error(ErrorSignaledViaUpdate::InternalError) }); self.us.push(update);