aboutsummaryrefslogtreecommitdiff
path: root/server/src/entity/conveyor.rs
diff options
context:
space:
mode:
Diffstat (limited to 'server/src/entity/conveyor.rs')
-rw-r--r--server/src/entity/conveyor.rs13
1 files changed, 7 insertions, 6 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,