Update some plugins to use REQUIRE_GLOBAL

develop
lethosor 2014-12-02 21:44:20 -05:00
parent e206c242c6
commit cac2245438
31 changed files with 85 additions and 100 deletions

@ -27,6 +27,7 @@ distribution.
#include "Export.h"
#include "Hooks.h"
#include "ColorText.h"
#include "MiscUtils.h"
#include <map>
#include <string>
#include <vector>

@ -41,14 +41,13 @@ using std::stack;
using namespace DFHack;
using namespace df::enums;
using df::global::gps;
using df::global::world;
using df::global::ui;
typedef df::reaction_product_item_improvementst improvement_product;
DFHACK_PLUGIN("add-spatter");
DFHACK_PLUGIN_IS_ENABLED(is_enabled);
REQUIRE_GLOBAL(gps);
REQUIRE_GLOBAL(world);
REQUIRE_GLOBAL(ui);
typedef df::reaction_product_item_improvementst improvement_product;
struct ReagentSource {
int idx;

@ -37,14 +37,15 @@
using namespace DFHack;
using namespace df::enums;
using df::global::world;
using df::global::ui_advmode;
using df::nemesis_record;
using df::historical_figure;
using namespace DFHack::Translation;
DFHACK_PLUGIN("advtools");
REQUIRE_GLOBAL(world);
REQUIRE_GLOBAL(ui_advmode);
/*********************
* PLUGIN INTERFACE *
*********************/
@ -54,8 +55,6 @@ static bool bodyswap_hotkey(df::viewscreen *top);
command_result adv_bodyswap (color_ostream &out, std::vector <std::string> & parameters);
command_result adv_tools (color_ostream &out, std::vector <std::string> & parameters);
DFHACK_PLUGIN("advtools");
DFhackCExport command_result plugin_init (color_ostream &out, std::vector <PluginCommand> &commands)
{
if (!ui_advmode)

@ -36,12 +36,10 @@ using std::set;
using namespace DFHack;
using namespace df::enums;
using df::global::world;
using df::global::ui;
#define PLUGIN_VERSION 0.3
DFHACK_PLUGIN("autochop");
REQUIRE_GLOBAL(world);
REQUIRE_GLOBAL(ui);
static bool autochop_enabled = false;
static int min_logs, max_logs;

@ -34,10 +34,10 @@ using namespace df::enums;
using MapExtras::Block;
using MapExtras::MapCache;
using df::global::world;
using df::building_stockpilest;
DFHACK_PLUGIN("autodump");
REQUIRE_GLOBAL(world);
// Stockpile interface START
static const string PERSISTENCE_KEY = "autodump/stockpiles";

@ -44,8 +44,10 @@ using std::endl;
using std::vector;
using namespace DFHack;
using namespace df::enums;
using df::global::ui;
using df::global::world;
DFHACK_PLUGIN("autolabor");
REQUIRE_GLOBAL(ui);
REQUIRE_GLOBAL(world);
#define ARRAY_COUNT(array) (sizeof(array)/sizeof((array)[0]))
@ -91,10 +93,6 @@ enum ConfigFlags {
// mostly to allow having the mandatory stuff on top of the file and commands on the bottom
command_result autolabor (color_ostream &out, std::vector <std::string> & parameters);
// A plugin must be able to return its name and version.
// The name string provided must correspond to the filename - autolabor.plug.so or autolabor.plug.dll in this case
DFHACK_PLUGIN("autolabor");
static void generate_labor_to_skill_map();
enum labor_mode {

@ -43,11 +43,11 @@ using std::vector;
using namespace DFHack;
using namespace df::enums;
using df::global::gps;
using df::global::ui;
using df::global::ui_build_selector;
DFHACK_PLUGIN("automaterial");
REQUIRE_GLOBAL(gps);
REQUIRE_GLOBAL(ui);
REQUIRE_GLOBAL(ui_build_selector);
struct MaterialDescriptor
{

@ -14,13 +14,13 @@
#include "modules/World.h"
#include "df/item_quality.h"
using df::global::world;
using df::global::cursor;
using df::global::ui;
using df::building_stockpilest;
DFHACK_PLUGIN("automelt");
#define PLUGIN_VERSION 0.3
REQUIRE_GLOBAL(world);
REQUIRE_GLOBAL(cursor);
REQUIRE_GLOBAL(ui);
static const string PERSISTENCE_KEY = "automelt/stockpiles";

@ -19,12 +19,12 @@
#include "df/mandate.h"
#include "modules/Maps.h"
using df::global::world;
using df::global::cursor;
using df::global::ui;
using df::building_stockpilest;
DFHACK_PLUGIN("autotrade");
REQUIRE_GLOBAL(world);
REQUIRE_GLOBAL(cursor);
REQUIRE_GLOBAL(ui);
static const string PERSISTENCE_KEY = "autotrade/stockpiles";

@ -24,9 +24,10 @@
using namespace DFHack;
using namespace df::enums;
using df::global::world;
DFHACK_PLUGIN("building-hacks");
REQUIRE_GLOBAL(world);
struct graphic_tile //could do just 31x31 and be done, but it's nicer to have flexible imho.
{
int16_t tile; //originally uint8_t but we need to indicate non-animated tiles

@ -35,12 +35,11 @@
#include "df/building.h"
#include "df/building_doorst.h"
using df::global::ui;
using df::global::ui_build_selector;
using df::global::world;
DFHACK_PLUGIN("buildingplan");
#define PLUGIN_VERSION 0.14
REQUIRE_GLOBAL(ui);
REQUIRE_GLOBAL(ui_build_selector);
REQUIRE_GLOBAL(world);
struct MaterialDescriptor
{

@ -37,9 +37,10 @@ using namespace DFHack;
using namespace df::enums;
using namespace dfproto;
using df::global::ui;
using df::global::world;
using df::global::gamemode;
DFHACK_PLUGIN("burrows");
REQUIRE_GLOBAL(ui);
REQUIRE_GLOBAL(world);
REQUIRE_GLOBAL(gamemode);
/*
* Initialization.
@ -47,8 +48,6 @@ using df::global::gamemode;
static command_result burrow(color_ostream &out, vector <string> & parameters);
DFHACK_PLUGIN("burrows");
static void init_map(color_ostream &out);
static void deinit_map(color_ostream &out);

@ -25,11 +25,11 @@ using namespace std;
#include <df/unit_genes.h>
using namespace DFHack;
using df::global::world;
command_result catsplosion (color_ostream &out, std::vector <std::string> & parameters);
DFHACK_PLUGIN("catsplosion");
REQUIRE_GLOBAL(world);
command_result catsplosion (color_ostream &out, std::vector <std::string> & parameters);
// Mandatory init function. If you have some global state, create it here.
DFhackCExport command_result plugin_init ( color_ostream &out, std::vector <PluginCommand> &commands)

@ -31,9 +31,9 @@ using namespace df::enums;
using MapExtras::Block;
using MapExtras::MapCache;
using df::global::world;
DFHACK_PLUGIN("changeitem");
REQUIRE_GLOBAL(world);
command_result df_changeitem(color_ostream &out, vector <string> & parameters);

@ -28,8 +28,9 @@ using namespace std;
using std::vector;
using std::string;
using df::global::world;
using df::global::cursor;
DFHACK_PLUGIN("changelayer");
REQUIRE_GLOBAL(world);
REQUIRE_GLOBAL(cursor);
const string changelayer_help =
" Allows to change the material of whole geology layers.\n"
@ -83,8 +84,6 @@ const string changelayer_trouble =
command_result changelayer (color_ostream &out, std::vector <std::string> & parameters);
DFHACK_PLUGIN("changelayer");
DFhackCExport command_result plugin_init ( color_ostream &out, std::vector <PluginCommand> &commands)
{
commands.push_back(PluginCommand(

@ -15,8 +15,9 @@ using std::string;
using namespace DFHack;
using namespace df::enums;
using df::global::world;
using df::global::cursor;
DFHACK_PLUGIN("changevein");
REQUIRE_GLOBAL(world);
REQUIRE_GLOBAL(cursor);
command_result df_changevein (color_ostream &out, vector <string> & parameters)
{
@ -77,8 +78,6 @@ command_result df_changevein (color_ostream &out, vector <string> & parameters)
return CR_OK;
}
DFHACK_PLUGIN("changevein");
DFhackCExport command_result plugin_init ( color_ostream &out, std::vector <PluginCommand> &commands)
{
commands.push_back(PluginCommand("changevein",

@ -16,9 +16,8 @@
using namespace std;
using namespace DFHack;
using df::global::world;
DFHACK_PLUGIN("cleanconst");
REQUIRE_GLOBAL(world);
command_result df_cleanconst(color_ostream &out, vector <string> & parameters)
{

@ -18,10 +18,9 @@ using std::string;
using namespace DFHack;
using namespace df::enums;
using df::global::world;
using df::global::cursor;
DFHACK_PLUGIN("cleaners");
REQUIRE_GLOBAL(world);
REQUIRE_GLOBAL(cursor);
command_result cleanmap (color_ostream &out, bool snow, bool mud, bool item_spatter)
{

@ -23,12 +23,11 @@ using namespace std;
using namespace DFHack;
using namespace df::enums;
using df::global::world;
DFHACK_PLUGIN("cleanowned");
REQUIRE_GLOBAL(world);
command_result df_cleanowned (color_ostream &out, vector <string> & parameters);
DFHACK_PLUGIN("cleanowned");
DFhackCExport command_result plugin_init ( color_ostream &out, std::vector <PluginCommand> &commands)
{
commands.push_back(PluginCommand(

@ -14,6 +14,7 @@ using namespace DFHack;
command_result colonies (color_ostream &out, vector <string> & parameters);
DFHACK_PLUGIN("colonies");
REQUIRE_GLOBAL(world); // used by Materials
DFhackCExport command_result plugin_init ( color_ostream &out, std::vector <PluginCommand> &commands)
{

@ -22,9 +22,10 @@
using namespace DFHack;
using namespace df::enums;
using df::global::ui;
using df::global::gps;
using df::global::enabler;
DFHACK_PLUGIN("command-prompt");
REQUIRE_GLOBAL(ui);
REQUIRE_GLOBAL(gps);
REQUIRE_GLOBAL(enabler);
std::vector<std::string> command_history;
@ -303,7 +304,7 @@ void viewscreen_commandpromptst::feed(std::set<df::interface_key> *events)
frame = 0;
}
DFHACK_PLUGIN("command-prompt");
command_result show_prompt(color_ostream &out, std::vector <std::string> & parameters)
{
if (Gui::getCurFocus() == "dfhack/commandprompt")

@ -31,11 +31,10 @@ using std::vector;
using namespace DFHack;
using namespace df::enums;
using df::global::world;
using df::global::ui;
using df::global::gametype;
DFHACK_PLUGIN("createitem");
REQUIRE_GLOBAL(world);
REQUIRE_GLOBAL(ui);
REQUIRE_GLOBAL(gametype);
int dest_container = -1, dest_building = -1;

@ -48,12 +48,12 @@ using std::vector;
using std::string;
using namespace DFHack;
using namespace df::enums;
using df::global::world;
using df::global::cursor;
command_result cursecheck (color_ostream &out, vector <string> & parameters);
DFHACK_PLUGIN("cursecheck");
REQUIRE_GLOBAL(world);
REQUIRE_GLOBAL(cursor);
command_result cursecheck (color_ostream &out, vector <string> & parameters);
DFhackCExport command_result plugin_init ( color_ostream &out, std::vector <PluginCommand> &commands)
{

@ -14,9 +14,8 @@ using std::string;
using namespace DFHack;
using namespace df::enums;
using df::global::world;
DFHACK_PLUGIN("deramp");
REQUIRE_GLOBAL(world);
command_result df_deramp (color_ostream &out, vector <string> & parameters)
{

@ -18,8 +18,10 @@ using namespace df::enums;
using std::string;
using std::vector;
using df::global::gps;
using df::global::enabler;
DFHACK_PLUGIN("dfstream");
REQUIRE_GLOBAL(gps);
REQUIRE_GLOBAL(enabler);
// The error messages are taken from the clsocket source code
const char * translate_socket_error(CSimpleSocket::CSocketError err) {
@ -283,8 +285,6 @@ public:
}
};
DFHACK_PLUGIN("dfstream");
inline df::renderer *& active_renderer() {
return enabler->renderer;
}

@ -27,6 +27,7 @@ command_result digcircle (color_ostream &out, vector <string> & parameters);
command_result digtype (color_ostream &out, vector <string> & parameters);
DFHACK_PLUGIN("dig");
REQUIRE_GLOBAL(world);
DFhackCExport command_result plugin_init ( color_ostream &out, std::vector <PluginCommand> &commands)
{

@ -21,14 +21,11 @@
using namespace DFHack;
using namespace std;
using df::global::world;
// using df::global::process_jobs;
// using df::global::process_dig;
DFHACK_PLUGIN("digFlood");
REQUIRE_GLOBAL(world);
command_result digFlood (color_ostream &out, std::vector <std::string> & parameters);
DFHACK_PLUGIN("digFlood");
void onDig(color_ostream& out, void* ptr);
void maybeExplore(color_ostream& out, MapExtras::MapCache& cache, df::coord pt, set<df::coord>& jobLocations);
EventManager::EventHandler digHandler(onDig, 0);

@ -77,6 +77,7 @@ void findAndAssignInvasionJob(color_ostream& out, void*);
DFHACK_PLUGIN_IS_ENABLED(enabled);
DFHACK_PLUGIN("diggingInvaders");
REQUIRE_GLOBAL(world);
//TODO: when world unloads
static int32_t lastInvasionJob=-1;
@ -386,8 +387,8 @@ void findAndAssignInvasionJob(color_ostream& out, void* tickTime) {
unordered_set<uint16_t> localConnectivity;
//find all locals and invaders
for ( size_t a = 0; a < df::global::world->units.all.size(); a++ ) {
df::unit* unit = df::global::world->units.all[a];
for ( size_t a = 0; a < world->units.all.size(); a++ ) {
df::unit* unit = world->units.all[a];
if ( unit->flags1.bits.dead )
continue;
if ( Units::isCitizen(unit) ) {
@ -597,7 +598,7 @@ void findAndAssignInvasionJob(color_ostream& out, void* tickTime) {
lastInvasionDigger = firstInvader->id;
lastInvasionJob = firstInvader->job.current_job ? firstInvader->job.current_job->id : -1;
invaderJobs.erase(lastInvasionJob);
for ( df::job_list_link* link = &df::global::world->job_list; link != NULL; link = link->next ) {
for ( df::job_list_link* link = &world->job_list; link != NULL; link = link->next ) {
if ( link->item == NULL )
continue;
df::job* job = link->item;

@ -15,9 +15,8 @@ using std::vector;
using namespace DFHack;
using namespace df::enums;
using df::global::world;
DFHACK_PLUGIN("drybuckets");
REQUIRE_GLOBAL(world);
command_result df_drybuckets (color_ostream &out, vector <string> & parameters)
{

@ -43,9 +43,11 @@
using std::deque;
using df::global::current_weather;
using df::global::world;
using df::global::ui;
DFHACK_PLUGIN("dwarfmonitor");
DFHACK_PLUGIN_IS_ENABLED(is_enabled);
REQUIRE_GLOBAL(current_weather);
REQUIRE_GLOBAL(world);
REQUIRE_GLOBAL(ui);
typedef int16_t activity_type;
@ -1775,9 +1777,6 @@ struct dwarf_monitor_hook : public df::viewscreen_dwarfmodest
IMPLEMENT_VMETHOD_INTERPOSE(dwarf_monitor_hook, feed);
IMPLEMENT_VMETHOD_INTERPOSE(dwarf_monitor_hook, render);
DFHACK_PLUGIN("dwarfmonitor");
DFHACK_PLUGIN_IS_ENABLED(is_enabled);
static bool set_monitoring_mode(const string &mode, const bool &state)
{
bool mode_recognized = false;

@ -34,14 +34,13 @@ using std::stack;
using namespace DFHack;
using namespace df::enums;
using df::global::gps;
using df::global::world;
using df::global::ui;
DFHACK_PLUGIN("eventful");
REQUIRE_GLOBAL(gps);
REQUIRE_GLOBAL(world);
REQUIRE_GLOBAL(ui);
typedef df::reaction_product_itemst item_product;
DFHACK_PLUGIN("eventful");
struct ReagentSource {
int idx;
df::reaction_reagent *reagent;