summaryrefslogtreecommitdiff
path: root/plugins/fastdwarf.cpp
diff options
context:
space:
mode:
authorQuietust2012-01-11 10:17:25 -0600
committerQuietust2012-01-11 10:17:25 -0600
commit29b0c4273e5110adc278b4ff0ebdb8379d49e9a1 (patch)
treedf0070d4e94719736c1fe700a04f37a675ebe652 /plugins/fastdwarf.cpp
parent9cc774fc9da403ae65e2c89667f0dd8eda8ede2f (diff)
downloaddfhack-29b0c4273e5110adc278b4ff0ebdb8379d49e9a1.tar.gz
dfhack-29b0c4273e5110adc278b4ff0ebdb8379d49e9a1.tar.bz2
dfhack-29b0c4273e5110adc278b4ff0ebdb8379d49e9a1.tar.xz
Cleanup fastdwarf plugin, no longer relies on modules
Diffstat (limited to 'plugins/fastdwarf.cpp')
-rw-r--r--plugins/fastdwarf.cpp53
1 files changed, 24 insertions, 29 deletions
diff --git a/plugins/fastdwarf.cpp b/plugins/fastdwarf.cpp
index 38b7f312..c8265be5 100644
--- a/plugins/fastdwarf.cpp
+++ b/plugins/fastdwarf.cpp
@@ -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 <Console.h>
#include <Export.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 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 <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");
- }
+ int32_t race = ui->race_id;
+ int32_t civ = ui->civ_id;
- for (unsigned i=0 ; i<v->size() ; ++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 <string> & 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 <PluginCommand>
commands.clear();
commands.push_back(PluginCommand("fastdwarf",
- "enable/disable fastdwarf (parameter=0/1)",
- fastdwarf));
+ "enable/disable fastdwarf (parameter=0/1)",
+ fastdwarf));
return CR_OK;
}