Skip to content

Commit

Permalink
Merge pull request #4178 from myk002/myk_retire_zone
Browse files Browse the repository at this point in the history
[zone] don't count dangling references when retiring zones
  • Loading branch information
myk002 authored Jan 15, 2024
2 parents 0517556 + 8dad318 commit 6f8d83b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions docs/changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ Template for new versions:

## New Features
- `sort`: search and sort for the "choose unit to elevate to the barony" screen. units are sorted by the number of item preferences they have and the units are annotated with the items that they have preferences for
- `zone`: add button to location details page for retiring unused locations
- `gui/mass-remove`: new global keybinding: Ctrl-M while on the fort map

## Fixes
Expand Down
9 changes: 8 additions & 1 deletion plugins/lua/zone.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1168,12 +1168,19 @@ end
function RetireLocationOverlay:confirm_retire()
local details = mi.location_details
local location = details.selected_ab
local num_occupations, num_zones = 0, #location.contents.building_ids
local num_occupations, num_zones = 0, 0
for _, occupation in ipairs(location.occupations) do
if occupation.histfig_id ~= -1 then
num_occupations = num_occupations + 1
end
end
for _, zone_id in ipairs(location.contents.building_ids) do
-- there can be dangling references in this list; only count
-- "attached" zones that actually exist
if df.building.find(zone_id) then
num_zones = num_zones + 1
end
end
if num_occupations + num_zones > 0 then
local messages = {'Cannot retire location! Please:', ''}
if num_occupations > 0 then
Expand Down

0 comments on commit 6f8d83b

Please sign in to comment.