@@ -220,14 +220,18 @@ public int CountTunedTiles()
220220
221221 internal void SaveRocklist ( string fileName )
222222 {
223+ Console . WriteLine ( string . Format ( "running rock detector on all runnable tiles, " +
224+ "saving resulting rocklist to \" {0}\" " , fileName ) ) ;
225+
223226 int numTiles = TilesVertical * TilesHorizontal ;
224227 var inSettings = new RockDetector . INSETTINGS [ numTiles ] ;
225228 var loaded = new bool [ numTiles ] ;
226229
227230 var tsd = TileShapeData ;
228231 var writeJSONOpts = new JsonSerializerOptions { WriteIndented = true } ;
229232
230- Console . WriteLine ( "loading settings for already-tuned tiles from " + GetDirectory ( Dir . FinalOutput ) ) ;
233+ Console . WriteLine ( string . Format ( "loading settings for already-tuned tiles from \" {0}\" " ,
234+ GetDirectory ( Dir . FinalOutput ) ) ) ;
231235 int numLoaded = 0 ;
232236 for ( int y = 0 ; y < TilesVertical ; y ++ )
233237 {
@@ -294,6 +298,7 @@ internal void SaveRocklist(string fileName)
294298 }
295299 }
296300
301+ int nc = 0 , nf = 0 ;
297302 for ( int y = 0 ; y < TilesVertical ; y ++ )
298303 {
299304 for ( int x = 0 ; x < TilesHorizontal ; x ++ )
@@ -313,8 +318,8 @@ internal void SaveRocklist(string fileName)
313318 int maxRadius = Math . Max ( x , y ) ;
314319 maxRadius = Math . Max ( maxRadius , TilesHorizontal - x - 1 ) ;
315320 maxRadius = Math . Max ( maxRadius , TilesVertical - y - 1 ) ;
316- Console . WriteLine ( string . Format ( "searching for tuned neighbor of tile at col {0}, row {1}, " +
317- "max radius {2}{3}" , x , y , maxRadius , grpMsg ) ) ;
321+ // Console.WriteLine(string.Format("searching for tuned neighbor of tile at col {0}, row {1}, " +
322+ // "max radius {2}{3}", x, y, maxRadius, grpMsg));
318323 int ni = - 1 ;
319324 for ( int radius = 1 ; radius <= maxRadius && ni < 0 ; radius ++ )
320325 {
@@ -346,8 +351,8 @@ internal void SaveRocklist(string fileName)
346351 if ( ni >= 0 )
347352 {
348353 GetTileAddress ( ni , out int nx , out int ny ) ;
349- Console . WriteLine ( string . Format ( "copying settings for tuned tile at col {0}, row {1} " +
350- "for tile at col {2}, row {3}{4}" , nx , ny , x , y , grpMsg ) ) ;
354+ // Console.WriteLine(string.Format("copying settings for tuned tile at col {0}, row {1} " +
355+ // "for tile at col {2}, row {3}{4}", nx, ny, x, y, grpMsg));
351356 inSettings [ idx ] = inSettings [ ni ] ;
352357 string srcName = ReviewRocks . GetTileOutputName ( ni , TilesHorizontal ) + ".json" ;
353358 string srcJSON = Path . Combine ( GetDirectory ( Dir . FinalOutput ) , srcName ) ;
@@ -362,29 +367,39 @@ internal void SaveRocklist(string fileName)
362367 string dstName = ReviewRocks . GetTileOutputName ( idx , TilesHorizontal ) + ".json" ;
363368 string dstJSON = Path . Combine ( dir , dstName ) ;
364369 File . WriteAllText ( dstJSON , JsonSerializer . Serialize ( data , data . GetType ( ) , writeJSONOpts ) ) ;
370+ nc ++ ;
365371 }
366372 else
367373 {
368374 //MaxShadowArea = 0 will cause RockDetector.detect_per_tile_settings() to ignore the tile
369375 Console . WriteLine ( string . Format ( "failed to find tuned tile from which to copy settings " +
370376 "for tile at col {0}, row {1}{2}" , x , y , grpMsg ) ) ;
377+ nf ++ ;
371378 }
372379 }
373380 }
374381 }
375382
376- //MaxShadowArea = 0 will cause RockDetector.detect_per_tile_settings() to ignore the tile
377- if ( tsd != null ) {
378- for ( int y = 0 ; y < TilesVertical ; y ++ )
383+ Console . WriteLine ( string . Format ( "copied settings for {0} un-tuned tiles from nearest tuned neighbor{1}" ,
384+ nc , tsd != null ? " in same shape file group" : "" ) ) ;
385+ Console . WriteLine ( string . Format ( "failed to copy settings for {0} un-tuned tiles from any tuned neighbor{1}" ,
386+ nf , tsd != null ? " in same shape file group" : "" ) ) ;
387+
388+ int nr = 0 ;
389+ for ( int y = 0 ; y < TilesVertical ; y ++ )
390+ {
391+ for ( int x = 0 ; x < TilesHorizontal ; x ++ )
379392 {
380- for ( int x = 0 ; x < TilesHorizontal ; x ++ )
381- {
382- int idx = GetTileIndex ( x , y ) ;
383- if ( tsd [ idx ] == null || ! tsd [ idx ] . run ) inSettings [ idx ] . MaxShadowArea = 0 ;
384- }
393+ int idx = GetTileIndex ( x , y ) ;
394+ //MaxShadowArea = 0 will cause RockDetector.detect_per_tile_settings() to ignore the tile
395+ if ( tsd != null && ( tsd [ idx ] == null || ! tsd [ idx ] . run ) ) inSettings [ idx ] . MaxShadowArea = 0 ;
396+ else if ( inSettings [ idx ] . MaxShadowArea > 0 ) nr ++ ;
385397 }
386398 }
387399
400+ Console . WriteLine ( string . Format ( "running rock detector on {0} runnable of {1} total tiles, " +
401+ "saving resulting rocklist to \" {2}\" " , nr , numTiles , fileName ) ) ;
402+
388403 RockDetector . detect_per_tile_settings ( ImagePath , fileName , numTiles , inSettings ) ;
389404 //TODO: warn
390405 }
0 commit comments