55 * Enhancement idea: Automatically place the slab. This seems like a tricky problem but maybe solveable with named zones?
66 * Might be made obsolete by people just using buildingplan to pre-place plans for slab?
77 * Enhancement idea: Optionally enable autoengraving for pets.
8- * Enhancement idea: Try to get ahead of ghosts by autoengraving for dead dwarves with no remains.
8+ * Enhancement idea: Try to get ahead of ghosts by autoengraving for dead dwarves with no remains, or dwarves
9+ * whose remains are unreachable.
910 */
1011
1112#include " Core.h"
2526
2627using namespace DFHack ;
2728
28- static command_result autoslab (color_ostream &out, std::vector<std::string> ¶meters);
29-
3029DFHACK_PLUGIN (" autoslab" );
3130DFHACK_PLUGIN_IS_ENABLED (is_enabled);
3231
@@ -70,19 +69,12 @@ static void set_config_bool(int index, bool value)
7069
7170static int32_t cycle_timestamp = 0 ; // world->frame_counter at last cycle
7271
73- static command_result do_command (color_ostream &out, std::vector<std::string> ¶meters);
7472static void do_cycle (color_ostream &out);
7573
7674DFhackCExport command_result plugin_init (color_ostream &out, std::vector<PluginCommand> &commands)
7775{
7876 DEBUG (status, out).print (" initializing %s\n " , plugin_name);
7977
80- // provide a configuration interface for the plugin
81- commands.push_back (PluginCommand (
82- plugin_name,
83- " Automatically engrave slabs of ghostly citizens!" ,
84- do_command));
85-
8678 return CR_OK ;
8779}
8880
@@ -123,7 +115,6 @@ DFhackCExport command_result plugin_load_data(color_ostream &out)
123115 DEBUG (status, out).print (" no config found in this save; initializing\n " );
124116 config = World::AddPersistentData (CONFIG_KEY );
125117 set_config_bool (CONFIG_IS_ENABLED , is_enabled);
126- set_config_val (CONFIG_CYCLE_TICKS , 1200 );
127118 }
128119
129120 // we have to copy our enabled flag into the global plugin variable, but
@@ -147,30 +138,16 @@ DFhackCExport command_result plugin_onstatechange(color_ostream &out, state_chan
147138 return CR_OK ;
148139}
149140
141+ static const int32_t CYCLE_TICKS = 1200 ;
142+
150143DFhackCExport command_result plugin_onupdate (color_ostream &out)
151144{
152145 CoreSuspender suspend;
153- if (is_enabled && world->frame_counter - cycle_timestamp >= get_config_val ( CONFIG_CYCLE_TICKS ) )
146+ if (is_enabled && world->frame_counter - cycle_timestamp >= CYCLE_TICKS )
154147 do_cycle (out);
155148 return CR_OK ;
156149}
157150
158- static command_result do_command (color_ostream &out, std::vector<std::string> ¶meters)
159- {
160- // be sure to suspend the core if any DF state is read or modified
161- CoreSuspender suspend;
162-
163- if (!Core::getInstance ().isWorldLoaded ())
164- {
165- out.printerr (" Cannot run %s without a loaded world.\n " , plugin_name);
166- return CR_FAILURE ;
167- }
168-
169- // TODO: decide what, if any configuration should be here
170-
171- return CR_OK ;
172- }
173-
174151// Name functions taken from manipulator.cpp
175152static std::string get_first_name (df::unit *unit)
176153{
@@ -243,7 +220,7 @@ static void checkslabs(color_ostream &out)
243220 std::vector<df::unit *> ghosts;
244221 std::copy_if (world->units .all .begin (), world->units .all .end (),
245222 std::back_inserter (ghosts),
246- [](const auto & unit)
223+ [](const df::unit * unit)
247224 { return unit->flags3 .bits .ghostly ; });
248225
249226 for (auto ghost : ghosts)
0 commit comments