From 911032cb80a6aeff5549e1038e19d0e0524abd3c Mon Sep 17 00:00:00 2001 From: Tom Barrett Date: Sun, 21 Mar 2021 17:24:51 +0100 Subject: fixed overflow issue --- src/main.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/main.rs') 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; -- cgit v1.2.3