From 73aea9af724cdefad758e982f95a8e0a346e607e Mon Sep 17 00:00:00 2001 From: Ryan Williams Date: Tue, 30 Jul 2024 21:57:19 -0700 Subject: [PATCH] Changes; prevent selecting in nil map block * Update autodump.lua * Update autodump.rst * Update changelog.txt --- changelog.txt | 3 ++- docs/gui/autodump.rst | 2 +- gui/autodump.lua | 13 +++++++------ 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/changelog.txt b/changelog.txt index 9c3b96618..533281283 100644 --- a/changelog.txt +++ b/changelog.txt @@ -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 diff --git a/docs/gui/autodump.rst b/docs/gui/autodump.rst index 2d92bfa41..1b8b28c82 100644 --- a/docs/gui/autodump.rst +++ b/docs/gui/autodump.rst @@ -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. diff --git a/gui/autodump.lua b/gui/autodump.lua index f1975c0ce..d3ec16c84 100644 --- a/gui/autodump.lua +++ b/gui/autodump.lua @@ -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 @@ -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) @@ -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