Skip to content

Commit 33fface

Browse files
committed
Close #11 by adding a real number check
1 parent 8d4dfae commit 33fface

2 files changed

Lines changed: 16 additions & 1 deletion

File tree

WARNINGS.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,9 @@ Which makes the black squares stand out like a sore thumb if placed above the wa
8080
### Contains an unlinked PrisonMarker
8181
This cell contains a `PrisonMarker` that doesn't link to an interior cell. `PrisonMarker`s need to link to interiors containing `stolen_goods` to prevent crashes.
8282

83+
### Contains non-real position or rotation
84+
This reference's position or rotation is not a real number (NaN or Infinity) which breaks things.
85+
8386
## Supply chests
8487

8588
### Not available to all ranks

src/validators/cells.rs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,19 @@ impl Handler<'_> for CellValidator {
128128
_: &[&Reference],
129129
_: usize,
130130
) {
131-
if !reference.deleted.unwrap_or(false) && !record.is_interior() {
131+
if reference.deleted.unwrap_or(false) {
132+
return;
133+
}
134+
let invalid_coords = reference.translation.iter().any(|coord| !coord.is_finite())
135+
|| reference.rotation.iter().any(|coord| !coord.is_finite());
136+
if invalid_coords {
137+
println!(
138+
"Cell {} contains reference {} which has a non-real position or rotation",
139+
record.editor_id(),
140+
reference.id
141+
)
142+
}
143+
if !invalid_coords && !record.is_interior() {
132144
let (x, y) = record.data.grid;
133145
let x_bound = CELL_SIZE * x as f64;
134146
let y_bound = CELL_SIZE * y as f64;

0 commit comments

Comments
 (0)