diff --git a/library/include/dfhack/modules/Creatures.h b/library/include/dfhack/modules/Creatures.h index 005e9afff..29c37950e 100644 --- a/library/include/dfhack/modules/Creatures.h +++ b/library/include/dfhack/modules/Creatures.h @@ -616,7 +616,7 @@ namespace DFHack std::vector appearance; // 52c int16_t unk_53c; int16_t unk_53e; - int16_t unk_540; + int16_t job_counter; // tick until next job update? int16_t unk_542; int16_t unk_544; int16_t unk_546; diff --git a/plugins/fastdwarf.cpp b/plugins/fastdwarf.cpp index 9ff77b332..88872af7a 100644 --- a/plugins/fastdwarf.cpp +++ b/plugins/fastdwarf.cpp @@ -29,44 +29,43 @@ DFhackCExport command_result plugin_shutdown ( Core * c ) static int enable_fastdwarf; -// remove that if struct df_creature is updated -#define job_counter unk_540 - DFhackCExport command_result plugin_onupdate ( Core * c ) { if (!enable_fastdwarf) return CR_OK; - - static vector *v; df_creature *cre; - - if (!v) { - OffsetGroup *ogc = c->vinfo->getGroup("Creatures"); - v = (vector*)ogc->getAddress("vector"); + DFHack::Creatures * cr = c->getCreatures(); + static vector *v = cr->creatures; + uint32_t race = cr->GetDwarfRaceIndex(); + uint32_t civ = cr->GetDwarfCivId(); + if (!v) + { + c->con.printerr("Unable to locate creature vector. Fastdwarf cancelled.\n"); } - //c->Suspend(); // will deadlock in onupdate - for (unsigned i=0 ; isize() ; ++i) { + for (unsigned i=0 ; isize() ; ++i) + { cre = v->at(i); - if (cre->race == 241 && cre->job_counter > 0) + if (cre->race == race && cre->civ == civ && cre->job_counter > 0) cre->job_counter = 0; - // could also patch the cre->current_job->counter + // could also patch the cre->current_job->counter } - //c->Resume(); - return CR_OK; } static command_result fastdwarf (Core * c, vector & parameters) { - if (parameters.size() == 1 && (parameters[0] == "0" || parameters[0] == "1")) { + if (parameters.size() == 1 && (parameters[0] == "0" || parameters[0] == "1")) + { if (parameters[0] == "0") enable_fastdwarf = 0; else enable_fastdwarf = 1; c->con.print("fastdwarf %sactivated.\n", (enable_fastdwarf ? "" : "de")); - } else { - c->con.print("Activate fastdwarf with 'fastdwarf 1', deactivate with 'fastdwarf 0'.\nCurrent state: %d.\n", enable_fastdwarf); + } + else + { + c->con.print("Makes your minions move at ludicrous speeds.\nActivate with 'fastdwarf 1', deactivate with 'fastdwarf 0'.\nCurrent state: %d.\n", enable_fastdwarf); } return CR_OK;