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 @@ -34,6 +34,7 @@ Template for new versions:

## Fixes
- `bodyswap`: fix "invalid argument count" when the target unit has no nemesis record
- `source`: report a useful error when no keyboard cursor is active
- `fix/loyaltycascade`: guard against citizens that are not historical figures and emit a warning.
- `gui/siegemanager`: fix nil index if there are no siege engines on the map

Expand Down
2 changes: 1 addition & 1 deletion source.lua
Original file line number Diff line number Diff line change
Expand Up @@ -132,12 +132,12 @@ function main(args)
end

local targetPos = guidm.getCursorPos()
local index = find_liquid_source_at_pos(targetPos)

if command == 'delete' then
if not targetPos then
qerror("Please place the cursor where there is a source to delete")
end
local index = find_liquid_source_at_pos(targetPos)
if index then
delete_liquid_source(targetPos)
print(('Deleted source at %s'):format(formatPos(targetPos)))
Expand Down
23 changes: 23 additions & 0 deletions test/source.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
config = {
mode = 'fortress',
target = 'source',
}

local guidm = require('gui.dwarfmode')
local source = reqscript('source')

function test.delete_requires_cursor()
mock.patch(guidm, 'getCursorPos', function() end, function()
expect.error_match(
'Please place the cursor where there is a source to delete',
function() source.main{'delete'} end)
end)
end

function test.add_requires_cursor()
mock.patch(guidm, 'getCursorPos', function() end, function()
expect.error_match(
'Please place the cursor where you would like a source',
function() source.main{'add', 'water'} end)
end)
end