Skip to content

Commit

Permalink
Use u8 for RoomXY ranges (#526)
Browse files Browse the repository at this point in the history
  • Loading branch information
shanemadden authored Aug 18, 2024
1 parent 9e63c8d commit 1e09176
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
Unreleased
==========

### Breaking:

- Change return type of `RoomXY::get_range_to` and input type of `RoomXY::in_range_to` to u8

### Additions:

- Make `RoomName::from_packed` and `RoomName::packed_repr` public

0.21.3 (2024-08-14)
Expand Down
6 changes: 3 additions & 3 deletions src/local/room_xy/game_math.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
}

Expand Down

0 comments on commit 1e09176

Please sign in to comment.