bool VeinGenerator::scan_tiles() { for (int x = 0; x < size.x; x++) { for (int y = 0; y < size.y; y++) { df::coord2d column(x,y); // First find where layers start and end for (int z = map.maxZ(); z >= 0; z--) { Block *b = map.BlockAt(df::coord(x,y,z)); if (!b || !b->is_valid()) continue; if (!scan_layer_depth(b, column, z)) return false; } if (!adjust_layer_depth(column)) return false; // Collect tile data for (int z = map.maxZ(); z >= 0; z--) { Block *b = map.BlockAt(df::coord(x,y,z)); if (!b || !b->is_valid()) continue; if (!scan_block_tiles(b, column, z)) return false; map.discardBlock(b); } // Discard this column of parsed blocks map.trash(); } } return true; }
static int findTopBlock(MapCache &map, int x, int y) { for (int z = map.maxZ(); z >= 0; z--) { Block *b = map.BlockAt(df::coord(x,y,z)); if (b && b->is_valid() && !isSkyBlock(b)) return z; } return -1; }
void VeinGenerator::write_tiles() { for (int x = 0; x < size.x; x++) { for (int y = 0; y < size.y; y++) { df::coord2d column(x,y); for (int z = map.maxZ(); z >= 0; z--) { Block *b = map.BlockAt(df::coord(x,y,z)); if (!b || !b->is_valid()) continue; write_block_tiles(b, column, z); b->Write(); map.discardBlock(b); } map.trash(); } } }