From 7fae443071e5f0d7031cb3d944c6cc4e7f054bf9 Mon Sep 17 00:00:00 2001 From: Shane Madden Date: Mon, 5 Aug 2024 20:00:18 -0600 Subject: [PATCH 1/2] Use u8 for RoomXY ranges --- src/local/room_xy/game_math.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/local/room_xy/game_math.rs b/src/local/room_xy/game_math.rs index 46abcf1d..df19d2a4 100644 --- a/src/local/room_xy/game_math.rs +++ b/src/local/room_xy/game_math.rs @@ -58,9 +58,9 @@ impl RoomXY { /// ``` #[doc(alias = "distance")] #[inline] - pub fn get_range_to(self, target: RoomXY) -> u32 { + pub fn get_range_to(self, target: RoomXY) -> u8 { let (dx, dy) = self - target; - dx.abs().max(dy.abs()) as u32 + dx.unsigned_abs().max(dy.unsigned_abs()) } /// Checks whether this position is in the given range of another position. @@ -96,7 +96,7 @@ impl RoomXY { /// ``` #[doc(alias = "distance")] #[inline] - pub fn in_range_to(self, target: RoomXY, range: u32) -> bool { + pub fn in_range_to(self, target: RoomXY, range: u8) -> bool { self.get_range_to(target) <= range } From b042307717459245f1594e3aa8708ed58b24f53e Mon Sep 17 00:00:00 2001 From: Shane Madden Date: Mon, 5 Aug 2024 20:01:33 -0600 Subject: [PATCH 2/2] Add changelog --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index d4382c13..f1c53269 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,10 @@ Unreleased ========== +### Breaking: + +- Change return type of `RoomXY::get_range_to` and input type of `RoomXY::in_range_to` to u8 + ### Misc: - Move crate constant `ROOM_AREA` to extra constants module and make public