Cleanup fastdwarf plugin, no longer relies on modules

develop
Quietust 2012-01-11 10:17:25 -06:00
parent 9cc774fc9d
commit 29b0c4273e
1 changed files with 24 additions and 29 deletions

@ -1,21 +1,20 @@
// foo
// vi:expandtab:sw=4
#include <iostream>
#include <vector>
#include <map>
#include <stddef.h>
#include <assert.h>
#include <string.h>
using namespace std;
#include "Core.h" #include "Core.h"
#include <Console.h> #include <Console.h>
#include <Export.h> #include <Export.h>
#include <PluginManager.h> #include <PluginManager.h>
#include <VersionInfo.h>
#include <modules/Units.h> #include <DataDefs.h>
#include "df/ui.h"
#include "df/world.h"
#include "df/unit.h"
using std::string;
using std::vector;
using namespace DFHack; using namespace DFHack;
using df::global::world;
using df::global::ui;
// dfhack interface // dfhack interface
DFhackCExport const char * plugin_name ( void ) DFhackCExport const char * plugin_name ( void )
{ {
@ -33,22 +32,16 @@ DFhackCExport command_result plugin_onupdate ( Core * c )
{ {
if (!enable_fastdwarf) if (!enable_fastdwarf)
return CR_OK; return CR_OK;
df_unit *cre; int32_t race = ui->race_id;
DFHack::Units * cr = c->getUnits(); int32_t civ = ui->civ_id;
static vector <df_unit*> *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");
}
for (unsigned i=0 ; i<v->size() ; ++i) for (int i = 0; i < world->units.all.size(); i++)
{ {
cre = v->at(i); df::unit *unit = world->units.all[i];
if (cre->race == race && cre->civ == civ && cre->job_counter > 0)
cre->job_counter = 0; if (unit->race == race && unit->civ_id == civ && unit->counters.job_counter > 0)
// could also patch the cre->current_job->counter unit->counters.job_counter = 0;
// could also patch the unit->job.current_job->completion_timer
} }
return CR_OK; return CR_OK;
} }
@ -65,7 +58,9 @@ static command_result fastdwarf (Core * c, vector <string> & parameters)
} }
else 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; return CR_OK;