From aaae17c6b2f1bb1ff8b60935e269193aa3da14de Mon Sep 17 00:00:00 2001 From: yukirij Date: Sun, 18 Aug 2024 16:55:30 -0700 Subject: [PATCH] Fix subtract with overflow bug. --- game/src/util/hex.rs | 6 +++--- www/.html | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/game/src/util/hex.rs b/game/src/util/hex.rs index fda692f..0710ad5 100644 --- a/game/src/util/hex.rs +++ b/game/src/util/hex.rs @@ -31,11 +31,11 @@ impl Hex { pub fn from_tile(tile:u8) -> Self { - let mut x = 0; + let mut x = 0i32; while tile >= ROWS[x as usize + 1] { x += 1; } - let y = tile - ROWS[x as usize] + ((x > 4) as u8 * (x - 4)); + let y = tile - ROWS[x as usize] + ((x > 4) as i32 * (x - 4)) as u8; Self { - x, + x:x as u8, y, tile, } diff --git a/www/.html b/www/.html index a52b463..0dffd91 100644 --- a/www/.html +++ b/www/.html @@ -5,7 +5,7 @@ - +