I'm looking to generate a list of positions based on certain criteria when the fortress map is loaded (e.g. all surface positions, all cavern positions, etc...). Is there a more efficient way to go about it than just brute forcing through each tile? I can get all the surface tiles fairly quickly by starting at the top in a corner, going down in z until I go underground, and then starting from that z in the next tile over and iterating through all the x,y pairs that way. But getting all cavern positions would require going through potentially millions of tiles, which I'd rather avoid if possible.
There's some data structures that might be relevant:
df.global.features.map_features[
#].layer, although I'm not sure what the number means.
df.global.world.map.map_block_columns.cave_columns[
#][
#].item - anon_2 seems like it could be z-level, looking at values and comparing them with embark's (internal) surface zlevel.
It was a while ago,but iirc when I deleted the bottom/right edges in 1x1 embark, I only got wildlife from top and left edges, so might be relevant for areas the game considers pathable.
PS: Also, it's faster to use dfhack.maps.getTileFlags(x,y) than block.designation[x%16][y%16]. Though ultimately it seems it's about the number of calls; recently managed to cut down time taken by 20ish% just by replacing text .. tostring(number) with text .. number in a bit of code when dealing with maps.