diff options
| author | Freya Murphy <freya@freyacat.org> | 2025-11-08 19:16:57 -0500 |
|---|---|---|
| committer | Freya Murphy <freya@freyacat.org> | 2025-11-08 19:16:57 -0500 |
| commit | 9d94571468c6b8e03c066732091d762a494d3cf2 (patch) | |
| tree | baa469fc43dc7efedecf7fa748c407e5a7e2ecf4 /dungeon/src/pos.rs | |
| parent | dungeon: refactor astar to not be generic (diff) | |
| download | DungeonCrawl-9d94571468c6b8e03c066732091d762a494d3cf2.tar.gz DungeonCrawl-9d94571468c6b8e03c066732091d762a494d3cf2.tar.bz2 DungeonCrawl-9d94571468c6b8e03c066732091d762a494d3cf2.zip | |
dungeon: fix pos idx overflow
Diffstat (limited to 'dungeon/src/pos.rs')
| -rw-r--r-- | dungeon/src/pos.rs | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/dungeon/src/pos.rs b/dungeon/src/pos.rs index ac2d6d0..f6c5eb4 100644 --- a/dungeon/src/pos.rs +++ b/dungeon/src/pos.rs @@ -194,9 +194,8 @@ impl Pos { /// ``` #[must_use] pub const fn idx(self) -> usize { - let (x, y) = self.xy(); - let idx = x + y * MAP_SIZE; - idx as usize + let (x, y) = (self.x() as usize, self.y() as usize); + x + y * MAP_SIZE_USIZE } /// Converse an index into a possible x and y position |