diff --git a/plugins/fastdwarf.cpp b/plugins/fastdwarf.cpp index 38b7f312d..c8265be52 100644 --- a/plugins/fastdwarf.cpp +++ b/plugins/fastdwarf.cpp @@ -1,21 +1,20 @@ -// foo -// vi:expandtab:sw=4 - -#include -#include -#include -#include -#include -#include -using namespace std; #include "Core.h" #include #include #include -#include -#include + +#include +#include "df/ui.h" +#include "df/world.h" +#include "df/unit.h" + +using std::string; +using std::vector; using namespace DFHack; +using df::global::world; +using df::global::ui; + // dfhack interface DFhackCExport const char * plugin_name ( void ) { @@ -33,22 +32,16 @@ DFhackCExport command_result plugin_onupdate ( Core * c ) { if (!enable_fastdwarf) return CR_OK; - df_unit *cre; - DFHack::Units * cr = c->getUnits(); - 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"); - } + int32_t race = ui->race_id; + int32_t civ = ui->civ_id; - for (unsigned i=0 ; isize() ; ++i) + for (int i = 0; i < world->units.all.size(); i++) { - cre = v->at(i); - if (cre->race == race && cre->civ == civ && cre->job_counter > 0) - cre->job_counter = 0; - // could also patch the cre->current_job->counter + df::unit *unit = world->units.all[i]; + + if (unit->race == race && unit->civ_id == civ && unit->counters.job_counter > 0) + unit->counters.job_counter = 0; + // could also patch the unit->job.current_job->completion_timer } return CR_OK; } @@ -65,7 +58,9 @@ static command_result fastdwarf (Core * c, vector & parameters) } 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); + c->con.print("Makes your minions move at ludicrous speeds.\n" + "Activate with 'fastdwarf 1', deactivate with 'fastdwarf 0'.\n" + "Current state: %d.\n", enable_fastdwarf); } return CR_OK; @@ -76,8 +71,8 @@ DFhackCExport command_result plugin_init ( Core * c, std::vector commands.clear(); commands.push_back(PluginCommand("fastdwarf", - "enable/disable fastdwarf (parameter=0/1)", - fastdwarf)); + "enable/disable fastdwarf (parameter=0/1)", + fastdwarf)); return CR_OK; }