@@ -22,11 +22,12 @@ const BLACK_SQUARES: [&str; 4] = [
22
22
pub struct CellValidator {
23
23
seen : HashSet < String > ,
24
24
broken : HashMap < & ' static str , & ' static str > ,
25
+ water_levels : HashMap < String , f32 > ,
25
26
}
26
27
27
28
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 ) ;
30
31
let ( x, y) = record. data . grid ;
31
32
if x != 0 || y != 0 {
32
33
let ext_x = x_pos + x * CELL_SIZE as i32 ;
@@ -58,18 +59,35 @@ impl Handler<'_> for CellValidator {
58
59
{
59
60
println ! ( "Cell {} has a fog density of 0" , cell. editor_id( ) ) ;
60
61
}
62
+ if let Some ( height) = get_water_height ( cell) {
63
+ self . water_levels
64
+ . insert ( cell. editor_id_ascii_lowercase ( ) . into_owned ( ) , height) ;
65
+ }
61
66
}
62
67
TES3Object :: PathGrid ( pathgrid) => {
63
68
let points = & pathgrid. points ;
64
69
if points. is_empty ( ) {
65
70
return ;
66
71
}
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 ( ) ) ;
67
78
let mut connected: HashSet < u32 > = HashSet :: new ( ) ;
68
79
connected. extend ( & pathgrid. connections ) ;
69
80
for ( i, point) in points. iter ( ) . enumerate ( ) {
70
81
if point. connection_count > 0 {
71
82
connected. insert ( i as u32 ) ;
72
83
}
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
+ }
73
91
for other_point in points[ i + 1 ..] . iter ( ) {
74
92
if point
75
93
. location
@@ -79,7 +97,7 @@ impl Handler<'_> for CellValidator {
79
97
{
80
98
println ! (
81
99
"PathGrid {} contains duplicate node at {}" ,
82
- pathgrid . editor_id ( ) ,
100
+ cell ,
83
101
get_point_coords( point, pathgrid)
84
102
) ;
85
103
break ;
@@ -91,7 +109,7 @@ impl Handler<'_> for CellValidator {
91
109
if !connected. contains ( & ( i as u32 ) ) {
92
110
println ! (
93
111
"PathGrid {} contains unconnected node at {}" ,
94
- pathgrid . editor_id ( ) ,
112
+ cell ,
95
113
get_point_coords( point, pathgrid)
96
114
) ;
97
115
}
@@ -195,6 +213,7 @@ impl CellValidator {
195
213
Self {
196
214
seen : HashSet :: new ( ) ,
197
215
broken : get_broken_data ( ) ,
216
+ water_levels : HashMap :: new ( ) ,
198
217
}
199
218
}
200
219
}
0 commit comments