diff options
author | Tom Barrett <tom@tombarrett.xyz> | 2021-03-21 17:24:51 +0100 |
---|---|---|
committer | Tom Barrett <tom@tombarrett.xyz> | 2021-03-21 17:24:51 +0100 |
commit | 911032cb80a6aeff5549e1038e19d0e0524abd3c (patch) | |
tree | 92789f3ce9f892208a2fb4fea478f76dd2f3d1ff /src/main.rs | |
parent | 42c0f017348ef2033b6889b272f31f0c5eb5d41d (diff) |
fixed overflow issue
Diffstat (limited to 'src/main.rs')
-rw-r--r-- | src/main.rs | 4 |
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; |