From 5988237b3d879db580a5ccb2955b500697318e3c Mon Sep 17 00:00:00 2001 From: Joshua Barretto Date: Wed, 17 May 2023 09:10:29 +0100 Subject: [PATCH] Fixed non-dismounting teleportation --- server/src/cmd.rs | 37 +++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/server/src/cmd.rs b/server/src/cmd.rs index f9723bc9c0..6f56b3b970 100644 --- a/server/src/cmd.rs +++ b/server/src/cmd.rs @@ -230,26 +230,28 @@ fn position_mut( dismount_volume: Option, f: impl for<'a> FnOnce(&'a mut comp::Pos) -> T, ) -> CmdResult { - let entity = if dismount_volume.unwrap_or(true) { + if dismount_volume.unwrap_or(true) { server .state .ecs() .write_storage::>() .remove(entity); - entity - } else { - server - .state - .read_storage::>() - .get(entity) - .and_then(|is_rider| { - server - .state - .ecs() - .read_resource::() - .retrieve_entity_internal(is_rider.mount.into()) - }) - .or(server + } + + let entity = server + .state + .read_storage::>() + .get(entity) + .and_then(|is_rider| { + server + .state + .ecs() + .read_resource::() + .retrieve_entity_internal(is_rider.mount.into()) + }) + .map(Ok) + .or_else(|| { + server .state .read_storage::>() .get(entity) @@ -265,9 +267,8 @@ fn position_mut( .retrieve_entity_internal(uid.into())?), }) }) - .transpose()?) - .unwrap_or(entity) - }; + }) + .unwrap_or(Ok(entity))?; let mut maybe_pos = None;