summaryrefslogtreecommitdiff
path: root/src/main.rs
diff options
context:
space:
mode:
authorTom Barrett <tom@tombarrett.xyz>2021-03-21 17:24:51 +0100
committerTom Barrett <tom@tombarrett.xyz>2021-03-21 17:24:51 +0100
commit911032cb80a6aeff5549e1038e19d0e0524abd3c (patch)
tree92789f3ce9f892208a2fb4fea478f76dd2f3d1ff /src/main.rs
parent42c0f017348ef2033b6889b272f31f0c5eb5d41d (diff)
fixed overflow issue
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/main.rs b/src/main.rs
index bab21a0..f0a7eb6 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -414,9 +414,9 @@ fn mouse_system(
if let Some(mut selected) = cells.clone().iter_mut().find(|c| c.selected) {
if let Some(mut hovered) = cells.iter_mut().find(|c| c.hovered) {
if (selected.x == hovered.x + 1 && selected.y == hovered.y)
- || (selected.x == hovered.x - 1 && selected.y == hovered.y)
+ || (selected.x == hovered.x.overflowing_sub(1).0 && selected.y == hovered.y)
|| (selected.y == hovered.y + 1 && selected.x == hovered.x)
- || (selected.y == hovered.y - 1 && selected.x == hovered.x)
+ || (selected.y == hovered.y.overflowing_sub(1).0 && selected.x == hovered.x)
{
let tmp = selected.occupant;
selected.occupant = hovered.occupant;