From 2b4044f3f2996d6d13fffaefca9603f8a1348c55 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Mr=C3=A1zek?= Date: Sun, 1 Apr 2012 03:46:17 +0200 Subject: [PATCH] Tweaks! Check map presence in autolabor and fastdwarf onupdate() functions Game state tracking in kittens plugin now respects on/off switch --- plugins/autolabor.cpp | 11 +++++++---- plugins/devel/kittens.cpp | 2 ++ plugins/fastdwarf.cpp | 8 ++++++-- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/plugins/autolabor.cpp b/plugins/autolabor.cpp index 1b442fe2f..963b6b417 100644 --- a/plugins/autolabor.cpp +++ b/plugins/autolabor.cpp @@ -29,7 +29,7 @@ using df::global::world; #define ARRAY_COUNT(array) (sizeof(array)/sizeof((array)[0])) -static int enable_autolabor; +static int enable_autolabor = 0; // Here go all the command declarations... @@ -467,9 +467,12 @@ struct values_sorter DFhackCExport command_result plugin_onupdate ( color_ostream &out ) { static int step_count = 0; - - if (!enable_autolabor) - return CR_OK; + // check run conditions + if(!world->map.block_index || !enable_autolabor) + { + // give up if we shouldn't be running' + return CR_OK; + } if (++step_count < 60) return CR_OK; diff --git a/plugins/devel/kittens.cpp b/plugins/devel/kittens.cpp index 5dbadcc72..2e8e6eaba 100644 --- a/plugins/devel/kittens.cpp +++ b/plugins/devel/kittens.cpp @@ -62,6 +62,8 @@ DFhackCExport command_result plugin_shutdown ( color_ostream &out ) DFhackCExport command_result plugin_onstatechange(color_ostream &out, state_change_event event) { + if(!statetrack) + return CR_OK; switch (event) { case SC_MAP_LOADED: out << "Map loaded" << endl; diff --git a/plugins/fastdwarf.cpp b/plugins/fastdwarf.cpp index 87402e428..643a097c4 100644 --- a/plugins/fastdwarf.cpp +++ b/plugins/fastdwarf.cpp @@ -23,12 +23,16 @@ DFhackCExport command_result plugin_shutdown ( color_ostream &out ) return CR_OK; } -static int enable_fastdwarf; +static int enable_fastdwarf = false; 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; + } int32_t race = ui->race_id; int32_t civ = ui->civ_id;