2011-12-31 04:48:42 -07:00
|
|
|
#include "Core.h"
|
2012-01-15 13:54:14 -07:00
|
|
|
#include "Console.h"
|
|
|
|
#include "Export.h"
|
|
|
|
#include "PluginManager.h"
|
2012-01-11 09:17:25 -07:00
|
|
|
|
2012-01-15 13:54:14 -07:00
|
|
|
#include "DataDefs.h"
|
2012-01-11 09:17:25 -07:00
|
|
|
#include "df/ui.h"
|
|
|
|
#include "df/world.h"
|
|
|
|
#include "df/unit.h"
|
|
|
|
|
|
|
|
using std::string;
|
|
|
|
using std::vector;
|
2011-10-06 19:53:58 -06:00
|
|
|
using namespace DFHack;
|
|
|
|
|
2012-01-11 09:17:25 -07:00
|
|
|
using df::global::world;
|
|
|
|
using df::global::ui;
|
|
|
|
|
2011-10-06 19:53:58 -06:00
|
|
|
// dfhack interface
|
|
|
|
DFhackCExport const char * plugin_name ( void )
|
|
|
|
{
|
|
|
|
return "fastdwarf";
|
|
|
|
}
|
|
|
|
|
|
|
|
DFhackCExport command_result plugin_shutdown ( Core * c )
|
|
|
|
{
|
|
|
|
return CR_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int enable_fastdwarf;
|
|
|
|
|
|
|
|
DFhackCExport command_result plugin_onupdate ( Core * c )
|
|
|
|
{
|
|
|
|
if (!enable_fastdwarf)
|
|
|
|
return CR_OK;
|
2012-01-11 09:17:25 -07:00
|
|
|
int32_t race = ui->race_id;
|
|
|
|
int32_t civ = ui->civ_id;
|
2011-10-06 19:53:58 -06:00
|
|
|
|
2012-01-11 09:17:25 -07:00
|
|
|
for (int i = 0; i < world->units.all.size(); i++)
|
2011-10-27 22:22:07 -06:00
|
|
|
{
|
2012-01-11 09:17:25 -07:00
|
|
|
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
|
2011-10-06 19:53:58 -06:00
|
|
|
}
|
|
|
|
return CR_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static command_result fastdwarf (Core * c, vector <string> & parameters)
|
|
|
|
{
|
2011-10-27 22:22:07 -06:00
|
|
|
if (parameters.size() == 1 && (parameters[0] == "0" || parameters[0] == "1"))
|
|
|
|
{
|
2011-10-06 19:53:58 -06:00
|
|
|
if (parameters[0] == "0")
|
|
|
|
enable_fastdwarf = 0;
|
|
|
|
else
|
|
|
|
enable_fastdwarf = 1;
|
|
|
|
c->con.print("fastdwarf %sactivated.\n", (enable_fastdwarf ? "" : "de"));
|
2011-10-27 22:22:07 -06:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-01-11 09:17:25 -07:00
|
|
|
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);
|
2011-10-06 19:53:58 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
return CR_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
DFhackCExport command_result plugin_init ( Core * c, std::vector <PluginCommand> &commands)
|
|
|
|
{
|
|
|
|
commands.clear();
|
|
|
|
|
|
|
|
commands.push_back(PluginCommand("fastdwarf",
|
2012-01-11 09:17:25 -07:00
|
|
|
"enable/disable fastdwarf (parameter=0/1)",
|
|
|
|
fastdwarf));
|
2011-10-06 19:53:58 -06:00
|
|
|
|
|
|
|
return CR_OK;
|
|
|
|
}
|