Fix bug when parsing off-board stats
This commit is contained in:
@@ -1 +1,2 @@
|
|||||||
target/
|
target/
|
||||||
|
*.zzt
|
||||||
|
|||||||
+7
-1
@@ -37,11 +37,17 @@ fn main() -> Result<(), Box<dyn Error>> {
|
|||||||
for stat in &mut board.stats {
|
for stat in &mut board.stats {
|
||||||
// Print some of the data parsed.
|
// Print some of the data parsed.
|
||||||
let (x, y) = (stat.x as usize, stat.y as usize);
|
let (x, y) = (stat.x as usize, stat.y as usize);
|
||||||
|
let terrain = if x < 1 || x > 60 || y < 1 || y > 25 {
|
||||||
|
None
|
||||||
|
} else {
|
||||||
|
let terrain_index = (x - 1) + (y - 1) * 60;
|
||||||
|
Some(board.terrain[terrain_index])
|
||||||
|
};
|
||||||
println!(
|
println!(
|
||||||
" stat at ({}, {}): {:?}, {:?}",
|
" stat at ({}, {}): {:?}, {:?}",
|
||||||
x,
|
x,
|
||||||
y,
|
y,
|
||||||
board.terrain[(x - 1) + (y - 1) * 60],
|
terrain,
|
||||||
to_latin1(&stat.code)
|
to_latin1(&stat.code)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user