Skip to content

Commit 1bb2fd8

Browse files
committed
Report underwater nodes
1 parent cf25f46 commit 1bb2fd8

File tree

2 files changed

+39
-8
lines changed

2 files changed

+39
-8
lines changed

WARNINGS.md

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,6 @@ See [this bug](https://github.com/TD-Addon/TD_Addon/issues/110).
3333
This object contains or creates an object that is supposed to be unique to the vanilla game.
3434
This includes things like quest rewards and vendor chests.
3535

36-
### Has a fog density of 0
37-
This can cause [graphical issues](https://en.uesp.net/wiki/Morrowind_Mod:Fogbug).
38-
3936
### Is not calculated for all levels
4037
This levelled list does not have `Calculate from all levels <= PC's level` checked, despite containing entries of different levels.
4138
Any entries in this list set to spawn at levels below the entries with the highest level smaller than or equal to the player's level will not appear.
@@ -125,7 +122,7 @@ This NPC is using upright Khajiit animations despite not being one of the Khajii
125122
### Has multiple slave bracers
126123
Slaves should generally only wear a single slave bracer.
127124

128-
## Knows spell
125+
### Knows spell
129126
This NPC knows a spell that is culturally or geographically inappropriate.
130127

131128
## Keys
@@ -281,6 +278,21 @@ This magic effect needs a magnitude to be useful. Might be fine if the spell is
281278
### Uses effect with duration 1
282279
This magic effect needs a duration to be useful. Might be fine if the spell is only meant to be detected by a script.
283280

281+
## Cells
282+
283+
### Has a fog density of 0
284+
This can cause [graphical issues](https://en.uesp.net/wiki/Morrowind_Mod:Fogbug).
285+
286+
### PathGrid contains underwater node
287+
Path grids that are underwater aren't used.
288+
289+
### PathGrid contains duplicate node
290+
There's two nodes in the same spot. Delete one and fix the connections.
291+
292+
### PathGrid contains unconnected node
293+
Nodes that aren't connected to any other nodes are useless.
294+
If you have a single-tile room with a locked door, just omit the path grid instead of adding a single unconnected node.
295+
284296
# The extended validator (`--extended`)
285297

286298
## Ownership checks

src/validators/cells.rs

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,12 @@ const BLACK_SQUARES: [&str; 4] = [
2222
pub struct CellValidator {
2323
seen: HashSet<String>,
2424
broken: HashMap<&'static str, &'static str>,
25+
water_levels: HashMap<String, f32>,
2526
}
2627

2728
fn get_point_coords(point: &PathGridPoint, record: &PathGrid) -> String {
28-
let [x_pos, y_pos, _] = point.location;
29-
let location = format!("[{}, {}]", x_pos, y_pos);
29+
let [x_pos, y_pos, z_pos] = point.location;
30+
let location = format!("[{}, {}, {}]", x_pos, y_pos, z_pos);
3031
let (x, y) = record.data.grid;
3132
if x != 0 || y != 0 {
3233
let ext_x = x_pos + x * CELL_SIZE as i32;
@@ -58,18 +59,35 @@ impl Handler<'_> for CellValidator {
5859
{
5960
println!("Cell {} has a fog density of 0", cell.editor_id());
6061
}
62+
if let Some(height) = get_water_height(cell) {
63+
self.water_levels
64+
.insert(cell.editor_id_ascii_lowercase().into_owned(), height);
65+
}
6166
}
6267
TES3Object::PathGrid(pathgrid) => {
6368
let points = &pathgrid.points;
6469
if points.is_empty() {
6570
return;
6671
}
72+
let cell = if pathgrid.data.grid == (0, 0) && !pathgrid.cell.is_empty() {
73+
pathgrid.cell.clone()
74+
} else {
75+
pathgrid.editor_id().into_owned()
76+
};
77+
let water_level = self.water_levels.get(&cell.to_ascii_lowercase());
6778
let mut connected: HashSet<u32> = HashSet::new();
6879
connected.extend(&pathgrid.connections);
6980
for (i, point) in points.iter().enumerate() {
7081
if point.connection_count > 0 {
7182
connected.insert(i as u32);
7283
}
84+
if water_level.is_some_and(|h| (point.location[2] as f32) < *h) {
85+
println!(
86+
"PathGrid {} contains underwater node at {}",
87+
cell,
88+
get_point_coords(point, pathgrid)
89+
);
90+
}
7391
for other_point in points[i + 1..].iter() {
7492
if point
7593
.location
@@ -79,7 +97,7 @@ impl Handler<'_> for CellValidator {
7997
{
8098
println!(
8199
"PathGrid {} contains duplicate node at {}",
82-
pathgrid.editor_id(),
100+
cell,
83101
get_point_coords(point, pathgrid)
84102
);
85103
break;
@@ -91,7 +109,7 @@ impl Handler<'_> for CellValidator {
91109
if !connected.contains(&(i as u32)) {
92110
println!(
93111
"PathGrid {} contains unconnected node at {}",
94-
pathgrid.editor_id(),
112+
cell,
95113
get_point_coords(point, pathgrid)
96114
);
97115
}
@@ -195,6 +213,7 @@ impl CellValidator {
195213
Self {
196214
seen: HashSet::new(),
197215
broken: get_broken_data(),
216+
water_levels: HashMap::new(),
198217
}
199218
}
200219
}

0 commit comments

Comments
 (0)