dfhack icon indicating copy to clipboard operation
dfhack copied to clipboard

[WIP] Channel safely

Open cppcooper opened this issue 3 years ago • 3 comments

Looking to rewrite via:

https://github.com/DFHack/dfhack/pull/1879#discussion_r846696723 - @myk002 and the one following.

cppcooper avatar Apr 22 '22 03:04 cppcooper

Is this marked draft since the code is still in flux?

myk002 avatar Apr 28 '22 03:04 myk002

Is this marked draft since the code is still in flux?

Effectively, yes. And because I have no idea when I'll get to this. I do think the tick event will be a nice way to assure safety during the job though.

cppcooper avatar Apr 28 '22 04:04 cppcooper

edit: so here's the game plan for this implementation so far. ~~I'll update if changes to it are made.~~ It is a bit out of date at this point

channel-safely
==============

.. dfhack-tool::
    :summary: Auto-manage channel designations to keep dwarves safe
    :tags: fort auto

Multi-level channel projects can be dangerous, and managing the safety of your
dwarves throughout the completion of such projects can be difficult and time
consuming. This plugin keeps your dwarves safe (while channeling) so you don't
have to. Now you can focus on designing your dwarven cities with the deep chasms
they were meant to have.

Usage
-----

::
    enable channel-safely
    channel-safely set <setting> <value>
    channel-safely enable|disable <feature>
    channel-safely run once

When enabled the map will be scanned for channel designations which will be grouped
together based on adjacency and z-level. These groups will then be analyzed for safety
and designations deemed unsafe will be put into :wiki:`Marker Mode <Designations_menu#Marker_Mode>`.
Each time a channel designation is completed its group status is checked, and if the group
is complete pending groups below are made active again.

Examples
--------

``channel-safely``
    The plugin reports its configured status.

``channel-safely run once``
    Runs the safety procedures once. You can use this if you prefer initiating scans manually.

``channel-safely disable require-vision``
    Allows the plugin to read all tiles, including the ones your dwarves know nothing about.

``channel-safely enable monitor-active``
    Enables monitoring active channel digging jobs. Meaning that if another unit it present
    or the tile below becomes open space the job will be paused or canceled (respectively).

``channel-safely set ignore-threshold 3``
    Configures the plugin to ignore designations equal to or above priority 3 designations.

Features
--------
:monitor-active:    Toggle whether to monitor the conditions of active digs. (default: disabled)
:require-vision:    Toggle whether the dwarves need vision of a tile before channeling to it can be deemed unsafe. (default: enabled)
:insta-dig:         Toggle whether to use insta-digging on unreachable designations. (default: disabled)

Settings
--------
:refresh-freq:      The rate at which full refreshes are performed.
                    This can be expensive if you're undertaking many mega projects. (default:600, twice a day)
:monitor-freq:      The rate at which active jobs are monitored.
                    todo: this can have a massive impact? (default:10)
:ignore-threshold:  Sets the priority threshold below which designations are processed. You can set to 1 or 0 to
                    effectively disable the scanning. (default: 7)
:fall-threshold:    Sets the fall threshold beyond which is considered unsafe. (default: 1)

cppcooper avatar Sep 05 '22 20:09 cppcooper

could you unmark this as WIP when it's ready for review?

myk002 avatar Nov 08 '22 01:11 myk002

could you unmark this as WIP when it's ready for review?

Sure, it could probably do with some code review now.

cppcooper avatar Nov 08 '22 18:11 cppcooper

run once as a single command feels weird. --run-once would be my preference

Moth-Tolias avatar Nov 14 '22 18:11 Moth-Tolias

run once as a single command feels weird. --run-once would be my preference

agreed, or just run or just once

myk002 avatar Nov 15 '22 00:11 myk002

nobody said runonce but I'll either do that or run when I get a chance to write a special case in the arg parser

cppcooper avatar Nov 16 '22 16:11 cppcooper

You need a hash template param for the unordered maps. see https://github.com/DFHack/dfhack/blob/bf6d569ea2f813587400033fe21f24ecea2a3a96/plugins/blueprint.cpp#L183 for an example

myk002 avatar Nov 20 '22 15:11 myk002

You need a hash template param for the unordered maps. see

https://github.com/DFHack/dfhack/blob/bf6d569ea2f813587400033fe21f24ecea2a3a96/plugins/blueprint.cpp#L183 for an example

nah I just need to include the eventmanager's hash functions

cppcooper avatar Nov 21 '22 17:11 cppcooper

Overall LGTM. Do you want to get the simulate_fall code moved in this PR?

I do not want to move that in this PR. I'd like some testing feedback if possible before we merge. It works fine for me, but I'd like the confidence that this will be ok for most if not all

cppcooper avatar Nov 22 '22 19:11 cppcooper