Skip to content

gui/export-world-map: precise locations of bridges; materials of bridges and roads - #1647

Open
Nekkowe wants to merge 4 commits into
DFHack:masterfrom
Nekkowe:bridge-export-exact-position
Open

Nekkowe wants to merge 4 commits into
DFHack:masterfrom
Nekkowe:bridge-export-exact-position

Conversation

@Nekkowe

@Nekkowe Nekkowe commented Oct 5, 2026 •

Copy link
Copy Markdown

This PR addresses the position of bridges in the geodata export (as discussed on Discord), pinpointing them down to the midmap tile rather than the world tile as before.

As a result, they now correctly coincide with roads crossing rivers (diamonds = old, starbursts = new):
image

image

It also adds an attribute for the exact materials of bridges and roads (e.g. mudstone, pear wood, willow...) using dfhack.matinfo.decode/2 for the names.

@Nekkowe Nekkowe changed the title export-world-map: precise locations of bridges, down from world tiles to midmap tiles gui/export-world-map: precise locations of bridges, down from world tiles to midmap tiles Oct 6, 2026
@Nekkowe Nekkowe changed the title gui/export-world-map: precise locations of bridges, down from world tiles to midmap tiles gui/export-world-map: precise locations of bridges; materials of bridges and roads Oct 6, 2026

@chdoc chdoc left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks pretty good, the requested changes are mostly nitpicks.

Comment on lines +45 to +46
local tile_array_width = df.global.world.world_data.constructions.width
local tile_array_height = df.global.world.world_data.constructions.height

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since df.global.world.world_data.constructions is a global object, it makes sense to get a global reference to this at the beginning of the file instead of various local references to its parts.

Comment on lines +48 to +49
for i = 1, tile_array_width do
for j = 1, tile_array_height do

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the point is to index a C++ data structure, please iterate from 0 to n-1

Comment on lines +74 to +75
local region_x = construction.square_pos["x"][0]
local region_y = construction.square_pos["y"][0]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
local region_x = construction.square_pos["x"][0]
local region_y = construction.square_pos["y"][0]
local region_x = construction.square_pos.x[0]
local region_y = construction.square_pos.y[0]

local material = ""

if df.item_type[square.item_type] == "WOOD" then
subtype = "wooden"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a strong preference, but I would prefer:

Suggested change
subtype = "wooden"
subtype = "wood"

for i = 1, tile_array_width do
for j = 1, tile_array_height do
for _, square in ipairs(df.global.world.world_data.constructions.map[i - 1]:_displace(j - 1).square) do
if df.world_construction_square_bridgest:is_instance(square) then

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of an instance check you may want to try using square:getType()

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.

2 participants