Check map presence in autolabor and fastdwarf onupdate() functions
Game state tracking in kittens plugin now respects on/off switch
develop
Petr Mrázek 2012-04-01 03:46:17 +02:00
parent 7ff728b6fc
commit 2b4044f3f2
3 changed files with 15 additions and 6 deletions

@ -29,7 +29,7 @@ using df::global::world;
#define ARRAY_COUNT(array) (sizeof(array)/sizeof((array)[0])) #define ARRAY_COUNT(array) (sizeof(array)/sizeof((array)[0]))
static int enable_autolabor; static int enable_autolabor = 0;
// Here go all the command declarations... // Here go all the command declarations...
@ -467,9 +467,12 @@ struct values_sorter
DFhackCExport command_result plugin_onupdate ( color_ostream &out ) DFhackCExport command_result plugin_onupdate ( color_ostream &out )
{ {
static int step_count = 0; static int step_count = 0;
// check run conditions
if (!enable_autolabor) if(!world->map.block_index || !enable_autolabor)
{
// give up if we shouldn't be running'
return CR_OK; return CR_OK;
}
if (++step_count < 60) if (++step_count < 60)
return CR_OK; return CR_OK;

@ -62,6 +62,8 @@ DFhackCExport command_result plugin_shutdown ( color_ostream &out )
DFhackCExport command_result plugin_onstatechange(color_ostream &out, state_change_event event) DFhackCExport command_result plugin_onstatechange(color_ostream &out, state_change_event event)
{ {
if(!statetrack)
return CR_OK;
switch (event) { switch (event) {
case SC_MAP_LOADED: case SC_MAP_LOADED:
out << "Map loaded" << endl; out << "Map loaded" << endl;

@ -23,12 +23,16 @@ DFhackCExport command_result plugin_shutdown ( color_ostream &out )
return CR_OK; return CR_OK;
} }
static int enable_fastdwarf; static int enable_fastdwarf = false;
DFhackCExport command_result plugin_onupdate ( color_ostream &out ) DFhackCExport command_result plugin_onupdate ( color_ostream &out )
{ {
if (!enable_fastdwarf) // check run conditions
if(!world->map.block_index || !enable_fastdwarf)
{
// give up if we shouldn't be running'
return CR_OK; return CR_OK;
}
int32_t race = ui->race_id; int32_t race = ui->race_id;
int32_t civ = ui->civ_id; int32_t civ = ui->civ_id;