Ok, got it.
I think I might have found another bug, for real this time
Actually one could count it as two, but with the same pattern and the same fix.
Have a look at
https://github.com/DFHack/dfhack/blob/f20446534bb7f39425e102bd70daec46e328004f/plugins/embark-assistant/survey.cpp#L1922https://github.com/DFHack/dfhack/blob/f20446534bb7f39425e102bd70daec46e328004f/plugins/embark-assistant/survey.cpp#L1996If k is 15 (in the case of translate_ns_edge) or i is 15 (in the case of translate_ew_edge), which means the incursion would cross world-tile boundaries to the south/east a wrong/illegal value for biome_x/biome_y is being used (out-of-bound read access for i/k==16). Whatever memory is being read is being interpreted as int8_t, but might be something completely different.
There is no access violation or any other error thrown, but there is a chance that the incursion results for these corner cases are bogus - also depending on the regions of the two embark/mid_level_tiles
involved in the comparison.
Do you agree with my assessment?
If I'm right, the fix is two-fold:
1. store world_data->region_details[0]->edges.biome_x[0-15][0]/biome_y[0][0-15] in the region_tile_datum, similar to
https://github.com/DFHack/dfhack/blob/f20446534bb7f39425e102bd70daec46e328004f/plugins/embark-assistant/defs.h#L116https://github.com/DFHack/dfhack/blob/f20446534bb7f39425e102bd70daec46e328004f/plugins/embark-assistant/defs.h#L117retaining the the northern row of biome_x and the western column of biome_y.
2. add distinct cases when accessing biome_x/biome_y similar to
https://github.com/DFHack/dfhack/blob/f20446534bb7f39425e102bd70daec46e328004f/plugins/embark-assistant/survey.cpp#L1684to
https://github.com/DFHack/dfhack/blob/f20446534bb7f39425e102bd70daec46e328004f/plugins/embark-assistant/survey.cpp#L1692including adjust_coordinates as in
https://github.com/DFHack/dfhack/blob/f20446534bb7f39425e102bd70daec46e328004f/plugins/embark-assistant/survey.cpp#L1660To allow for a 1/1.5 pass incursion processing I'll need the data anyway - so I can provide the necessary changes once I've made them and they work as intended.
Ah, and one actual question concerning the incursion processing at the edges of the world.
Of course there can't be any processing of edges from/to the outside of the world.
But what about the corners? Let's say we're at the southern edge of the world (y == world_data->world_height - 1 && k == 15).
Would it be possible to process the southern (-west/-east) corners to see if there is an incursion from/to the neighboring tile (i+/-1) within the same world-tile, ignoring the 2 non-existing corners/tiles further to the south?
Or would the needed data live in the non-existing southern world-tile neighbor (y+1)?
What about the other edges of the world (west/north)? Can those corner (north-west + south-west / north-west + north-east) be processed with the available data?
Long question short:
Is it possible to process corner incursion at the edge of the world with only two candidates and if so for which world-edges is it possible?