Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 26f6820

Browse files
committed
Address review comments, hopefully fix linux build
1 parent 1bc9c41 commit 26f6820

2 files changed

Lines changed: 8 additions & 31 deletions

File tree

docs/plugins/autoslab.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ autoslab
22
========
33

44
.. dfhack-tool::
5-
:summary: Automatically engrave slabs for ghostly citizens!
6-
:tags: untested fort auto workorders
5+
:summary: Automatically engrave slabs for ghostly citizens.
6+
:tags: fort auto workorders
77
:no-command:
88

99
Automatically queue orders to engrave slabs of existing ghosts. Will only queue

plugins/autoslab.cpp

Lines changed: 6 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
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"
@@ -25,8 +26,6 @@
2526

2627
using namespace DFHack;
2728

28-
static command_result autoslab(color_ostream &out, std::vector<std::string> &parameters);
29-
3029
DFHACK_PLUGIN("autoslab");
3130
DFHACK_PLUGIN_IS_ENABLED(is_enabled);
3231

@@ -70,19 +69,12 @@ static void set_config_bool(int index, bool value)
7069

7170
static 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> &parameters);
7472
static void do_cycle(color_ostream &out);
7573

7674
DFhackCExport 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+
150143
DFhackCExport 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> &parameters)
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
175152
static 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

Comments
 (0)