From: Ian Jackson Date: Sat, 30 Apr 2022 12:21:00 +0000 (+0100) Subject: Move op_do_set_z to gamestate X-Git-Tag: otter-1.1.0~396 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=0fd60d8edd31d377447da5859ca6c43644828bf4;p=otter.git Move op_do_set_z to gamestate This is preparatory, to reduce diff noise. We're going to change the way this works in a moment. Signed-off-by: Ian Jackson --- diff --git a/daemon/api.rs b/daemon/api.rs index 7ad73c40..22c83fa0 100644 --- a/daemon/api.rs +++ b/daemon/api.rs @@ -464,14 +464,6 @@ api_route!{ } } -#[throws(ApiPieceOpError)] -fn op_do_set_z(gpc: &mut GPiece, gen: Generation, z: &ZCoord) { - if gpc.occult.is_active() { - if z >= &gpc.zlevel.z { throw!(Ia::Occultation) } - } - gpc.zlevel = ZLevel { z: z.clone(), zg: gen }; -} - api_route!{ api_move, "/_/api/m", struct ApiPieceMove(Pos); diff --git a/src/gamestate.rs b/src/gamestate.rs index 5ef3a5cb..96e848f9 100644 --- a/src/gamestate.rs +++ b/src/gamestate.rs @@ -804,6 +804,16 @@ mod test { } } +// ---------- 2-phase Z level setting ---------- + +#[throws(ApiPieceOpError)] +pub fn op_do_set_z(gpc: &mut GPiece, gen: Generation, z: &ZCoord) { + if gpc.occult.is_active() { + if z >= &gpc.zlevel.z { throw!(Ia::Occultation) } + } + gpc.zlevel = ZLevel { z: z.clone(), zg: gen }; +} + // ---------- log expiry ---------- impl GameState {