Update remaining plugins to use REQUIRE_GLOBAL

develop
lethosor 2014-12-06 18:47:35 -05:00
parent 5de3e6110a
commit a615723b38
47 changed files with 236 additions and 261 deletions

@ -17,13 +17,10 @@ using std::vector;
using namespace DFHack; using namespace DFHack;
using namespace df::enums; using namespace df::enums;
using df::global::world;
using df::global::debug_turbospeed;
// dfhack interface
DFHACK_PLUGIN("fastdwarf"); DFHACK_PLUGIN("fastdwarf");
DFHACK_PLUGIN_IS_ENABLED(active); DFHACK_PLUGIN_IS_ENABLED(active);
REQUIRE_GLOBAL(world);
using df::global::debug_turbospeed; // not required
static bool enable_fastdwarf = false; static bool enable_fastdwarf = false;
static bool enable_teledwarf = false; static bool enable_teledwarf = false;

@ -17,7 +17,8 @@ using std::endl;
using namespace DFHack; using namespace DFHack;
using namespace df::enums; using namespace df::enums;
using df::global::world; DFHACK_PLUGIN("feature");
REQUIRE_GLOBAL(world);
static command_result feature(color_ostream &out, vector <string> &parameters) static command_result feature(color_ostream &out, vector <string> &parameters)
@ -92,8 +93,6 @@ static command_result feature(color_ostream &out, vector <string> &parameters)
return CR_OK; return CR_OK;
} }
DFHACK_PLUGIN("feature");
DFhackCExport command_result plugin_init (color_ostream &out, std::vector <PluginCommand> &commands) DFhackCExport command_result plugin_init (color_ostream &out, std::vector <PluginCommand> &commands)
{ {
commands.push_back(PluginCommand( commands.push_back(PluginCommand(

@ -18,7 +18,8 @@ using std::vector;
using namespace DFHack; using namespace DFHack;
using namespace df::enums; using namespace df::enums;
using df::global::world; DFHACK_PLUGIN("fixpositions");
REQUIRE_GLOBAL(world);
command_result df_fixdiplomats (color_ostream &out, vector<string> &parameters) command_result df_fixdiplomats (color_ostream &out, vector<string> &parameters)
{ {
@ -226,8 +227,6 @@ command_result df_fixmerchants (color_ostream &out, vector<string> &parameters)
return CR_OK; return CR_OK;
} }
DFHACK_PLUGIN("fixpositions");
DFhackCExport command_result plugin_init ( color_ostream &out, std::vector <PluginCommand> &commands) DFhackCExport command_result plugin_init ( color_ostream &out, std::vector <PluginCommand> &commands)
{ {
commands.push_back(PluginCommand( commands.push_back(PluginCommand(

@ -19,7 +19,8 @@ using std::string;
using namespace DFHack; using namespace DFHack;
using namespace df::enums; using namespace df::enums;
using df::global::world; DFHACK_PLUGIN("fixveins");
REQUIRE_GLOBAL(world);
bool setTileMaterial(df::tiletype &tile, const df::tiletype_material mat) bool setTileMaterial(df::tiletype &tile, const df::tiletype_material mat)
{ {
@ -95,8 +96,6 @@ command_result df_fixveins (color_ostream &out, vector <string> & parameters)
return CR_OK; return CR_OK;
} }
DFHACK_PLUGIN("fixveins");
DFhackCExport command_result plugin_init ( color_ostream &out, std::vector <PluginCommand> &commands) DFhackCExport command_result plugin_init ( color_ostream &out, std::vector <PluginCommand> &commands)
{ {
commands.push_back(PluginCommand("fixveins", commands.push_back(PluginCommand("fixveins",

@ -15,7 +15,8 @@ using std::vector;
using namespace DFHack; using namespace DFHack;
using namespace df::enums; using namespace df::enums;
using df::global::world; DFHACK_PLUGIN("flows");
REQUIRE_GLOBAL(world);
command_result df_flows (color_ostream &out, vector <string> & parameters) command_result df_flows (color_ostream &out, vector <string> & parameters)
{ {
@ -56,8 +57,6 @@ command_result df_flows (color_ostream &out, vector <string> & parameters)
return CR_OK; return CR_OK;
} }
DFHACK_PLUGIN("flows");
DFhackCExport command_result plugin_init ( color_ostream &out, std::vector <PluginCommand> &commands) DFhackCExport command_result plugin_init ( color_ostream &out, std::vector <PluginCommand> &commands)
{ {
commands.push_back(PluginCommand("flows", commands.push_back(PluginCommand("flows",

@ -16,7 +16,9 @@
using namespace DFHack; using namespace DFHack;
using namespace df::enums; using namespace df::enums;
using df::global::world; DFHACK_PLUGIN("follow");
DFHACK_PLUGIN_IS_ENABLED(is_enabled);
REQUIRE_GLOBAL(world);
command_result follow (color_ostream &out, std::vector <std::string> & parameters); command_result follow (color_ostream &out, std::vector <std::string> & parameters);
@ -24,9 +26,6 @@ df::unit *followedUnit;
int32_t prevX, prevY, prevZ; int32_t prevX, prevY, prevZ;
uint8_t prevMenuWidth; uint8_t prevMenuWidth;
DFHACK_PLUGIN("follow");
DFHACK_PLUGIN_IS_ENABLED(is_enabled);
DFhackCExport command_result plugin_init ( color_ostream &out, std::vector <PluginCommand> &commands) DFhackCExport command_result plugin_init ( color_ostream &out, std::vector <PluginCommand> &commands)
{ {
commands.push_back(PluginCommand( commands.push_back(PluginCommand(

@ -46,13 +46,13 @@ using namespace df::enums;
using MapExtras::Block; using MapExtras::Block;
using MapExtras::MapCache; using MapExtras::MapCache;
using df::global::world;
DFHACK_PLUGIN("forceequip");
REQUIRE_GLOBAL(world);
const int const_GloveRightHandedness = 1; const int const_GloveRightHandedness = 1;
const int const_GloveLeftHandedness = 2; const int const_GloveLeftHandedness = 2;
DFHACK_PLUGIN("forceequip");
command_result df_forceequip(color_ostream &out, vector <string> & parameters); command_result df_forceequip(color_ostream &out, vector <string> & parameters);
const string forceequip_help = const string forceequip_help =

@ -22,7 +22,8 @@ using std::set;
using namespace DFHack; using namespace DFHack;
using namespace df::enums; using namespace df::enums;
using df::global::world; DFHACK_PLUGIN("getplants");
REQUIRE_GLOBAL(world);
command_result df_getplants (color_ostream &out, vector <string> & parameters) command_result df_getplants (color_ostream &out, vector <string> & parameters)
{ {
@ -148,8 +149,6 @@ command_result df_getplants (color_ostream &out, vector <string> & parameters)
return CR_OK; return CR_OK;
} }
DFHACK_PLUGIN("getplants");
DFhackCExport command_result plugin_init ( color_ostream &out, vector <PluginCommand> &commands) DFhackCExport command_result plugin_init ( color_ostream &out, vector <PluginCommand> &commands)
{ {
commands.push_back(PluginCommand( commands.push_back(PluginCommand(

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

@ -12,13 +12,12 @@ using std::endl;
using namespace DFHack; using namespace DFHack;
using namespace df::enums; using namespace df::enums;
using df::global::d_init; DFHACK_PLUGIN("initflags");
REQUIRE_GLOBAL(d_init);
command_result twaterlvl(color_ostream &out, vector <string> & parameters); command_result twaterlvl(color_ostream &out, vector <string> & parameters);
command_result tidlers(color_ostream &out, vector <string> & parameters); command_result tidlers(color_ostream &out, vector <string> & parameters);
DFHACK_PLUGIN("initflags");
DFhackCExport command_result plugin_init (color_ostream &out, std::vector <PluginCommand> &commands) DFhackCExport command_result plugin_init (color_ostream &out, std::vector <PluginCommand> &commands)
{ {
if (d_init) { if (d_init) {

@ -31,10 +31,11 @@ using namespace DFHack;
using namespace df::enums; using namespace df::enums;
using namespace isoworldremote; using namespace isoworldremote;
using df::global::gamemode; DFHACK_PLUGIN("isoworldremote");
using df::global::world; REQUIRE_GLOBAL(gamemode);
using df::global::cur_year; REQUIRE_GLOBAL(world);
using df::global::cur_season; REQUIRE_GLOBAL(cur_year);
REQUIRE_GLOBAL(cur_season);
// Here go all the command declarations... // Here go all the command declarations...
// mostly to allow having the mandatory stuff on top of the file and commands on the bottom // mostly to allow having the mandatory stuff on top of the file and commands on the bottom
@ -47,11 +48,6 @@ static command_result GetRawNames(color_ostream &stream, const MapRequest *in, R
bool gather_embark_tile_layer(int EmbX, int EmbY, int EmbZ, EmbarkTileLayer * tile, MapExtras::MapCache * MP); bool gather_embark_tile_layer(int EmbX, int EmbY, int EmbZ, EmbarkTileLayer * tile, MapExtras::MapCache * MP);
bool gather_embark_tile(int EmbX, int EmbY, EmbarkTile * tile, MapExtras::MapCache * MP); bool gather_embark_tile(int EmbX, int EmbY, EmbarkTile * tile, MapExtras::MapCache * MP);
// A plugin must be able to return its name and version.
// The name string provided must correspond to the filename - skeleton.plug.so or skeleton.plug.dll in this case
DFHACK_PLUGIN("isoworldremote");
// Mandatory init function. If you have some global state, create it here. // Mandatory init function. If you have some global state, create it here.
DFhackCExport command_result plugin_init ( color_ostream &out, std::vector <PluginCommand> &commands) DFhackCExport command_result plugin_init ( color_ostream &out, std::vector <PluginCommand> &commands)
{ {

@ -31,11 +31,12 @@ using std::endl;
using namespace DFHack; using namespace DFHack;
using namespace df::enums; using namespace df::enums;
using df::global::world; DFHACK_PLUGIN("jobutils");
using df::global::ui; REQUIRE_GLOBAL(world);
using df::global::ui_build_selector; REQUIRE_GLOBAL(ui);
using df::global::ui_workshop_job_cursor; REQUIRE_GLOBAL(ui_build_selector);
using df::global::job_next_id; REQUIRE_GLOBAL(ui_workshop_job_cursor);
REQUIRE_GLOBAL(job_next_id);
/* Plugin registration */ /* Plugin registration */
@ -45,8 +46,6 @@ static command_result job_material(color_ostream &out, vector <string> & paramet
static command_result job_duplicate(color_ostream &out, vector <string> & parameters); static command_result job_duplicate(color_ostream &out, vector <string> & parameters);
static command_result job_cmd(color_ostream &out, vector <string> & parameters); static command_result job_cmd(color_ostream &out, vector <string> & parameters);
DFHACK_PLUGIN("jobutils");
DFhackCExport command_result plugin_init (color_ostream &out, std::vector <PluginCommand> &commands) DFhackCExport command_result plugin_init (color_ostream &out, std::vector <PluginCommand> &commands)
{ {
if (!world || !ui) if (!world || !ui)

@ -12,9 +12,9 @@
#include "modules/Gui.h" #include "modules/Gui.h"
using namespace DFHack; using namespace DFHack;
using namespace df::enums; using namespace df::enums;
using df::global::world;
DFHACK_PLUGIN("lair"); DFHACK_PLUGIN("lair");
REQUIRE_GLOBAL(world);
enum state enum state
{ {

@ -46,15 +46,15 @@ using std::set;
using namespace MapExtras; using namespace MapExtras;
using namespace DFHack; using namespace DFHack;
using namespace df::enums; using namespace df::enums;
using df::global::world;
DFHACK_PLUGIN("liquids");
REQUIRE_GLOBAL(world);
CommandHistory liquids_hist; CommandHistory liquids_hist;
command_result df_liquids (color_ostream &out, vector <string> & parameters); command_result df_liquids (color_ostream &out, vector <string> & parameters);
command_result df_liquids_here (color_ostream &out, vector <string> & parameters); command_result df_liquids_here (color_ostream &out, vector <string> & parameters);
DFHACK_PLUGIN("liquids");
DFhackCExport command_result plugin_init ( color_ostream &out, std::vector <PluginCommand> &commands) DFhackCExport command_result plugin_init ( color_ostream &out, std::vector <PluginCommand> &commands)
{ {
liquids_hist.load("liquids.history"); liquids_hist.load("liquids.history");

@ -36,10 +36,12 @@ using std::string;
using namespace DFHack; using namespace DFHack;
using namespace df::enums; using namespace df::enums;
using df::global::world; DFHACK_PLUGIN("manipulator");
using df::global::ui; DFHACK_PLUGIN_IS_ENABLED(is_enabled);
using df::global::gps; REQUIRE_GLOBAL(world);
using df::global::enabler; REQUIRE_GLOBAL(ui);
REQUIRE_GLOBAL(gps);
REQUIRE_GLOBAL(enabler);
struct SkillLevel struct SkillLevel
{ {
@ -1291,10 +1293,6 @@ struct unitlist_hook : df::viewscreen_unitlistst
IMPLEMENT_VMETHOD_INTERPOSE(unitlist_hook, feed); IMPLEMENT_VMETHOD_INTERPOSE(unitlist_hook, feed);
IMPLEMENT_VMETHOD_INTERPOSE(unitlist_hook, render); IMPLEMENT_VMETHOD_INTERPOSE(unitlist_hook, render);
DFHACK_PLUGIN("manipulator");
DFHACK_PLUGIN_IS_ENABLED(is_enabled);
DFhackCExport command_result plugin_enable(color_ostream &out, bool enable) DFhackCExport command_result plugin_enable(color_ostream &out, bool enable)
{ {
if (!gps) if (!gps)

@ -15,11 +15,12 @@
using namespace std; using namespace std;
using namespace DFHack; using namespace DFHack;
using df::global::world; DFHACK_PLUGIN("misery");
using df::global::ui;
DFHACK_PLUGIN_IS_ENABLED(is_enabled); DFHACK_PLUGIN_IS_ENABLED(is_enabled);
REQUIRE_GLOBAL(world);
REQUIRE_GLOBAL(ui);
static int factor = 1; static int factor = 1;
static map<int, int> processedThoughtCountTable; static map<int, int> processedThoughtCountTable;
@ -28,8 +29,6 @@ static vector<std::pair<int,int> > fakeThoughts;
static int count; static int count;
const int maxCount = 1000; const int maxCount = 1000;
DFHACK_PLUGIN("misery");
command_result misery(color_ostream& out, vector<string>& parameters); command_result misery(color_ostream& out, vector<string>& parameters);
DFhackCExport command_result plugin_shutdown(color_ostream& out) { DFhackCExport command_result plugin_shutdown(color_ostream& out) {

@ -21,14 +21,13 @@
#include "TileTypes.h" #include "TileTypes.h"
#include "DataFuncs.h" #include "DataFuncs.h"
using df::global::world; DFHACK_PLUGIN("mousequery");
using df::global::ui; REQUIRE_GLOBAL(world);
using df::global::ui_build_selector; REQUIRE_GLOBAL(ui);
REQUIRE_GLOBAL(ui_build_selector);
using namespace df::enums::ui_sidebar_mode; using namespace df::enums::ui_sidebar_mode;
DFHACK_PLUGIN("mousequery");
#define PLUGIN_VERSION 0.18 #define PLUGIN_VERSION 0.18
static int32_t last_clicked_x, last_clicked_y, last_clicked_z; static int32_t last_clicked_x, last_clicked_y, last_clicked_z;

@ -20,17 +20,17 @@
using namespace DFHack; using namespace DFHack;
using namespace std; using namespace std;
using df::global::world; DFHACK_PLUGIN("petcapRemover");
DFHACK_PLUGIN_IS_ENABLED(is_enabled);
REQUIRE_GLOBAL(world);
static int32_t howOften = 10000; static int32_t howOften = 10000;
static int32_t popcap = 100; static int32_t popcap = 100;
static int32_t pregtime = 200000; static int32_t pregtime = 200000;
DFHACK_PLUGIN_IS_ENABLED(is_enabled);
command_result petcapRemover (color_ostream &out, std::vector <std::string> & parameters); command_result petcapRemover (color_ostream &out, std::vector <std::string> & parameters);
DFHACK_PLUGIN("petcapRemover");
DFhackCExport command_result plugin_init ( color_ostream &out, std::vector <PluginCommand> &commands) DFhackCExport command_result plugin_init ( color_ostream &out, std::vector <PluginCommand> &commands)
{ {
commands.push_back(PluginCommand( commands.push_back(PluginCommand(

@ -18,11 +18,11 @@
using std::vector; using std::vector;
using std::string; using std::string;
using namespace DFHack; using namespace DFHack;
using df::global::world;
const uint32_t sapling_to_tree_threshold = 120 * 28 * 12 * 3 - 1; // 3 years minus 1 - let the game handle the actual growing-up
DFHACK_PLUGIN("plants"); DFHACK_PLUGIN("plants");
REQUIRE_GLOBAL(world);
const uint32_t sapling_to_tree_threshold = 120 * 28 * 12 * 3 - 1; // 3 years minus 1 - let the game handle the actual growing-up
/* Immolate/Extirpate no longer work in 0.40 /* Immolate/Extirpate no longer work in 0.40
enum do_what enum do_what

@ -38,12 +38,11 @@ using std::stack;
using namespace DFHack; using namespace DFHack;
using namespace df::enums; using namespace df::enums;
using df::global::gps;
using df::global::world;
using df::global::ui;
using df::global::ui_build_selector;
DFHACK_PLUGIN("power-meter"); DFHACK_PLUGIN("power-meter");
REQUIRE_GLOBAL(gps);
REQUIRE_GLOBAL(world);
REQUIRE_GLOBAL(ui);
REQUIRE_GLOBAL(ui_build_selector);
static const uint32_t METER_BIT = 0x80000000U; static const uint32_t METER_BIT = 0x80000000U;

@ -33,15 +33,15 @@ using std::vector;
using std::string; using std::string;
using namespace DFHack; using namespace DFHack;
using namespace df::enums; using namespace df::enums;
using df::global::world;
using df::global::cursor; DFHACK_PLUGIN("probe");
REQUIRE_GLOBAL(world);
REQUIRE_GLOBAL(cursor);
command_result df_probe (color_ostream &out, vector <string> & parameters); command_result df_probe (color_ostream &out, vector <string> & parameters);
command_result df_cprobe (color_ostream &out, vector <string> & parameters); command_result df_cprobe (color_ostream &out, vector <string> & parameters);
command_result df_bprobe (color_ostream &out, vector <string> & parameters); command_result df_bprobe (color_ostream &out, vector <string> & parameters);
DFHACK_PLUGIN("probe");
DFhackCExport command_result plugin_init ( color_ostream &out, std::vector <PluginCommand> &commands) DFhackCExport command_result plugin_init ( color_ostream &out, std::vector <PluginCommand> &commands)
{ {
commands.push_back(PluginCommand("probe", commands.push_back(PluginCommand("probe",

@ -38,9 +38,11 @@ using namespace std;
using namespace DFHack; using namespace DFHack;
using namespace df::enums; using namespace df::enums;
using df::global::world;
using df::coord2d; using df::coord2d;
DFHACK_PLUGIN("prospector");
REQUIRE_GLOBAL(world);
struct matdata struct matdata
{ {
const static int invalid_z = -30000; const static int invalid_z = -30000;
@ -198,8 +200,6 @@ void printVeins(color_ostream &con, MatMap &mat_map,
command_result prospector (color_ostream &out, vector <string> & parameters); command_result prospector (color_ostream &out, vector <string> & parameters);
DFHACK_PLUGIN("prospector");
DFhackCExport command_result plugin_init ( color_ostream &out, std::vector <PluginCommand> &commands) DFhackCExport command_result plugin_init ( color_ostream &out, std::vector <PluginCommand> &commands)
{ {
commands.push_back(PluginCommand( commands.push_back(PluginCommand(

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

@ -56,6 +56,9 @@ using namespace df::enums;
using namespace RemoteFortressReader; using namespace RemoteFortressReader;
using namespace std; using namespace std;
DFHACK_PLUGIN("RemoteFortressReader");
REQUIRE_GLOBAL(world);
// Here go all the command declarations... // Here go all the command declarations...
// mostly to allow having the mandatory stuff on top of the file and commands on the bottom // mostly to allow having the mandatory stuff on top of the file and commands on the bottom
@ -80,10 +83,6 @@ const char* growth_locations[] = {
}; };
#define GROWTH_LOCATIONS_SIZE 8 #define GROWTH_LOCATIONS_SIZE 8
// A plugin must be able to return its name and version.
// The name string provided must correspond to the filename - skeleton.plug.so or skeleton.plug.dll in this case
DFHACK_PLUGIN("RemoteFortressReader");
// Mandatory init function. If you have some global state, create it here. // Mandatory init function. If you have some global state, create it here.
DFhackCExport command_result plugin_init(color_ostream &out, std::vector <PluginCommand> &commands) DFhackCExport command_result plugin_init(color_ostream &out, std::vector <PluginCommand> &commands)
{ {
@ -387,9 +386,9 @@ RemoteFortressReader::TiletypeVariant TranslateVariant(df::tiletype_variant vari
static command_result CheckHashes(color_ostream &stream, const EmptyMessage *in) static command_result CheckHashes(color_ostream &stream, const EmptyMessage *in)
{ {
clock_t start = clock(); clock_t start = clock();
for (int i = 0; i < df::global::world->map.map_blocks.size(); i++) for (int i = 0; i < world->map.map_blocks.size(); i++)
{ {
df::map_block * block = df::global::world->map.map_blocks[i]; df::map_block * block = world->map.map_blocks[i];
fletcher16((uint8_t*)(block->tiletype), 16 * 16 * sizeof(df::enums::tiletype::tiletype)); fletcher16((uint8_t*)(block->tiletype), 16 * 16 * sizeof(df::enums::tiletype::tiletype));
} }
clock_t end = clock(); clock_t end = clock();
@ -417,7 +416,7 @@ static command_result GetMaterialList(color_ostream &stream, const EmptyMessage
df::world_raws *raws = &df::global::world->raws; df::world_raws *raws = &world->raws;
MaterialInfo mat; MaterialInfo mat;
for (int i = 0; i < raws->inorganics.size(); i++) for (int i = 0; i < raws->inorganics.size(); i++)
{ {
@ -509,7 +508,7 @@ static command_result GetGrowthList(color_ostream &stream, const EmptyMessage *i
df::world_raws *raws = &df::global::world->raws; df::world_raws *raws = &world->raws;
if (!raws) if (!raws)
return CR_OK;//'. return CR_OK;//'.
@ -617,9 +616,9 @@ static command_result GetPlantList(color_ostream &stream, const BlockRequest *in
for (int xx = min_x; xx < max_x; xx++) for (int xx = min_x; xx < max_x; xx++)
for (int yy = min_y; yy < max_y; yy++) for (int yy = min_y; yy < max_y; yy++)
{ {
if (xx < 0 || yy < 0 || xx >= df::global::world->map.x_count_block || yy >= df::global::world->map.y_count_block) if (xx < 0 || yy < 0 || xx >= world->map.x_count_block || yy >= world->map.y_count_block)
continue; continue;
df::map_block_column * column = df::global::world->map.column_index[xx][yy]; df::map_block_column * column = world->map.column_index[xx][yy];
for (int i = 0; i < column->plants.size(); i++) for (int i = 0; i < column->plants.size(); i++)
{ {
df::plant * plant = column->plants[i]; df::plant * plant = column->plants[i];

@ -46,17 +46,17 @@ using namespace DFHack;
using namespace df::enums; using namespace df::enums;
using namespace dfproto; using namespace dfproto;
using df::global::ui; DFHACK_PLUGIN("rename");
using df::global::ui_sidebar_menus; DFHACK_PLUGIN_IS_ENABLED(is_enabled);
using df::global::world;
REQUIRE_GLOBAL(ui);
REQUIRE_GLOBAL(ui_sidebar_menus);
REQUIRE_GLOBAL(world);
DFhackCExport command_result plugin_onstatechange(color_ostream &out, state_change_event event); DFhackCExport command_result plugin_onstatechange(color_ostream &out, state_change_event event);
static command_result rename(color_ostream &out, vector <string> & parameters); static command_result rename(color_ostream &out, vector <string> & parameters);
DFHACK_PLUGIN("rename");
DFHACK_PLUGIN_IS_ENABLED(is_enabled);
DFhackCExport command_result plugin_init (color_ostream &out, std::vector <PluginCommand> &commands) DFhackCExport command_result plugin_init (color_ostream &out, std::vector <PluginCommand> &commands)
{ {
if (world && ui) { if (world && ui) {

@ -28,6 +28,21 @@ using df::viewscreen_dwarfmodest;
using namespace DFHack; using namespace DFHack;
using std::vector; using std::vector;
using std::string; using std::string;
DFHACK_PLUGIN("rendermax");
REQUIRE_GLOBAL(cur_year_tick);
REQUIRE_GLOBAL(cursor);
REQUIRE_GLOBAL(enabler);
REQUIRE_GLOBAL(gametype);
REQUIRE_GLOBAL(gps);
REQUIRE_GLOBAL(ui);
REQUIRE_GLOBAL(ui_area_map_width);
REQUIRE_GLOBAL(ui_menu_width);
REQUIRE_GLOBAL(window_x);
REQUIRE_GLOBAL(window_y);
REQUIRE_GLOBAL(window_z);
REQUIRE_GLOBAL(world);
enum RENDERER_MODE enum RENDERER_MODE
{ {
MODE_DEFAULT,MODE_TRIPPY,MODE_TRUECOLOR,MODE_LUA,MODE_LIGHT MODE_DEFAULT,MODE_TRIPPY,MODE_TRUECOLOR,MODE_LUA,MODE_LIGHT
@ -37,9 +52,6 @@ lightingEngine *engine=NULL;
static command_result rendermax(color_ostream &out, vector <string> & parameters); static command_result rendermax(color_ostream &out, vector <string> & parameters);
DFHACK_PLUGIN("rendermax");
DFhackCExport command_result plugin_init (color_ostream &out, std::vector <PluginCommand> &commands) DFhackCExport command_result plugin_init (color_ostream &out, std::vector <PluginCommand> &commands)
{ {
commands.push_back(PluginCommand( commands.push_back(PluginCommand(
@ -93,34 +105,34 @@ void removeOld()
engine=0; engine=0;
} }
if(current_mode!=MODE_DEFAULT) if(current_mode!=MODE_DEFAULT)
delete df::global::enabler->renderer; delete enabler->renderer;
current_mode=MODE_DEFAULT; current_mode=MODE_DEFAULT;
} }
void installNew(df::renderer* r,RENDERER_MODE newMode) void installNew(df::renderer* r,RENDERER_MODE newMode)
{ {
df::global::enabler->renderer=r; enabler->renderer=r;
current_mode=newMode; current_mode=newMode;
} }
static void lockGrids() static void lockGrids()
{ {
if(current_mode!=MODE_LUA) if(current_mode!=MODE_LUA)
return ; return ;
renderer_lua* r=reinterpret_cast<renderer_lua*>(df::global::enabler->renderer); renderer_lua* r=reinterpret_cast<renderer_lua*>(enabler->renderer);
r->dataMutex.lock(); r->dataMutex.lock();
} }
static void unlockGrids() static void unlockGrids()
{ {
if(current_mode!=MODE_LUA) if(current_mode!=MODE_LUA)
return ; return ;
renderer_lua* r=reinterpret_cast<renderer_lua*>(df::global::enabler->renderer); renderer_lua* r=reinterpret_cast<renderer_lua*>(enabler->renderer);
r->dataMutex.unlock(); r->dataMutex.unlock();
} }
static void resetGrids() static void resetGrids()
{ {
if(current_mode!=MODE_LUA) if(current_mode!=MODE_LUA)
return ; return ;
renderer_lua* r=reinterpret_cast<renderer_lua*>(df::global::enabler->renderer); renderer_lua* r=reinterpret_cast<renderer_lua*>(enabler->renderer);
for(size_t i=0;i<r->foreMult.size();i++) for(size_t i=0;i<r->foreMult.size();i++)
{ {
r->foreMult[i]=rgbf(1,1,1); r->foreMult[i]=rgbf(1,1,1);
@ -133,16 +145,16 @@ static int getGridsSize(lua_State* L)
{ {
if(current_mode!=MODE_LUA) if(current_mode!=MODE_LUA)
return -1; return -1;
renderer_lua* r=reinterpret_cast<renderer_lua*>(df::global::enabler->renderer); renderer_lua* r=reinterpret_cast<renderer_lua*>(enabler->renderer);
lua_pushnumber(L,df::global::gps->dimx); lua_pushnumber(L,gps->dimx);
lua_pushnumber(L,df::global::gps->dimy); lua_pushnumber(L,gps->dimy);
return 2; return 2;
} }
static int getCell(lua_State* L) static int getCell(lua_State* L)
{ {
if(current_mode!=MODE_LUA) if(current_mode!=MODE_LUA)
return 0; return 0;
renderer_lua* r=reinterpret_cast<renderer_lua*>(df::global::enabler->renderer); renderer_lua* r=reinterpret_cast<renderer_lua*>(enabler->renderer);
int x=luaL_checknumber(L,1); int x=luaL_checknumber(L,1);
int y=luaL_checknumber(L,2); int y=luaL_checknumber(L,2);
int id=r->xyToTile(x,y); int id=r->xyToTile(x,y);
@ -193,7 +205,7 @@ static int setCell(lua_State* L)
{ {
if(current_mode!=MODE_LUA) if(current_mode!=MODE_LUA)
return 0; return 0;
renderer_lua* r=reinterpret_cast<renderer_lua*>(df::global::enabler->renderer); renderer_lua* r=reinterpret_cast<renderer_lua*>(enabler->renderer);
int x=luaL_checknumber(L,1); int x=luaL_checknumber(L,1);
int y=luaL_checknumber(L,2); int y=luaL_checknumber(L,2);
@ -242,7 +254,7 @@ static int invalidate(lua_State* L)
{ {
if(current_mode!=MODE_LUA) if(current_mode!=MODE_LUA)
return 0; return 0;
renderer_lua* r=reinterpret_cast<renderer_lua*>(df::global::enabler->renderer); renderer_lua* r=reinterpret_cast<renderer_lua*>(enabler->renderer);
if(lua_gettop(L)==0) if(lua_gettop(L)==0)
{ {
r->invalidate(); r->invalidate();
@ -324,7 +336,7 @@ static command_result rendermax(color_ostream &out, vector <string> & parameters
{ {
if(parameters.size()==0) if(parameters.size()==0)
return CR_WRONG_USAGE; return CR_WRONG_USAGE;
if(!df::global::enabler->renderer->uses_opengl()) if(!enabler->renderer->uses_opengl())
{ {
out.printerr("Sorry, this plugin needs open gl enabled printmode. Try STANDARD or other non-2D\n"); out.printerr("Sorry, this plugin needs open gl enabled printmode. Try STANDARD or other non-2D\n");
return CR_FAILURE; return CR_FAILURE;
@ -333,7 +345,7 @@ static command_result rendermax(color_ostream &out, vector <string> & parameters
if(cmd=="trippy") if(cmd=="trippy")
{ {
removeOld(); removeOld();
installNew(new renderer_trippy(df::global::enabler->renderer),MODE_TRIPPY); installNew(new renderer_trippy(enabler->renderer),MODE_TRIPPY);
return CR_OK; return CR_OK;
} }
else if(cmd=="truecolor") else if(cmd=="truecolor")
@ -341,7 +353,7 @@ static command_result rendermax(color_ostream &out, vector <string> & parameters
if(current_mode!=MODE_TRUECOLOR) if(current_mode!=MODE_TRUECOLOR)
{ {
removeOld(); removeOld();
installNew(new renderer_test(df::global::enabler->renderer),MODE_TRUECOLOR); installNew(new renderer_test(enabler->renderer),MODE_TRUECOLOR);
} }
if(current_mode==MODE_TRUECOLOR && parameters.size()==2) if(current_mode==MODE_TRUECOLOR && parameters.size()==2)
{ {
@ -356,10 +368,10 @@ static command_result rendermax(color_ostream &out, vector <string> & parameters
else if(col=="blue") else if(col=="blue")
cur=blue; cur=blue;
renderer_test* r=reinterpret_cast<renderer_test*>(df::global::enabler->renderer); renderer_test* r=reinterpret_cast<renderer_test*>(enabler->renderer);
tthread::lock_guard<tthread::fast_mutex> guard(r->dataMutex); tthread::lock_guard<tthread::fast_mutex> guard(r->dataMutex);
int h=df::global::gps->dimy; int h=gps->dimy;
int w=df::global::gps->dimx; int w=gps->dimx;
int cx=w/2; int cx=w/2;
int cy=h/2; int cy=h/2;
int rad=cx; int rad=cx;
@ -385,7 +397,7 @@ static command_result rendermax(color_ostream &out, vector <string> & parameters
else if(cmd=="lua") else if(cmd=="lua")
{ {
removeOld(); removeOld();
installNew(new renderer_lua(df::global::enabler->renderer),MODE_LUA); installNew(new renderer_lua(enabler->renderer),MODE_LUA);
lockGrids(); lockGrids();
resetGrids(); resetGrids();
unlockGrids(); unlockGrids();
@ -396,7 +408,7 @@ static command_result rendermax(color_ostream &out, vector <string> & parameters
if(current_mode!=MODE_LIGHT) if(current_mode!=MODE_LIGHT)
{ {
removeOld(); removeOld();
renderer_light *myRender=new renderer_light(df::global::enabler->renderer); renderer_light *myRender=new renderer_light(enabler->renderer);
installNew(myRender,MODE_LIGHT); installNew(myRender,MODE_LIGHT);
engine=new lightingEngineViewscreen(myRender); engine=new lightingEngineViewscreen(myRender);
@ -444,7 +456,7 @@ static command_result rendermax(color_ostream &out, vector <string> & parameters
else else
removeOld(); removeOld();
CoreSuspender guard; CoreSuspender guard;
df::global::gps->force_full_display_count++; gps->force_full_display_count++;
return CR_OK; return CR_OK;
} }
return CR_WRONG_USAGE; return CR_WRONG_USAGE;

@ -34,13 +34,13 @@ using std::vector;
using namespace DFHack; using namespace DFHack;
using namespace df::enums; using namespace df::enums;
using df::global::gps;
using df::global::ui;
using df::global::world;
DFHACK_PLUGIN("resume"); DFHACK_PLUGIN("resume");
#define PLUGIN_VERSION 0.2 #define PLUGIN_VERSION 0.2
REQUIRE_GLOBAL(gps);
REQUIRE_GLOBAL(ui);
REQUIRE_GLOBAL(world);
#ifndef HAVE_NULLPTR #ifndef HAVE_NULLPTR
#define nullptr 0L #define nullptr 0L
#endif #endif

@ -20,7 +20,10 @@ using std::vector;
using namespace DFHack; using namespace DFHack;
using namespace df::enums; using namespace df::enums;
using df::global::world; DFHACK_PLUGIN("reveal");
DFHACK_PLUGIN_IS_ENABLED(is_active);
REQUIRE_GLOBAL(world);
/* /*
* Anything that might reveal Hell is unsafe. * Anything that might reveal Hell is unsafe.
@ -72,8 +75,6 @@ command_result revflood(color_ostream &out, vector<string> & params);
command_result revforget(color_ostream &out, vector<string> & params); command_result revforget(color_ostream &out, vector<string> & params);
command_result nopause(color_ostream &out, vector<string> & params); command_result nopause(color_ostream &out, vector<string> & params);
DFHACK_PLUGIN("reveal");
DFhackCExport command_result plugin_init ( color_ostream &out, vector <PluginCommand> &commands) DFhackCExport command_result plugin_init ( color_ostream &out, vector <PluginCommand> &commands)
{ {
commands.push_back(PluginCommand("reveal","Reveal the map. 'reveal hell' will also reveal hell. 'reveal demon' won't pause.",reveal,false, commands.push_back(PluginCommand("reveal","Reveal the map. 'reveal hell' will also reveal hell. 'reveal demon' won't pause.",reveal,false,
@ -96,8 +97,6 @@ DFhackCExport command_result plugin_init ( color_ostream &out, vector <PluginCom
return CR_OK; return CR_OK;
} }
DFHACK_PLUGIN_IS_ENABLED(is_active);
DFhackCExport command_result plugin_onupdate ( color_ostream &out ) DFhackCExport command_result plugin_onupdate ( color_ostream &out )
{ {
t_gamemodes gm; t_gamemodes gm;

@ -37,9 +37,12 @@ using std::string;
using namespace DFHack; using namespace DFHack;
using namespace df::enums; using namespace df::enums;
using df::global::gps; DFHACK_PLUGIN("search");
using df::global::gview; DFHACK_PLUGIN_IS_ENABLED(is_enabled);
using df::global::ui;
REQUIRE_GLOBAL(gps);
REQUIRE_GLOBAL(gview);
REQUIRE_GLOBAL(ui);
/* /*
Search Plugin Search Plugin
@ -1668,10 +1671,6 @@ IMPLEMENT_HOOKS(df::viewscreen_dwarfmodest, burrow_search);
// //
DFHACK_PLUGIN("search");
DFHACK_PLUGIN_IS_ENABLED(is_enabled);
#define SEARCH_HOOKS \ #define SEARCH_HOOKS \
HOOK_ACTION(unitlist_search_hook) \ HOOK_ACTION(unitlist_search_hook) \
HOOK_ACTION(roomlist_search_hook) \ HOOK_ACTION(roomlist_search_hook) \

@ -19,11 +19,14 @@
using namespace std; using namespace std;
using namespace DFHack; using namespace DFHack;
using namespace df::enums; using namespace df::enums;
using df::global::world;
const int buffer = 20; // seed number buffer - 20 is reasonable DFHACK_PLUGIN("seedwatch");
DFHACK_PLUGIN_IS_ENABLED(running); // whether seedwatch is counting the seeds or not DFHACK_PLUGIN_IS_ENABLED(running); // whether seedwatch is counting the seeds or not
REQUIRE_GLOBAL(world);
const int buffer = 20; // seed number buffer - 20 is reasonable
// abbreviations for the standard plants // abbreviations for the standard plants
map<string, string> abbreviations; map<string, string> abbreviations;
@ -250,8 +253,6 @@ command_result df_seedwatch(color_ostream &out, vector<string>& parameters)
return CR_OK; return CR_OK;
} }
DFHACK_PLUGIN("seedwatch");
DFhackCExport command_result plugin_init(color_ostream &out, vector<PluginCommand>& commands) DFhackCExport command_result plugin_init(color_ostream &out, vector<PluginCommand>& commands)
{ {
commands.push_back(PluginCommand("seedwatch", "Switches cookery based on quantity of seeds, to keep reserves", df_seedwatch)); commands.push_back(PluginCommand("seedwatch", "Switches cookery based on quantity of seeds, to keep reserves", df_seedwatch));

@ -25,7 +25,8 @@ using std::vector;
using namespace DFHack; using namespace DFHack;
using namespace df::enums; using namespace df::enums;
using df::global::world; DFHACK_PLUGIN("showmood");
REQUIRE_GLOBAL(world);
command_result df_showmood (color_ostream &out, vector <string> & parameters) command_result df_showmood (color_ostream &out, vector <string> & parameters)
{ {
@ -291,8 +292,6 @@ command_result df_showmood (color_ostream &out, vector <string> & parameters)
return CR_OK; return CR_OK;
} }
DFHACK_PLUGIN("showmood");
DFhackCExport command_result plugin_init (color_ostream &out, std::vector<PluginCommand> &commands) DFhackCExport command_result plugin_init (color_ostream &out, std::vector<PluginCommand> &commands)
{ {
commands.push_back(PluginCommand("showmood", "Shows items needed for current strange mood.", df_showmood, false, commands.push_back(PluginCommand("showmood", "Shows items needed for current strange mood.", df_showmood, false,

@ -65,16 +65,15 @@ using std::stack;
using namespace DFHack; using namespace DFHack;
using namespace df::enums; using namespace df::enums;
using df::global::gamemode;
using df::global::gps;
using df::global::world;
using df::global::ui;
using df::global::ui_build_selector;
using df::global::process_jobs;
using Screen::Pen; using Screen::Pen;
DFHACK_PLUGIN("siege-engine"); DFHACK_PLUGIN("siege-engine");
REQUIRE_GLOBAL(gamemode);
REQUIRE_GLOBAL(gps);
REQUIRE_GLOBAL(world);
REQUIRE_GLOBAL(ui);
REQUIRE_GLOBAL(ui_build_selector);
REQUIRE_GLOBAL(process_jobs);
/* /*
Aiming is simulated by using a normal distribution to perturb X and Y. Aiming is simulated by using a normal distribution to perturb X and Y.

@ -37,14 +37,15 @@ using std::endl;
using namespace DFHack; using namespace DFHack;
using namespace df::enums; using namespace df::enums;
using df::global::ui; DFHACK_PLUGIN("sort");
using df::global::world; REQUIRE_GLOBAL(ui);
using df::global::ui_building_in_assign; REQUIRE_GLOBAL(world);
using df::global::ui_building_item_cursor; REQUIRE_GLOBAL(ui_building_in_assign);
using df::global::ui_building_assign_type; REQUIRE_GLOBAL(ui_building_item_cursor);
using df::global::ui_building_assign_is_marked; REQUIRE_GLOBAL(ui_building_assign_type);
using df::global::ui_building_assign_units; REQUIRE_GLOBAL(ui_building_assign_is_marked);
using df::global::ui_building_assign_items; REQUIRE_GLOBAL(ui_building_assign_units);
REQUIRE_GLOBAL(ui_building_assign_items);
static bool unit_list_hotkey(df::viewscreen *top); static bool unit_list_hotkey(df::viewscreen *top);
static bool item_list_hotkey(df::viewscreen *top); static bool item_list_hotkey(df::viewscreen *top);
@ -52,8 +53,6 @@ static bool item_list_hotkey(df::viewscreen *top);
static command_result sort_units(color_ostream &out, vector <string> & parameters); static command_result sort_units(color_ostream &out, vector <string> & parameters);
static command_result sort_items(color_ostream &out, vector <string> & parameters); static command_result sort_items(color_ostream &out, vector <string> & parameters);
DFHACK_PLUGIN("sort");
DFhackCExport command_result plugin_init (color_ostream &out, std::vector <PluginCommand> &commands) DFhackCExport command_result plugin_init (color_ostream &out, std::vector <PluginCommand> &commands)
{ {
commands.push_back(PluginCommand( commands.push_back(PluginCommand(

@ -117,14 +117,14 @@ using std::set;
using namespace DFHack; using namespace DFHack;
using namespace df::enums; using namespace df::enums;
using df::global::gps;
using df::global::world;
using df::global::ui;
using df::global::ui_build_selector;
using df::global::cursor;
DFHACK_PLUGIN("steam-engine"); DFHACK_PLUGIN("steam-engine");
REQUIRE_GLOBAL(gps);
REQUIRE_GLOBAL(world);
REQUIRE_GLOBAL(ui);
REQUIRE_GLOBAL(ui_build_selector);
REQUIRE_GLOBAL(cursor);
/* /*
* List of known steam engine workshop raws. * List of known steam engine workshop raws.
*/ */

@ -18,12 +18,9 @@
using namespace DFHack; using namespace DFHack;
using namespace std; using namespace std;
using df::global::world;
using df::global::ui;
using df::building_stockpilest; using df::building_stockpilest;
DFHACK_PLUGIN("stockflow"); DFHACK_PLUGIN("stockflow");
#define AUTOENABLE false #define AUTOENABLE false
#ifdef DFHACK_PLUGIN_IS_ENABLED #ifdef DFHACK_PLUGIN_IS_ENABLED
DFHACK_PLUGIN_IS_ENABLED(enabled); DFHACK_PLUGIN_IS_ENABLED(enabled);
@ -31,6 +28,9 @@ DFHACK_PLUGIN_IS_ENABLED(enabled);
bool enabled = false; bool enabled = false;
#endif #endif
REQUIRE_GLOBAL(world);
REQUIRE_GLOBAL(ui);
bool fast = false; bool fast = false;
const char *tagline = "Allows the fortress bookkeeper to queue jobs through the manager."; const char *tagline = "Allows the fortress bookkeeper to queue jobs through the manager.";
const char *usage = ( const char *usage = (
@ -72,7 +72,7 @@ public:
} else { } else {
// Gather orders when the bookkeeper starts updating stockpile records, // Gather orders when the bookkeeper starts updating stockpile records,
// and enqueue them when the job is done. // and enqueue them when the job is done.
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; if (link->item == NULL) continue;
if (link->item->job_type == job_type::UpdateStockpileRecords) { if (link->item->job_type == job_type::UpdateStockpileRecords) {
found = true; found = true;

@ -58,9 +58,10 @@ using namespace df::enums;
using namespace google::protobuf; using namespace google::protobuf;
using namespace dfstockpiles; using namespace dfstockpiles;
using df::global::world; DFHACK_PLUGIN ( "stockpiles" );
using df::global::ui; REQUIRE_GLOBAL ( world );
using df::global::selection_rect; REQUIRE_GLOBAL ( ui );
REQUIRE_GLOBAL ( selection_rect );
using df::building_stockpilest; using df::building_stockpilest;
using std::placeholders::_1; using std::placeholders::_1;
@ -74,8 +75,6 @@ static bool savestock_guard ( df::viewscreen *top );
static command_result loadstock ( color_ostream &out, vector <string> & parameters ); static command_result loadstock ( color_ostream &out, vector <string> & parameters );
static bool loadstock_guard ( df::viewscreen *top ); static bool loadstock_guard ( df::viewscreen *top );
DFHACK_PLUGIN ( "stockpiles" );
DFhackCExport command_result plugin_init ( color_ostream &out, std::vector <PluginCommand> &commands ) DFhackCExport command_result plugin_init ( color_ostream &out, std::vector <PluginCommand> &commands )
{ {
if ( world && ui ) if ( world && ui )

@ -28,11 +28,11 @@
#include "df/building_cagest.h" #include "df/building_cagest.h"
#include "df/ui_advmode.h" #include "df/ui_advmode.h"
using df::global::world;
DFHACK_PLUGIN("stocks"); DFHACK_PLUGIN("stocks");
#define PLUGIN_VERSION 0.12 #define PLUGIN_VERSION 0.12
REQUIRE_GLOBAL(world);
DFhackCExport command_result plugin_shutdown ( color_ostream &out ) DFhackCExport command_result plugin_shutdown ( color_ostream &out )
{ {
return CR_OK; return CR_OK;

@ -32,15 +32,17 @@ using std::vector;
using namespace DFHack; using namespace DFHack;
using namespace df::enums; using namespace df::enums;
using df::global::world; DFHACK_PLUGIN("strangemood");
using df::global::ui;
using df::global::d_init; REQUIRE_GLOBAL(world);
using df::global::created_item_count; REQUIRE_GLOBAL(ui);
using df::global::created_item_type; REQUIRE_GLOBAL(d_init);
using df::global::created_item_subtype; REQUIRE_GLOBAL(created_item_count);
using df::global::created_item_mattype; REQUIRE_GLOBAL(created_item_type);
using df::global::created_item_matindex; REQUIRE_GLOBAL(created_item_subtype);
using df::global::debug_nomoods; REQUIRE_GLOBAL(created_item_mattype);
REQUIRE_GLOBAL(created_item_matindex);
REQUIRE_GLOBAL(debug_nomoods);
Random::MersenneRNG rng; Random::MersenneRNG rng;
@ -1302,8 +1304,6 @@ command_result df_strangemood (color_ostream &out, vector <string> & parameters)
return CR_OK; return CR_OK;
} }
DFHACK_PLUGIN("strangemood");
DFhackCExport command_result plugin_init (color_ostream &out, std::vector<PluginCommand> &commands) DFhackCExport command_result plugin_init (color_ostream &out, std::vector<PluginCommand> &commands)
{ {
commands.push_back(PluginCommand("strangemood", "Force a strange mood to happen.\n", df_strangemood, false, commands.push_back(PluginCommand("strangemood", "Force a strange mood to happen.\n", df_strangemood, false,

@ -44,7 +44,8 @@ using namespace MapExtras;
using namespace DFHack; using namespace DFHack;
using namespace df::enums; using namespace df::enums;
using df::global::world; DFHACK_PLUGIN("tiletypes");
REQUIRE_GLOBAL(world);
CommandHistory tiletypes_hist; CommandHistory tiletypes_hist;
@ -53,8 +54,6 @@ command_result df_tiletypes_command (color_ostream &out, vector <string> & param
command_result df_tiletypes_here (color_ostream &out, vector <string> & parameters); command_result df_tiletypes_here (color_ostream &out, vector <string> & parameters);
command_result df_tiletypes_here_point (color_ostream &out, vector <string> & parameters); command_result df_tiletypes_here_point (color_ostream &out, vector <string> & parameters);
DFHACK_PLUGIN("tiletypes");
DFhackCExport command_result plugin_init ( color_ostream &out, std::vector <PluginCommand> &commands) DFhackCExport command_result plugin_init ( color_ostream &out, std::vector <PluginCommand> &commands)
{ {
tiletypes_hist.load("tiletypes.history"); tiletypes_hist.load("tiletypes.history");

@ -15,18 +15,18 @@
using namespace DFHack; using namespace DFHack;
using namespace std; using namespace std;
using df::global::world;
using df::global::ui;
using df::building_rollersst; using df::building_rollersst;
using df::building_trapst; using df::building_trapst;
using df::enums::trap_type::trap_type; using df::enums::trap_type::trap_type;
using df::enums::screw_pump_direction::screw_pump_direction; using df::enums::screw_pump_direction::screw_pump_direction;
DFHACK_PLUGIN("trackstop"); DFHACK_PLUGIN("trackstop");
#define AUTOENABLE false #define AUTOENABLE false
DFHACK_PLUGIN_IS_ENABLED(enabled); DFHACK_PLUGIN_IS_ENABLED(enabled);
REQUIRE_GLOBAL(gps);
REQUIRE_GLOBAL(ui);
REQUIRE_GLOBAL(world);
/* /*
* Interface hooks * Interface hooks
@ -270,14 +270,6 @@ IMPLEMENT_VMETHOD_INTERPOSE(roller_hook, render);
DFhackCExport command_result plugin_enable(color_ostream& out, bool enable) { DFhackCExport command_result plugin_enable(color_ostream& out, bool enable) {
// Accept the "enable trackstop" / "disable trackstop" commands. // Accept the "enable trackstop" / "disable trackstop" commands.
if (enable != enabled) { if (enable != enabled) {
// Check for global variables that, if missing, result in total failure.
// Missing enabler and ui_menu_width also produce visible effects, but not nearly as severe.
// This could be moved to the plugin_init step, but that's louder for no real benefit.
if (!(gps && ui && world)) {
out.printerr("trackstop: Missing required global variables.\n");
return CR_FAILURE;
}
if (!INTERPOSE_HOOK(trackstop_hook, feed).apply(enable) || if (!INTERPOSE_HOOK(trackstop_hook, feed).apply(enable) ||
!INTERPOSE_HOOK(trackstop_hook, render).apply(enable) || !INTERPOSE_HOOK(trackstop_hook, render).apply(enable) ||
!INTERPOSE_HOOK(roller_hook, feed).apply(enable) || !INTERPOSE_HOOK(roller_hook, feed).apply(enable) ||

@ -21,8 +21,11 @@
using namespace DFHack; using namespace DFHack;
using df::global::world; DFHACK_PLUGIN("treefarm");
using df::global::ui; DFHACK_PLUGIN_IS_ENABLED(enabled);
REQUIRE_GLOBAL(world);
REQUIRE_GLOBAL(ui);
void checkFarms(color_ostream& out, void* ptr); void checkFarms(color_ostream& out, void* ptr);
command_result treefarm (color_ostream &out, std::vector <std::string> & parameters); command_result treefarm (color_ostream &out, std::vector <std::string> & parameters);
@ -30,9 +33,6 @@ command_result treefarm (color_ostream &out, std::vector <std::string> & paramet
EventManager::EventHandler handler(&checkFarms, -1); EventManager::EventHandler handler(&checkFarms, -1);
int32_t frequency = 1200*30; int32_t frequency = 1200*30;
DFHACK_PLUGIN_IS_ENABLED(enabled);
DFHACK_PLUGIN("treefarm");
DFhackCExport command_result plugin_init ( color_ostream &out, std::vector <PluginCommand> &commands) DFhackCExport command_result plugin_init ( color_ostream &out, std::vector <PluginCommand> &commands)
{ {
commands.push_back(PluginCommand( commands.push_back(PluginCommand(

@ -17,7 +17,9 @@
using namespace DFHack; using namespace DFHack;
using namespace df::enums; using namespace df::enums;
using df::global::world;
DFHACK_PLUGIN("tubefill");
REQUIRE_GLOBAL(world);
bool isDesignatedHollow(df::coord pos) bool isDesignatedHollow(df::coord pos)
{ {
@ -33,8 +35,6 @@ bool isDesignatedHollow(df::coord pos)
command_result tubefill(color_ostream &out, std::vector<std::string> & params); command_result tubefill(color_ostream &out, std::vector<std::string> & params);
DFHACK_PLUGIN("tubefill");
DFhackCExport command_result plugin_init ( color_ostream &out, std::vector <PluginCommand> &commands) DFhackCExport command_result plugin_init ( color_ostream &out, std::vector <PluginCommand> &commands)
{ {
commands.push_back(PluginCommand("tubefill","Fill in all the adamantine tubes again.",tubefill, false, commands.push_back(PluginCommand("tubefill","Fill in all the adamantine tubes again.",tubefill, false,

@ -92,19 +92,20 @@ using std::endl;
using namespace DFHack; using namespace DFHack;
using namespace df::enums; using namespace df::enums;
using df::global::ui; DFHACK_PLUGIN("tweak");
using df::global::world;
using df::global::ui_build_selector; REQUIRE_GLOBAL(ui);
using df::global::ui_menu_width; REQUIRE_GLOBAL(ui_build_selector);
using df::global::ui_area_map_width; REQUIRE_GLOBAL(ui_building_item_cursor);
REQUIRE_GLOBAL(ui_menu_width);
REQUIRE_GLOBAL(ui_area_map_width);
REQUIRE_GLOBAL(world);
using namespace DFHack::Gui; using namespace DFHack::Gui;
static command_result tweak(color_ostream &out, vector <string> & parameters); static command_result tweak(color_ostream &out, vector <string> & parameters);
static std::multimap<std::string, VMethodInterposeLinkBase> tweak_hooks; static std::multimap<std::string, VMethodInterposeLinkBase> tweak_hooks;
DFHACK_PLUGIN("tweak");
#define TWEAK_HOOK(tweak, cls, func) tweak_hooks.insert(std::pair<std::string, VMethodInterposeLinkBase>\ #define TWEAK_HOOK(tweak, cls, func) tweak_hooks.insert(std::pair<std::string, VMethodInterposeLinkBase>\
(tweak, INTERPOSE_HOOK(cls, func))) (tweak, INTERPOSE_HOOK(cls, func)))

@ -13,15 +13,15 @@ using std::string;
using namespace DFHack; using namespace DFHack;
using namespace df::enums; using namespace df::enums;
using df::global::current_weather; DFHACK_PLUGIN("weather");
REQUIRE_GLOBAL(current_weather);
bool locked = false; bool locked = false;
unsigned char locked_data[25]; unsigned char locked_data[25];
command_result weather (color_ostream &out, vector <string> & parameters); command_result weather (color_ostream &out, vector <string> & parameters);
DFHACK_PLUGIN("weather");
DFhackCExport command_result plugin_init ( color_ostream &out, std::vector <PluginCommand> &commands) DFhackCExport command_result plugin_init ( color_ostream &out, std::vector <PluginCommand> &commands)
{ {
commands.push_back(PluginCommand( commands.push_back(PluginCommand(

@ -14,10 +14,9 @@
using namespace std; using namespace std;
using namespace DFHack; using namespace DFHack;
using df::global::process_jobs;
using df::global::process_dig;
DFHACK_PLUGIN("workNow"); DFHACK_PLUGIN("workNow");
REQUIRE_GLOBAL(process_jobs);
REQUIRE_GLOBAL(process_dig);
static int mode = 0; static int mode = 0;

@ -49,10 +49,12 @@ using std::flush;
using namespace DFHack; using namespace DFHack;
using namespace df::enums; using namespace df::enums;
using df::global::world; DFHACK_PLUGIN("workflow");
using df::global::ui;
using df::global::ui_workshop_job_cursor; REQUIRE_GLOBAL(world);
using df::global::job_next_id; REQUIRE_GLOBAL(ui);
REQUIRE_GLOBAL(ui_workshop_job_cursor);
REQUIRE_GLOBAL(job_next_id);
/* Plugin registration */ /* Plugin registration */
@ -61,8 +63,6 @@ static command_result workflow_cmd(color_ostream &out, vector <string> & paramet
static void init_state(color_ostream &out); static void init_state(color_ostream &out);
static void cleanup_state(color_ostream &out); static void cleanup_state(color_ostream &out);
DFHACK_PLUGIN("workflow");
DFhackCExport command_result plugin_init (color_ostream &out, std::vector <PluginCommand> &commands) DFhackCExport command_result plugin_init (color_ostream &out, std::vector <PluginCommand> &commands)
{ {
if (!world || !ui) if (!world || !ui)

@ -74,23 +74,27 @@ using std::vector;
using std::string; using std::string;
using namespace DFHack; using namespace DFHack;
using namespace df::enums; using namespace df::enums;
using df::global::world;
using df::global::cursor; DFHACK_PLUGIN("zone");
using df::global::ui; DFHACK_PLUGIN_IS_ENABLED(is_enabled);
using df::global::ui_build_selector;
using df::global::gps; REQUIRE_GLOBAL(world);
using df::global::cur_year; REQUIRE_GLOBAL(cursor);
using df::global::cur_year_tick; REQUIRE_GLOBAL(ui);
REQUIRE_GLOBAL(ui_build_selector);
using df::global::ui_building_item_cursor; REQUIRE_GLOBAL(gps);
using df::global::ui_building_assign_type; REQUIRE_GLOBAL(cur_year);
using df::global::ui_building_assign_is_marked; REQUIRE_GLOBAL(cur_year_tick);
using df::global::ui_building_assign_units;
using df::global::ui_building_assign_items; REQUIRE_GLOBAL(ui_building_item_cursor);
using df::global::ui_building_in_assign; REQUIRE_GLOBAL(ui_building_assign_type);
REQUIRE_GLOBAL(ui_building_assign_is_marked);
using df::global::ui_menu_width; REQUIRE_GLOBAL(ui_building_assign_units);
using df::global::ui_area_map_width; REQUIRE_GLOBAL(ui_building_assign_items);
REQUIRE_GLOBAL(ui_building_in_assign);
REQUIRE_GLOBAL(ui_menu_width);
REQUIRE_GLOBAL(ui_area_map_width);
using namespace DFHack::Gui; using namespace DFHack::Gui;
@ -98,10 +102,6 @@ command_result df_zone (color_ostream &out, vector <string> & parameters);
command_result df_autonestbox (color_ostream &out, vector <string> & parameters); command_result df_autonestbox (color_ostream &out, vector <string> & parameters);
command_result df_autobutcher(color_ostream &out, vector <string> & parameters); command_result df_autobutcher(color_ostream &out, vector <string> & parameters);
DFHACK_PLUGIN("zone");
DFHACK_PLUGIN_IS_ENABLED(is_enabled);
DFhackCExport command_result plugin_enable ( color_ostream &out, bool enable); DFhackCExport command_result plugin_enable ( color_ostream &out, bool enable);
const string zone_help = const string zone_help =