Skip to content

Commit

Permalink
Changes; prevent selecting in nil map block
Browse files Browse the repository at this point in the history
* Update autodump.lua
* Update autodump.rst
* Update changelog.txt
  • Loading branch information
Bumber64 authored Jul 31, 2024
1 parent 9f4b85f commit 73aea9a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
3 changes: 2 additions & 1 deletion changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ Template for new versions:
- `prioritize`: fix incorrect loading of persisted data on some OS types
- `list-waves`: no longer gets confused by units that leave the map and then return (e.g. squads who go out on raids)
- `fix/dead-units`: fix error when removing dead units from burrows and the unit with the greatest ID was dead
- `gui/autodump`: prevent dumping into walls or invalid map area, set proper projectile flags to prevent items from being destroyed
- `gui/autodump`: prevent dumping into walls or invalid map area, as well as selecting in unallocated blocks
- `gui/autodump`: set proper projectile flags to prevent items from being destroyed

## Misc Improvements
- `build-now`: if `suspendmanager` is running, run an unsuspend cycle immediately before scanning for buildings to build
Expand Down
2 changes: 1 addition & 1 deletion docs/gui/autodump.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ you draw boxes around items on the map, it will act on the selected items
instead. Double-click anywhere on the map to teleport the items there. Be wary
(or excited) that if you teleport the items into an unsupported position
(e.g., mid-air), then they will become projectiles and fall. Items may not be
teleported into walls or fortifications.
teleported into walls.

There are options to include or exclude forbidden items, items that are
currently tagged as being used by an active job, and items dropped by traders.
Expand Down
13 changes: 7 additions & 6 deletions gui/autodump.lua
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ function Autodump:select_box(bounds)
for x=bounds.x1,bounds.x2 do
local block = dfhack.maps.getTileBlock(xyz2pos(x, y, z))
local block_str = tostring(block)
if not seen_blocks[block_str] then
if block and not seen_blocks[block_str] then
seen_blocks[block_str] = true
self:select_items_in_block(block, bounds)
end
Expand Down Expand Up @@ -309,7 +309,7 @@ end
function Autodump:do_dump(pos)
pos = pos or dfhack.gui.getMousePos()
if not pos then --We check this before calling
dfhack.printerr('Autodump:do_dump called with bad pos!')
qerror('Autodump:do_dump called with bad pos!')
end

local tt = dfhack.maps.getTileType(pos)
Expand All @@ -319,11 +319,12 @@ function Autodump:do_dump(pos)
end

local on_ground
local shape_attrs = df.tiletype_shape.attrs[df.tiletype.attrs[tt].shape]
if shape_attrs.walkable then
on_ground = true --Floor, stair, or ramp
local shape = df.tiletype.attrs[tt].shape
local shape_attrs = df.tiletype_shape.attrs[shape]
if shape_attrs.walkable or shape == df.tiletype_shape.FORTIFICATION then
on_ground = true --Floor, stair, ramp, or fortification
elseif shape_attrs.basic_shape == df.tiletype_shape_basic.Wall then
dfhack.printerr('Dump tile blocked! Can\'t dump inside walls or fortifications.')
dfhack.printerr('Dump tile blocked! Can\'t dump inside walls.') --Wall or brook bed
return
end

Expand Down

0 comments on commit 73aea9a

Please sign in to comment.