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 changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ Template for new versions:
## New Features

## Fixes
- `gui/siegemanager`: Added error message in the console if no siege engine is selected

## Misc Improvements

Expand Down
4 changes: 4 additions & 0 deletions gui/siegemanager.lua
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,10 @@ end
function SiegeEngineList:set_selected_action(action)
local _, selected = self.subviews.list:getSelected()

if not selected then
qerror('No siege engine selected')
end

Comment on lines +419 to +422
Copy link
Member

Choose a reason for hiding this comment

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

I think this is fundamentally the wrong way to fix the problem. All it does is change the error instead of avoiding it. The underlying issue is that the labels for setting the siege engines stance are enabled even if there is no siege engine selected. Thus, the right way to address this is to provide a function/callback that checks whether the labels should be enabled, as has been done here for example:

scripts/idle-crafting.lua

Lines 576 to 580 in 56c934e

enabled = function()
local bld = dfhack.gui.getSelectedBuilding(true)
if not bld then return end
return not invalidProfile(bld)
end,

local successful = set_siege_engine_action({selected.data}, action)
if not successful then
self:refresh_view(true)
Expand Down
Loading