Skip to content

Commit fe19564

Browse files
authored
Merge pull request #1280 from myk002/myk_zones
[quickfort] integrate with preserve-rooms
2 parents 3444064 + 07759c2 commit fe19564

File tree

3 files changed

+11
-20
lines changed

3 files changed

+11
-20
lines changed

changelog.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ Template for new versions:
3535
- `caravan`: DFHack dialogs for trade screens (both ``Bring goods to depot`` and the ``Trade`` barter screen) can now filter by item origins (foreign vs. fort-made) and can filter bins by whether they have a mix of ethically acceptable and unacceptable items in them
3636
- `caravan`: If you have managed to select an item that is ethically unacceptable to the merchant, an "Ethics warning" badge will now appear next to the "Trade" button. Clicking on the badge will show you which items that you have selected are problematic. The dialog has a button that you can click to deselect the problematic items in the trade list.
3737
- `confirm`: If you have ethically unacceptable items selected for trade, the "Are you sure you want to trade" confirmation will warn you about them
38+
- `quickfort`: ``#zone`` blueprints now integrated with `preserve-rooms` so you can create a zone and automatically assign it to a noble or administrative role
3839

3940
## Fixes
4041
- `timestream`: ensure child growth events (e.g. becoming an adult) are not skipped over

gui/quickfort.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ function BlueprintDialog:init()
6363
text_pen=COLOR_GREY,
6464
},
6565
widgets.ToggleHotkeyLabel{
66-
frame={t=0, l=12},
66+
frame={t=0, l=12, w=20},
6767
key='CUSTOM_ALT_L',
6868
label='Library:',
6969
options=options,
@@ -72,7 +72,7 @@ function BlueprintDialog:init()
7272
on_change=self:callback('update_setting', 'show_library')
7373
},
7474
widgets.ToggleHotkeyLabel{
75-
frame={t=0, l=35},
75+
frame={t=0, l=35, w=19},
7676
key='CUSTOM_ALT_H',
7777
label='Hidden:',
7878
options=options,

internal/quickfort/zone.lua

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,11 @@ if not dfhack_flags.module then
66
end
77

88
require('dfhack.buildings') -- loads additional functions into dfhack.buildings
9-
local utils = require('utils')
9+
local preserve_rooms = require('plugins.preserve-rooms')
1010
local quickfort_common = reqscript('internal/quickfort/common')
1111
local quickfort_building = reqscript('internal/quickfort/building')
1212
local quickfort_parse = reqscript('internal/quickfort/parse')
13+
local utils = require('utils')
1314

1415
local log = quickfort_common.log
1516
local logfn = quickfort_common.logfn
@@ -227,12 +228,6 @@ local function parse_location_props(props)
227228
return location_data
228229
end
229230

230-
local function get_noble_unit(noble)
231-
local unit = dfhack.units.getUnitByNobleRole(noble)
232-
if not unit then log('could not find a noble position for: "%s"', noble) end
233-
return unit
234-
end
235-
236231
local function parse_zone_config(c, props)
237232
if not rawget(zone_db_raw, c) then
238233
return 'Invalid', nil
@@ -250,13 +245,7 @@ local function parse_zone_config(c, props)
250245
props.name = nil
251246
end
252247
if props.assigned_unit then
253-
zone_data.assigned_unit = get_noble_unit(props.assigned_unit)
254-
if not zone_data.assigned_unit and props.assigned_unit:lower() == 'sheriff' then
255-
zone_data.assigned_unit = get_noble_unit('captain_of_the_guard')
256-
end
257-
if not zone_data.assigned_unit then
258-
log('could not find a unit assigned to noble position: "%s"', props.assigned_unit)
259-
end
248+
zone_data.assigned_unit = props.assigned_unit
260249
props.assigned_unit = nil
261250
end
262251
if db_entry.props_fn then db_entry.props_fn(zone_data, props) end
@@ -387,11 +376,12 @@ local function create_zone(zone, data, ctx)
387376
set_location(bld, data.location, ctx)
388377
data.location = nil
389378
end
390-
if data.assigned_unit then
391-
dfhack.buildings.setOwner(bld, data.assigned_unit)
392-
data.assigned_unit = nil
393-
end
379+
local assigned_unit = data.assigned_unit
380+
data.assigned_unit = nil
394381
utils.assign(bld, data)
382+
if assigned_unit then
383+
preserve_rooms.assignToRole(assigned_unit, bld)
384+
end
395385
return ntiles
396386
end
397387

0 commit comments

Comments
 (0)