diff options
author | metamuffin <metamuffin@disroot.org> | 2024-10-13 22:21:44 +0200 |
---|---|---|
committer | metamuffin <metamuffin@disroot.org> | 2024-10-13 22:21:44 +0200 |
commit | 8300b2f1853e026a2c3d5d1aa40a185341deba47 (patch) | |
tree | 5fe814992e917ea1a06c2e9faf1fd72bf5bb097b /server/src/entity | |
parent | 21a9b4087b6612383ee4beb16c2576a4eeb6b38f (diff) | |
download | hurrycurry-8300b2f1853e026a2c3d5d1aa40a185341deba47.tar hurrycurry-8300b2f1853e026a2c3d5d1aa40a185341deba47.tar.bz2 hurrycurry-8300b2f1853e026a2c3d5d1aa40a185341deba47.tar.zst |
fix compile for new rust nightly
Diffstat (limited to 'server/src/entity')
-rw-r--r-- | server/src/entity/conveyor.rs | 13 | ||||
-rw-r--r-- | server/src/entity/item_portal.rs | 13 |
2 files changed, 14 insertions, 12 deletions
diff --git a/server/src/entity/conveyor.rs b/server/src/entity/conveyor.rs index e8ff34d7..6177ba9c 100644 --- a/server/src/entity/conveyor.rs +++ b/server/src/entity/conveyor.rs @@ -17,7 +17,7 @@ */ use super::{Entity, EntityContext}; use crate::interaction::interact; -use anyhow::{anyhow, Result}; +use anyhow::{anyhow, bail, Result}; use hurrycurry_protocol::{glam::IVec2, ItemIndex, ItemLocation}; #[derive(Debug, Clone)] @@ -62,11 +62,12 @@ impl Entity for Conveyor { } self.cooldown = 0.; - let [from, to] = c - .game - .tiles - .get_many_mut([&self.from, &self.to]) - .ok_or(anyhow!("conveyor does ends in itself"))?; + if self.from == self.to { + bail!("conveyor does ends in itself") + } + let [Some(from), Some(to)] = c.game.tiles.get_many_mut([&self.from, &self.to]) else { + bail!("at least one conveyor end not on map"); + }; interact( &c.game.data, diff --git a/server/src/entity/item_portal.rs b/server/src/entity/item_portal.rs index 8eda7a3c..3ea33fa6 100644 --- a/server/src/entity/item_portal.rs +++ b/server/src/entity/item_portal.rs @@ -17,7 +17,7 @@ */ use super::{Entity, EntityContext}; use crate::interaction::interact; -use anyhow::{anyhow, Result}; +use anyhow::{bail, Result}; use hurrycurry_protocol::{glam::IVec2, ItemLocation}; #[derive(Debug, Default, Clone)] @@ -28,11 +28,12 @@ pub struct ItemPortal { impl Entity for ItemPortal { fn tick(&mut self, c: EntityContext) -> Result<()> { - let [from, to] = c - .game - .tiles - .get_many_mut([&self.from, &self.to]) - .ok_or(anyhow!("conveyor does ends in itself"))?; + if self.from == self.to { + bail!("item portal ends in itself") + } + let [Some(from), Some(to)] = c.game.tiles.get_many_mut([&self.from, &self.to]) else { + bail!("at least one item portal end not on map"); + }; if from.item.is_some() { interact( |