MCPcopy Create free account
hub / github.com/DFHack/dfhack / scan_layer_depth

Method scan_layer_depth

plugins/3dveins.cpp:760–816  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

758}
759
760bool VeinGenerator::scan_layer_depth(Block *b, df::coord2d column, int z)
761{
762 for (int x = 0; x < 16; x++)
763 {
764 for (int y = 0; y < 16; y++)
765 {
766 df::coord2d tile(x,y);
767 GeoLayer *layer = mapLayer(b, tile);
768 if (!layer)
769 continue;
770
771 int idx = layer->index;
772
773 auto &col_info = layer->biome->columns(column);
774 auto &max_level = col_info.max_level[x][y];
775 auto &min_level = col_info.min_level[x][y];
776 auto &top = col_info.top_layer[x][y];
777 auto &top_solid = col_info.top_solid_z[x][y];
778 auto &bottom = col_info.bottom_layer[x][y];
779
780 auto ttype = b->baseTiletypeAt(tile);
781 bool obsidian = isTransientMaterial(ttype);
782
783 if (top_solid < 0 && !obsidian && isWallTerrain(ttype))
784 top_solid = z;
785
786 if (max_level[idx] < 0)
787 {
788 // Do not start the layer stack in open air.
789 // Those tiles can be very weird.
790 if (bottom < 0 && (isOpenTerrain(ttype) || obsidian))
791 continue;
792
793 max_level[idx] = min_level[idx] = z;
794
795 if (top < 0 || idx < top)
796 top = idx;
797
798 bottom = std::max<int8_t>(idx, bottom);
799 }
800 else
801 {
802 if (z != min_level[idx]-1 && min_level[idx] <= top_solid)
803 {
804 WARN(process, out).print("Discontinuous layer {} at ({} {} {}).\n",
805 layer->index, x+column.x*16, y+column.y*16, z
806 );
807 return false;
808 }
809
810 min_level[idx] = z;
811 }
812 }
813 }
814
815 return true;
816}
817

Callers

nothing calls this directly

Calls 4

isTransientMaterialFunction · 0.85
isWallTerrainFunction · 0.85
isOpenTerrainFunction · 0.85
printMethod · 0.45

Tested by

no test coverage detected