Skip to content

'3dveins': fix failure on embarks that cross midmap tiles - #5913

Merged
ab9rf merged 2 commits into
DFHack:developfrom
Alistair-Afton:fix-3dveins-midmap
Sep 16, 2026
Merged

ab9rf merged 2 commits into
DFHack:developfrom
Alistair-Afton:fix-3dveins-midmap

Conversation

@Alistair-Afton

Copy link
Copy Markdown
Contributor

Summary

  • MapCache built biomes[] as a fixed 3x3 neighborhood anchored at region_x/16 and indexed it directly with map_block.region_offset. region_offset is actually relative to each block's own region_pos, so on embarks that span multiple midmap cells, blocks outside the anchor cell resolved their biomes to the wrong world region.
  • 3dveins then compared measured layer heights against the wrong geobiome spec and aborted with Layer height change ... instead of ... on such embarks.
  • biomes[] now covers the union of neighborhoods around every midmap cell the map touches, with a biome_index map from world region coords to slots. Block::biomeIndexAt resolves the offset through block->region_pos, matching Maps::getBlockTileBiomeRgn, probe, and changelayer.
  • Exported Maps::getBiomeRgnPos (previously an internal helper used by getBlockTileBiomeRgn/ReadGeology), now also guarding world_data and the index range.

Testing

  • Reproduced the issue on a real crossing embark (embark rect spanning midmap cells (5,1) and (6,1)): 3dveins aborted with Layer height change in layer 5 at (144 0 112): 3 instead of 4 on the old build.
  • Same embark on the new build: full statistics/generate/write cycle completes with no abort, and Maps::getTileBiomeRgn agrees with the corrected resolution.
  • Single-midmap-cell fortress: 3dveins still completes normally.
  • prospector (heavy MapCache consumer) smoke-tested on the crossing embark.

Fixes #5880

Alistair-Afton and others added 2 commits September 15, 2026 22:58
MapCache assumed that map block `region_offset` values index the biome
neighborhood of the map's anchor region (region_x/16). They actually index
the neighborhood of each block's own region_pos, so blocks in other midmap
cells resolved their biomes to the wrong region. On such embarks 3dveins
compared layer thicknesses against the wrong geobiome spec and aborted with
"Layer height change" errors.

The MapCache biome list now covers the neighborhood of every midmap cell
that the map touches, and biomeIndexAt resolves the biome through the
block's own region_pos. Maps::getBiomeRgnPos is exported for this; it was
already used internally by getBlockTileBiomeRgn and ReadGeology.

Fixes DFHack#5880
@ab9rf
ab9rf merged commit cac8698 into DFHack:develop Sep 16, 2026
14 checks passed
@Alistair-Afton
Alistair-Afton deleted the fix-3dveins-midmap branch September 16, 2026 01:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3dveins sometimes fails on embarks that cross midmap tiles

2 participants