Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ Template for new versions:

## Fixes
- Fix broken weather lookup in ``World::ReadCurrentWeather``
- `buildingplan`: link planned gem and glass windows to existing rooms and zones
- Fixed a possible hang or assertion failure when pressing a hotkey while a DFHack GUI window was open but unfocused
- In ``Screen`` module, Fix out-of-bounds color table access when Lua pens use ``COLOR_RESET``
- `3dveins`: fix failure on embarks that cross midmap tiles
Expand Down
9 changes: 8 additions & 1 deletion library/modules/Buildings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,14 @@ static void zone_into_building_unidir(df::building* bld, df::building_civzonest*

static bool is_suitable_building_for_zoning(df::building* bld)
{
return bld->canMakeRoom();
switch (bld->getType())
{
case building_type::WindowGlass:
case building_type::WindowGem:
return true;
default:
return bld->canMakeRoom();
}
}

static void add_building_to_zone(df::building* bld, df::building_civzonest* zone)
Expand Down
50 changes: 50 additions & 0 deletions test/modules/buildings_fortress.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
config.target = 'core'
config.mode = 'fortress'

local function contains(vec, value)
for _,entry in ipairs(vec) do
if entry == value then return true end
end
return false
end

local function construct_window_in_zone(window_type)
for _,zone in ipairs(df.global.world.buildings.other.ANY_ZONE) do
if zone.room.extents then
for y = zone.y1, zone.y2 do
for x = zone.x1, zone.x2 do
local pos = xyz2pos(x, y, zone.z)
if not dfhack.buildings.findAtTile(pos) then
local bld = dfhack.buildings.constructBuilding{
pos=pos,
type=window_type,
filters=dfhack.buildings.getFiltersByType(
{}, window_type, -1, -1),
}
if bld then return bld, zone end
end
end
end
end
end
end

local function expect_window_linked(window_type)
local bld, zone = construct_window_in_zone(window_type)
expect.ne(nil, bld, 'could not find a zone tile suitable for a window')
if not bld then return end
dfhack.with_finalize(
function() dfhack.buildings.deconstruct(bld) end,
function()
expect.true_(contains(bld.relations, zone))
expect.true_(contains(zone.contained_buildings, bld))
end)
end

function test.constructed_gem_window_is_linked_to_zone()
expect_window_linked(df.building_type.WindowGem)
end

function test.constructed_glass_window_is_linked_to_zone()
expect_window_linked(df.building_type.WindowGlass)
end
Loading