From a615723b381be211097de7e2fb31c8c07b7c4d7a Mon Sep 17 00:00:00 2001 From: lethosor Date: Sat, 6 Dec 2014 18:47:35 -0500 Subject: [PATCH] Update remaining plugins to use REQUIRE_GLOBAL --- plugins/fastdwarf.cpp | 7 ++-- plugins/feature.cpp | 5 ++- plugins/fixpositions.cpp | 5 ++- plugins/fixveins.cpp | 5 ++- plugins/flows.cpp | 5 ++- plugins/follow.cpp | 7 ++-- plugins/forceequip.cpp | 6 ++-- plugins/getplants.cpp | 5 ++- plugins/infiniteSky.cpp | 5 ++- plugins/initflags.cpp | 5 ++- plugins/isoworldremote.cpp | 14 +++----- plugins/jobutils.cpp | 13 ++++--- plugins/lair.cpp | 2 +- plugins/liquids.cpp | 6 ++-- plugins/manipulator.cpp | 14 ++++---- plugins/misery.cpp | 9 +++-- plugins/mousequery.cpp | 9 +++-- plugins/petcapRemover.cpp | 8 ++--- plugins/plants.cpp | 6 ++-- plugins/power-meter.cpp | 9 +++-- plugins/probe.cpp | 8 ++--- plugins/prospector.cpp | 6 ++-- plugins/regrass.cpp | 3 +- plugins/remotefortressreader.cpp | 19 +++++------ plugins/rename.cpp | 12 +++---- plugins/rendermax/rendermax.cpp | 58 +++++++++++++++++++------------- plugins/resume.cpp | 8 ++--- plugins/reveal.cpp | 9 +++-- plugins/search.cpp | 13 ++++--- plugins/seedwatch.cpp | 9 ++--- plugins/showmood.cpp | 5 ++- plugins/siege-engine.cpp | 13 ++++--- plugins/sort.cpp | 19 +++++------ plugins/steam-engine.cpp | 12 +++---- plugins/stockflow.cpp | 8 ++--- plugins/stockpiles.cpp | 9 +++-- plugins/stocks.cpp | 4 +-- plugins/strangemood.cpp | 22 ++++++------ plugins/tiletypes.cpp | 5 ++- plugins/trackstop.cpp | 14 ++------ plugins/treefarm.cpp | 10 +++--- plugins/tubefill.cpp | 6 ++-- plugins/tweak/tweak.cpp | 15 +++++---- plugins/weather.cpp | 6 ++-- plugins/workNow.cpp | 5 ++- plugins/workflow.cpp | 12 +++---- plugins/zone.cpp | 42 +++++++++++------------ 47 files changed, 236 insertions(+), 261 deletions(-) diff --git a/plugins/fastdwarf.cpp b/plugins/fastdwarf.cpp index 5416f6d00..47b2d5cac 100644 --- a/plugins/fastdwarf.cpp +++ b/plugins/fastdwarf.cpp @@ -17,13 +17,10 @@ using std::vector; using namespace DFHack; using namespace df::enums; -using df::global::world; -using df::global::debug_turbospeed; - -// dfhack interface DFHACK_PLUGIN("fastdwarf"); - DFHACK_PLUGIN_IS_ENABLED(active); +REQUIRE_GLOBAL(world); +using df::global::debug_turbospeed; // not required static bool enable_fastdwarf = false; static bool enable_teledwarf = false; diff --git a/plugins/feature.cpp b/plugins/feature.cpp index cbfd7b5e0..30c71cda2 100644 --- a/plugins/feature.cpp +++ b/plugins/feature.cpp @@ -17,7 +17,8 @@ using std::endl; using namespace DFHack; using namespace df::enums; -using df::global::world; +DFHACK_PLUGIN("feature"); +REQUIRE_GLOBAL(world); static command_result feature(color_ostream &out, vector ¶meters) @@ -92,8 +93,6 @@ static command_result feature(color_ostream &out, vector ¶meters) return CR_OK; } -DFHACK_PLUGIN("feature"); - DFhackCExport command_result plugin_init (color_ostream &out, std::vector &commands) { commands.push_back(PluginCommand( diff --git a/plugins/fixpositions.cpp b/plugins/fixpositions.cpp index bd8fb2791..7a22fd2b8 100644 --- a/plugins/fixpositions.cpp +++ b/plugins/fixpositions.cpp @@ -18,7 +18,8 @@ using std::vector; using namespace DFHack; using namespace df::enums; -using df::global::world; +DFHACK_PLUGIN("fixpositions"); +REQUIRE_GLOBAL(world); command_result df_fixdiplomats (color_ostream &out, vector ¶meters) { @@ -226,8 +227,6 @@ command_result df_fixmerchants (color_ostream &out, vector ¶meters) return CR_OK; } -DFHACK_PLUGIN("fixpositions"); - DFhackCExport command_result plugin_init ( color_ostream &out, std::vector &commands) { commands.push_back(PluginCommand( diff --git a/plugins/fixveins.cpp b/plugins/fixveins.cpp index f02f61673..5f612c9ad 100644 --- a/plugins/fixveins.cpp +++ b/plugins/fixveins.cpp @@ -19,7 +19,8 @@ using std::string; using namespace DFHack; using namespace df::enums; -using df::global::world; +DFHACK_PLUGIN("fixveins"); +REQUIRE_GLOBAL(world); bool setTileMaterial(df::tiletype &tile, const df::tiletype_material mat) { @@ -95,8 +96,6 @@ command_result df_fixveins (color_ostream &out, vector & parameters) return CR_OK; } -DFHACK_PLUGIN("fixveins"); - DFhackCExport command_result plugin_init ( color_ostream &out, std::vector &commands) { commands.push_back(PluginCommand("fixveins", diff --git a/plugins/flows.cpp b/plugins/flows.cpp index 26188f512..070776b10 100644 --- a/plugins/flows.cpp +++ b/plugins/flows.cpp @@ -15,7 +15,8 @@ using std::vector; using namespace DFHack; using namespace df::enums; -using df::global::world; +DFHACK_PLUGIN("flows"); +REQUIRE_GLOBAL(world); command_result df_flows (color_ostream &out, vector & parameters) { @@ -56,8 +57,6 @@ command_result df_flows (color_ostream &out, vector & parameters) return CR_OK; } -DFHACK_PLUGIN("flows"); - DFhackCExport command_result plugin_init ( color_ostream &out, std::vector &commands) { commands.push_back(PluginCommand("flows", diff --git a/plugins/follow.cpp b/plugins/follow.cpp index de3428300..ff0a94787 100644 --- a/plugins/follow.cpp +++ b/plugins/follow.cpp @@ -16,7 +16,9 @@ using namespace DFHack; 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 & parameters); @@ -24,9 +26,6 @@ df::unit *followedUnit; int32_t prevX, prevY, prevZ; uint8_t prevMenuWidth; -DFHACK_PLUGIN("follow"); -DFHACK_PLUGIN_IS_ENABLED(is_enabled); - DFhackCExport command_result plugin_init ( color_ostream &out, std::vector &commands) { commands.push_back(PluginCommand( diff --git a/plugins/forceequip.cpp b/plugins/forceequip.cpp index 54da374b5..1f1eb1ce6 100644 --- a/plugins/forceequip.cpp +++ b/plugins/forceequip.cpp @@ -46,13 +46,13 @@ using namespace df::enums; using MapExtras::Block; using MapExtras::MapCache; -using df::global::world; + +DFHACK_PLUGIN("forceequip"); +REQUIRE_GLOBAL(world); const int const_GloveRightHandedness = 1; const int const_GloveLeftHandedness = 2; -DFHACK_PLUGIN("forceequip"); - command_result df_forceequip(color_ostream &out, vector & parameters); const string forceequip_help = diff --git a/plugins/getplants.cpp b/plugins/getplants.cpp index f4771b58b..ed3272265 100644 --- a/plugins/getplants.cpp +++ b/plugins/getplants.cpp @@ -22,7 +22,8 @@ using std::set; using namespace DFHack; using namespace df::enums; -using df::global::world; +DFHACK_PLUGIN("getplants"); +REQUIRE_GLOBAL(world); command_result df_getplants (color_ostream &out, vector & parameters) { @@ -148,8 +149,6 @@ command_result df_getplants (color_ostream &out, vector & parameters) return CR_OK; } -DFHACK_PLUGIN("getplants"); - DFhackCExport command_result plugin_init ( color_ostream &out, vector &commands) { commands.push_back(PluginCommand( diff --git a/plugins/infiniteSky.cpp b/plugins/infiniteSky.cpp index 774ac4d51..f2853f128 100644 --- a/plugins/infiniteSky.cpp +++ b/plugins/infiniteSky.cpp @@ -23,12 +23,11 @@ using namespace std; using namespace DFHack; using namespace df::enums; -using df::global::world; +DFHACK_PLUGIN("infiniteSky"); +REQUIRE_GLOBAL(world); command_result infiniteSky (color_ostream &out, std::vector & parameters); -DFHACK_PLUGIN("infiniteSky"); - DFhackCExport command_result plugin_init ( color_ostream &out, std::vector &commands) { commands.push_back(PluginCommand( diff --git a/plugins/initflags.cpp b/plugins/initflags.cpp index 6aa78930a..24c773679 100644 --- a/plugins/initflags.cpp +++ b/plugins/initflags.cpp @@ -12,13 +12,12 @@ using std::endl; using namespace DFHack; using namespace df::enums; -using df::global::d_init; +DFHACK_PLUGIN("initflags"); +REQUIRE_GLOBAL(d_init); command_result twaterlvl(color_ostream &out, vector & parameters); command_result tidlers(color_ostream &out, vector & parameters); -DFHACK_PLUGIN("initflags"); - DFhackCExport command_result plugin_init (color_ostream &out, std::vector &commands) { if (d_init) { diff --git a/plugins/isoworldremote.cpp b/plugins/isoworldremote.cpp index 78baad1e1..607035d7b 100644 --- a/plugins/isoworldremote.cpp +++ b/plugins/isoworldremote.cpp @@ -31,10 +31,11 @@ using namespace DFHack; using namespace df::enums; using namespace isoworldremote; -using df::global::gamemode; -using df::global::world; -using df::global::cur_year; -using df::global::cur_season; +DFHACK_PLUGIN("isoworldremote"); +REQUIRE_GLOBAL(gamemode); +REQUIRE_GLOBAL(world); +REQUIRE_GLOBAL(cur_year); +REQUIRE_GLOBAL(cur_season); // Here go all the command declarations... // 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(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. DFhackCExport command_result plugin_init ( color_ostream &out, std::vector &commands) { diff --git a/plugins/jobutils.cpp b/plugins/jobutils.cpp index dbfe26b90..3e3b6b2a0 100644 --- a/plugins/jobutils.cpp +++ b/plugins/jobutils.cpp @@ -31,11 +31,12 @@ using std::endl; using namespace DFHack; using namespace df::enums; -using df::global::world; -using df::global::ui; -using df::global::ui_build_selector; -using df::global::ui_workshop_job_cursor; -using df::global::job_next_id; +DFHACK_PLUGIN("jobutils"); +REQUIRE_GLOBAL(world); +REQUIRE_GLOBAL(ui); +REQUIRE_GLOBAL(ui_build_selector); +REQUIRE_GLOBAL(ui_workshop_job_cursor); +REQUIRE_GLOBAL(job_next_id); /* Plugin registration */ @@ -45,8 +46,6 @@ static command_result job_material(color_ostream &out, vector & paramet static command_result job_duplicate(color_ostream &out, vector & parameters); static command_result job_cmd(color_ostream &out, vector & parameters); -DFHACK_PLUGIN("jobutils"); - DFhackCExport command_result plugin_init (color_ostream &out, std::vector &commands) { if (!world || !ui) diff --git a/plugins/lair.cpp b/plugins/lair.cpp index cafbbcc33..0ae612e07 100644 --- a/plugins/lair.cpp +++ b/plugins/lair.cpp @@ -12,9 +12,9 @@ #include "modules/Gui.h" using namespace DFHack; using namespace df::enums; -using df::global::world; DFHACK_PLUGIN("lair"); +REQUIRE_GLOBAL(world); enum state { diff --git a/plugins/liquids.cpp b/plugins/liquids.cpp index 5ec25de34..68229aaa3 100644 --- a/plugins/liquids.cpp +++ b/plugins/liquids.cpp @@ -46,15 +46,15 @@ using std::set; using namespace MapExtras; using namespace DFHack; using namespace df::enums; -using df::global::world; + +DFHACK_PLUGIN("liquids"); +REQUIRE_GLOBAL(world); CommandHistory liquids_hist; command_result df_liquids (color_ostream &out, vector & parameters); command_result df_liquids_here (color_ostream &out, vector & parameters); -DFHACK_PLUGIN("liquids"); - DFhackCExport command_result plugin_init ( color_ostream &out, std::vector &commands) { liquids_hist.load("liquids.history"); diff --git a/plugins/manipulator.cpp b/plugins/manipulator.cpp index 93459e732..776100bd7 100644 --- a/plugins/manipulator.cpp +++ b/plugins/manipulator.cpp @@ -36,10 +36,12 @@ using std::string; using namespace DFHack; using namespace df::enums; -using df::global::world; -using df::global::ui; -using df::global::gps; -using df::global::enabler; +DFHACK_PLUGIN("manipulator"); +DFHACK_PLUGIN_IS_ENABLED(is_enabled); +REQUIRE_GLOBAL(world); +REQUIRE_GLOBAL(ui); +REQUIRE_GLOBAL(gps); +REQUIRE_GLOBAL(enabler); struct SkillLevel { @@ -1291,10 +1293,6 @@ struct unitlist_hook : df::viewscreen_unitlistst IMPLEMENT_VMETHOD_INTERPOSE(unitlist_hook, feed); 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) { if (!gps) diff --git a/plugins/misery.cpp b/plugins/misery.cpp index bc617b906..bc4ba3777 100644 --- a/plugins/misery.cpp +++ b/plugins/misery.cpp @@ -15,11 +15,12 @@ using namespace std; using namespace DFHack; -using df::global::world; -using df::global::ui; - +DFHACK_PLUGIN("misery"); DFHACK_PLUGIN_IS_ENABLED(is_enabled); +REQUIRE_GLOBAL(world); +REQUIRE_GLOBAL(ui); + static int factor = 1; static map processedThoughtCountTable; @@ -28,8 +29,6 @@ static vector > fakeThoughts; static int count; const int maxCount = 1000; -DFHACK_PLUGIN("misery"); - command_result misery(color_ostream& out, vector& parameters); DFhackCExport command_result plugin_shutdown(color_ostream& out) { diff --git a/plugins/mousequery.cpp b/plugins/mousequery.cpp index c0143e830..1b9eedd96 100644 --- a/plugins/mousequery.cpp +++ b/plugins/mousequery.cpp @@ -21,14 +21,13 @@ #include "TileTypes.h" #include "DataFuncs.h" -using df::global::world; -using df::global::ui; -using df::global::ui_build_selector; +DFHACK_PLUGIN("mousequery"); +REQUIRE_GLOBAL(world); +REQUIRE_GLOBAL(ui); +REQUIRE_GLOBAL(ui_build_selector); using namespace df::enums::ui_sidebar_mode; -DFHACK_PLUGIN("mousequery"); - #define PLUGIN_VERSION 0.18 static int32_t last_clicked_x, last_clicked_y, last_clicked_z; diff --git a/plugins/petcapRemover.cpp b/plugins/petcapRemover.cpp index 44870eb76..7eaa3b1e2 100644 --- a/plugins/petcapRemover.cpp +++ b/plugins/petcapRemover.cpp @@ -20,17 +20,17 @@ using namespace DFHack; 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 popcap = 100; static int32_t pregtime = 200000; -DFHACK_PLUGIN_IS_ENABLED(is_enabled); command_result petcapRemover (color_ostream &out, std::vector & parameters); -DFHACK_PLUGIN("petcapRemover"); - DFhackCExport command_result plugin_init ( color_ostream &out, std::vector &commands) { commands.push_back(PluginCommand( diff --git a/plugins/plants.cpp b/plugins/plants.cpp index 9509e07f8..5d84ca96e 100644 --- a/plugins/plants.cpp +++ b/plugins/plants.cpp @@ -18,11 +18,11 @@ using std::vector; using std::string; 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"); +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 enum do_what diff --git a/plugins/power-meter.cpp b/plugins/power-meter.cpp index 0f8135eed..039b133f2 100644 --- a/plugins/power-meter.cpp +++ b/plugins/power-meter.cpp @@ -38,12 +38,11 @@ using std::stack; using namespace DFHack; 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"); +REQUIRE_GLOBAL(gps); +REQUIRE_GLOBAL(world); +REQUIRE_GLOBAL(ui); +REQUIRE_GLOBAL(ui_build_selector); static const uint32_t METER_BIT = 0x80000000U; diff --git a/plugins/probe.cpp b/plugins/probe.cpp index 28b62c24e..045326d62 100644 --- a/plugins/probe.cpp +++ b/plugins/probe.cpp @@ -33,15 +33,15 @@ using std::vector; using std::string; using namespace DFHack; 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 & parameters); command_result df_cprobe (color_ostream &out, vector & parameters); command_result df_bprobe (color_ostream &out, vector & parameters); -DFHACK_PLUGIN("probe"); - DFhackCExport command_result plugin_init ( color_ostream &out, std::vector &commands) { commands.push_back(PluginCommand("probe", diff --git a/plugins/prospector.cpp b/plugins/prospector.cpp index 8b505c221..995dea9ba 100644 --- a/plugins/prospector.cpp +++ b/plugins/prospector.cpp @@ -38,9 +38,11 @@ using namespace std; using namespace DFHack; using namespace df::enums; -using df::global::world; using df::coord2d; +DFHACK_PLUGIN("prospector"); +REQUIRE_GLOBAL(world); + struct matdata { 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 & parameters); -DFHACK_PLUGIN("prospector"); - DFhackCExport command_result plugin_init ( color_ostream &out, std::vector &commands) { commands.push_back(PluginCommand( diff --git a/plugins/regrass.cpp b/plugins/regrass.cpp index 9c687ad7d..22b6a6747 100644 --- a/plugins/regrass.cpp +++ b/plugins/regrass.cpp @@ -22,9 +22,8 @@ using std::vector; using namespace std; using namespace DFHack; -using df::global::world; - DFHACK_PLUGIN("regrass"); +REQUIRE_GLOBAL(world); command_result df_regrass (color_ostream &out, vector & parameters); diff --git a/plugins/remotefortressreader.cpp b/plugins/remotefortressreader.cpp index 3ef673119..8c1307f61 100644 --- a/plugins/remotefortressreader.cpp +++ b/plugins/remotefortressreader.cpp @@ -56,6 +56,9 @@ using namespace df::enums; using namespace RemoteFortressReader; using namespace std; +DFHACK_PLUGIN("RemoteFortressReader"); +REQUIRE_GLOBAL(world); + // Here go all the command declarations... // 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 -// 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. DFhackCExport command_result plugin_init(color_ostream &out, std::vector &commands) { @@ -387,9 +386,9 @@ RemoteFortressReader::TiletypeVariant TranslateVariant(df::tiletype_variant vari static command_result CheckHashes(color_ostream &stream, const EmptyMessage *in) { 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)); } 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; 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) 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 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; - 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++) { df::plant * plant = column->plants[i]; diff --git a/plugins/rename.cpp b/plugins/rename.cpp index 383066b5e..0ef3e02d5 100644 --- a/plugins/rename.cpp +++ b/plugins/rename.cpp @@ -46,17 +46,17 @@ using namespace DFHack; using namespace df::enums; using namespace dfproto; -using df::global::ui; -using df::global::ui_sidebar_menus; -using df::global::world; +DFHACK_PLUGIN("rename"); +DFHACK_PLUGIN_IS_ENABLED(is_enabled); + +REQUIRE_GLOBAL(ui); +REQUIRE_GLOBAL(ui_sidebar_menus); +REQUIRE_GLOBAL(world); DFhackCExport command_result plugin_onstatechange(color_ostream &out, state_change_event event); static command_result rename(color_ostream &out, vector & parameters); -DFHACK_PLUGIN("rename"); -DFHACK_PLUGIN_IS_ENABLED(is_enabled); - DFhackCExport command_result plugin_init (color_ostream &out, std::vector &commands) { if (world && ui) { diff --git a/plugins/rendermax/rendermax.cpp b/plugins/rendermax/rendermax.cpp index a6b2f17c7..a2edd3b0a 100644 --- a/plugins/rendermax/rendermax.cpp +++ b/plugins/rendermax/rendermax.cpp @@ -28,6 +28,21 @@ using df::viewscreen_dwarfmodest; using namespace DFHack; using std::vector; 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 { 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 & parameters); -DFHACK_PLUGIN("rendermax"); - - DFhackCExport command_result plugin_init (color_ostream &out, std::vector &commands) { commands.push_back(PluginCommand( @@ -93,34 +105,34 @@ void removeOld() engine=0; } if(current_mode!=MODE_DEFAULT) - delete df::global::enabler->renderer; + delete enabler->renderer; current_mode=MODE_DEFAULT; } void installNew(df::renderer* r,RENDERER_MODE newMode) { - df::global::enabler->renderer=r; + enabler->renderer=r; current_mode=newMode; } static void lockGrids() { if(current_mode!=MODE_LUA) return ; - renderer_lua* r=reinterpret_cast(df::global::enabler->renderer); + renderer_lua* r=reinterpret_cast(enabler->renderer); r->dataMutex.lock(); } static void unlockGrids() { if(current_mode!=MODE_LUA) return ; - renderer_lua* r=reinterpret_cast(df::global::enabler->renderer); + renderer_lua* r=reinterpret_cast(enabler->renderer); r->dataMutex.unlock(); } static void resetGrids() { if(current_mode!=MODE_LUA) return ; - renderer_lua* r=reinterpret_cast(df::global::enabler->renderer); + renderer_lua* r=reinterpret_cast(enabler->renderer); for(size_t i=0;iforeMult.size();i++) { r->foreMult[i]=rgbf(1,1,1); @@ -133,16 +145,16 @@ static int getGridsSize(lua_State* L) { if(current_mode!=MODE_LUA) return -1; - renderer_lua* r=reinterpret_cast(df::global::enabler->renderer); - lua_pushnumber(L,df::global::gps->dimx); - lua_pushnumber(L,df::global::gps->dimy); + renderer_lua* r=reinterpret_cast(enabler->renderer); + lua_pushnumber(L,gps->dimx); + lua_pushnumber(L,gps->dimy); return 2; } static int getCell(lua_State* L) { if(current_mode!=MODE_LUA) return 0; - renderer_lua* r=reinterpret_cast(df::global::enabler->renderer); + renderer_lua* r=reinterpret_cast(enabler->renderer); int x=luaL_checknumber(L,1); int y=luaL_checknumber(L,2); int id=r->xyToTile(x,y); @@ -193,7 +205,7 @@ static int setCell(lua_State* L) { if(current_mode!=MODE_LUA) return 0; - renderer_lua* r=reinterpret_cast(df::global::enabler->renderer); + renderer_lua* r=reinterpret_cast(enabler->renderer); int x=luaL_checknumber(L,1); int y=luaL_checknumber(L,2); @@ -242,7 +254,7 @@ static int invalidate(lua_State* L) { if(current_mode!=MODE_LUA) return 0; - renderer_lua* r=reinterpret_cast(df::global::enabler->renderer); + renderer_lua* r=reinterpret_cast(enabler->renderer); if(lua_gettop(L)==0) { r->invalidate(); @@ -324,7 +336,7 @@ static command_result rendermax(color_ostream &out, vector & parameters { if(parameters.size()==0) 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"); return CR_FAILURE; @@ -333,7 +345,7 @@ static command_result rendermax(color_ostream &out, vector & parameters if(cmd=="trippy") { removeOld(); - installNew(new renderer_trippy(df::global::enabler->renderer),MODE_TRIPPY); + installNew(new renderer_trippy(enabler->renderer),MODE_TRIPPY); return CR_OK; } else if(cmd=="truecolor") @@ -341,7 +353,7 @@ static command_result rendermax(color_ostream &out, vector & parameters if(current_mode!=MODE_TRUECOLOR) { 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) { @@ -356,10 +368,10 @@ static command_result rendermax(color_ostream &out, vector & parameters else if(col=="blue") cur=blue; - renderer_test* r=reinterpret_cast(df::global::enabler->renderer); + renderer_test* r=reinterpret_cast(enabler->renderer); tthread::lock_guard guard(r->dataMutex); - int h=df::global::gps->dimy; - int w=df::global::gps->dimx; + int h=gps->dimy; + int w=gps->dimx; int cx=w/2; int cy=h/2; int rad=cx; @@ -385,7 +397,7 @@ static command_result rendermax(color_ostream &out, vector & parameters else if(cmd=="lua") { removeOld(); - installNew(new renderer_lua(df::global::enabler->renderer),MODE_LUA); + installNew(new renderer_lua(enabler->renderer),MODE_LUA); lockGrids(); resetGrids(); unlockGrids(); @@ -396,7 +408,7 @@ static command_result rendermax(color_ostream &out, vector & parameters if(current_mode!=MODE_LIGHT) { removeOld(); - renderer_light *myRender=new renderer_light(df::global::enabler->renderer); + renderer_light *myRender=new renderer_light(enabler->renderer); installNew(myRender,MODE_LIGHT); engine=new lightingEngineViewscreen(myRender); @@ -444,7 +456,7 @@ static command_result rendermax(color_ostream &out, vector & parameters else removeOld(); CoreSuspender guard; - df::global::gps->force_full_display_count++; + gps->force_full_display_count++; return CR_OK; } return CR_WRONG_USAGE; diff --git a/plugins/resume.cpp b/plugins/resume.cpp index 01127ef94..e0db688ff 100644 --- a/plugins/resume.cpp +++ b/plugins/resume.cpp @@ -34,13 +34,13 @@ using std::vector; using namespace DFHack; using namespace df::enums; -using df::global::gps; -using df::global::ui; -using df::global::world; - DFHACK_PLUGIN("resume"); #define PLUGIN_VERSION 0.2 +REQUIRE_GLOBAL(gps); +REQUIRE_GLOBAL(ui); +REQUIRE_GLOBAL(world); + #ifndef HAVE_NULLPTR #define nullptr 0L #endif diff --git a/plugins/reveal.cpp b/plugins/reveal.cpp index c0d71bb7b..c6b7cafbf 100644 --- a/plugins/reveal.cpp +++ b/plugins/reveal.cpp @@ -20,7 +20,10 @@ using std::vector; using namespace DFHack; 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. @@ -72,8 +75,6 @@ command_result revflood(color_ostream &out, vector & params); command_result revforget(color_ostream &out, vector & params); command_result nopause(color_ostream &out, vector & params); -DFHACK_PLUGIN("reveal"); - DFhackCExport command_result plugin_init ( color_ostream &out, vector &commands) { 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 abbreviations; @@ -250,8 +253,6 @@ command_result df_seedwatch(color_ostream &out, vector& parameters) return CR_OK; } -DFHACK_PLUGIN("seedwatch"); - DFhackCExport command_result plugin_init(color_ostream &out, vector& commands) { commands.push_back(PluginCommand("seedwatch", "Switches cookery based on quantity of seeds, to keep reserves", df_seedwatch)); diff --git a/plugins/showmood.cpp b/plugins/showmood.cpp index e0bc5a08d..34b2c8f44 100644 --- a/plugins/showmood.cpp +++ b/plugins/showmood.cpp @@ -25,7 +25,8 @@ using std::vector; using namespace DFHack; using namespace df::enums; -using df::global::world; +DFHACK_PLUGIN("showmood"); +REQUIRE_GLOBAL(world); command_result df_showmood (color_ostream &out, vector & parameters) { @@ -291,8 +292,6 @@ command_result df_showmood (color_ostream &out, vector & parameters) return CR_OK; } -DFHACK_PLUGIN("showmood"); - DFhackCExport command_result plugin_init (color_ostream &out, std::vector &commands) { commands.push_back(PluginCommand("showmood", "Shows items needed for current strange mood.", df_showmood, false, diff --git a/plugins/siege-engine.cpp b/plugins/siege-engine.cpp index b3e5a208d..4ad8fa341 100644 --- a/plugins/siege-engine.cpp +++ b/plugins/siege-engine.cpp @@ -65,16 +65,15 @@ using std::stack; using namespace DFHack; 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; 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. diff --git a/plugins/sort.cpp b/plugins/sort.cpp index e4aad61e2..7d80b4aa1 100644 --- a/plugins/sort.cpp +++ b/plugins/sort.cpp @@ -37,14 +37,15 @@ using std::endl; using namespace DFHack; using namespace df::enums; -using df::global::ui; -using df::global::world; -using df::global::ui_building_in_assign; -using df::global::ui_building_item_cursor; -using df::global::ui_building_assign_type; -using df::global::ui_building_assign_is_marked; -using df::global::ui_building_assign_units; -using df::global::ui_building_assign_items; +DFHACK_PLUGIN("sort"); +REQUIRE_GLOBAL(ui); +REQUIRE_GLOBAL(world); +REQUIRE_GLOBAL(ui_building_in_assign); +REQUIRE_GLOBAL(ui_building_item_cursor); +REQUIRE_GLOBAL(ui_building_assign_type); +REQUIRE_GLOBAL(ui_building_assign_is_marked); +REQUIRE_GLOBAL(ui_building_assign_units); +REQUIRE_GLOBAL(ui_building_assign_items); static bool unit_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 & parameters); static command_result sort_items(color_ostream &out, vector & parameters); -DFHACK_PLUGIN("sort"); - DFhackCExport command_result plugin_init (color_ostream &out, std::vector &commands) { commands.push_back(PluginCommand( diff --git a/plugins/steam-engine.cpp b/plugins/steam-engine.cpp index 138de3916..2a22d5953 100644 --- a/plugins/steam-engine.cpp +++ b/plugins/steam-engine.cpp @@ -117,14 +117,14 @@ using std::set; using namespace DFHack; 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"); +REQUIRE_GLOBAL(gps); +REQUIRE_GLOBAL(world); +REQUIRE_GLOBAL(ui); +REQUIRE_GLOBAL(ui_build_selector); +REQUIRE_GLOBAL(cursor); + /* * List of known steam engine workshop raws. */ diff --git a/plugins/stockflow.cpp b/plugins/stockflow.cpp index 257680682..33068479e 100644 --- a/plugins/stockflow.cpp +++ b/plugins/stockflow.cpp @@ -18,12 +18,9 @@ using namespace DFHack; using namespace std; -using df::global::world; -using df::global::ui; using df::building_stockpilest; DFHACK_PLUGIN("stockflow"); - #define AUTOENABLE false #ifdef DFHACK_PLUGIN_IS_ENABLED DFHACK_PLUGIN_IS_ENABLED(enabled); @@ -31,6 +28,9 @@ DFHACK_PLUGIN_IS_ENABLED(enabled); bool enabled = false; #endif +REQUIRE_GLOBAL(world); +REQUIRE_GLOBAL(ui); + bool fast = false; const char *tagline = "Allows the fortress bookkeeper to queue jobs through the manager."; const char *usage = ( @@ -72,7 +72,7 @@ public: } else { // Gather orders when the bookkeeper starts updating stockpile records, // 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->job_type == job_type::UpdateStockpileRecords) { found = true; diff --git a/plugins/stockpiles.cpp b/plugins/stockpiles.cpp index ebf4b0d40..ae257c55a 100644 --- a/plugins/stockpiles.cpp +++ b/plugins/stockpiles.cpp @@ -58,9 +58,10 @@ using namespace df::enums; using namespace google::protobuf; using namespace dfstockpiles; -using df::global::world; -using df::global::ui; -using df::global::selection_rect; +DFHACK_PLUGIN ( "stockpiles" ); +REQUIRE_GLOBAL ( world ); +REQUIRE_GLOBAL ( ui ); +REQUIRE_GLOBAL ( selection_rect ); using df::building_stockpilest; using std::placeholders::_1; @@ -74,8 +75,6 @@ static bool savestock_guard ( df::viewscreen *top ); static command_result loadstock ( color_ostream &out, vector & parameters ); static bool loadstock_guard ( df::viewscreen *top ); -DFHACK_PLUGIN ( "stockpiles" ); - DFhackCExport command_result plugin_init ( color_ostream &out, std::vector &commands ) { if ( world && ui ) diff --git a/plugins/stocks.cpp b/plugins/stocks.cpp index c5fbed4d5..56692d5c4 100644 --- a/plugins/stocks.cpp +++ b/plugins/stocks.cpp @@ -28,11 +28,11 @@ #include "df/building_cagest.h" #include "df/ui_advmode.h" -using df::global::world; - DFHACK_PLUGIN("stocks"); #define PLUGIN_VERSION 0.12 +REQUIRE_GLOBAL(world); + DFhackCExport command_result plugin_shutdown ( color_ostream &out ) { return CR_OK; diff --git a/plugins/strangemood.cpp b/plugins/strangemood.cpp index 74c717816..09c4ead11 100644 --- a/plugins/strangemood.cpp +++ b/plugins/strangemood.cpp @@ -32,15 +32,17 @@ using std::vector; using namespace DFHack; using namespace df::enums; -using df::global::world; -using df::global::ui; -using df::global::d_init; -using df::global::created_item_count; -using df::global::created_item_type; -using df::global::created_item_subtype; -using df::global::created_item_mattype; -using df::global::created_item_matindex; -using df::global::debug_nomoods; +DFHACK_PLUGIN("strangemood"); + +REQUIRE_GLOBAL(world); +REQUIRE_GLOBAL(ui); +REQUIRE_GLOBAL(d_init); +REQUIRE_GLOBAL(created_item_count); +REQUIRE_GLOBAL(created_item_type); +REQUIRE_GLOBAL(created_item_subtype); +REQUIRE_GLOBAL(created_item_mattype); +REQUIRE_GLOBAL(created_item_matindex); +REQUIRE_GLOBAL(debug_nomoods); Random::MersenneRNG rng; @@ -1302,8 +1304,6 @@ command_result df_strangemood (color_ostream &out, vector & parameters) return CR_OK; } -DFHACK_PLUGIN("strangemood"); - DFhackCExport command_result plugin_init (color_ostream &out, std::vector &commands) { commands.push_back(PluginCommand("strangemood", "Force a strange mood to happen.\n", df_strangemood, false, diff --git a/plugins/tiletypes.cpp b/plugins/tiletypes.cpp index b624b944f..1a249825c 100644 --- a/plugins/tiletypes.cpp +++ b/plugins/tiletypes.cpp @@ -44,7 +44,8 @@ using namespace MapExtras; using namespace DFHack; using namespace df::enums; -using df::global::world; +DFHACK_PLUGIN("tiletypes"); +REQUIRE_GLOBAL(world); CommandHistory tiletypes_hist; @@ -53,8 +54,6 @@ command_result df_tiletypes_command (color_ostream &out, vector & param command_result df_tiletypes_here (color_ostream &out, vector & parameters); command_result df_tiletypes_here_point (color_ostream &out, vector & parameters); -DFHACK_PLUGIN("tiletypes"); - DFhackCExport command_result plugin_init ( color_ostream &out, std::vector &commands) { tiletypes_hist.load("tiletypes.history"); diff --git a/plugins/trackstop.cpp b/plugins/trackstop.cpp index c7109191a..a10b0105b 100644 --- a/plugins/trackstop.cpp +++ b/plugins/trackstop.cpp @@ -15,18 +15,18 @@ using namespace DFHack; using namespace std; -using df::global::world; -using df::global::ui; using df::building_rollersst; using df::building_trapst; using df::enums::trap_type::trap_type; using df::enums::screw_pump_direction::screw_pump_direction; DFHACK_PLUGIN("trackstop"); - #define AUTOENABLE false DFHACK_PLUGIN_IS_ENABLED(enabled); +REQUIRE_GLOBAL(gps); +REQUIRE_GLOBAL(ui); +REQUIRE_GLOBAL(world); /* * Interface hooks @@ -270,14 +270,6 @@ IMPLEMENT_VMETHOD_INTERPOSE(roller_hook, render); DFhackCExport command_result plugin_enable(color_ostream& out, bool enable) { // Accept the "enable trackstop" / "disable trackstop" commands. 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) || !INTERPOSE_HOOK(trackstop_hook, render).apply(enable) || !INTERPOSE_HOOK(roller_hook, feed).apply(enable) || diff --git a/plugins/treefarm.cpp b/plugins/treefarm.cpp index 6660b07f8..1578bf373 100644 --- a/plugins/treefarm.cpp +++ b/plugins/treefarm.cpp @@ -21,8 +21,11 @@ using namespace DFHack; -using df::global::world; -using df::global::ui; +DFHACK_PLUGIN("treefarm"); +DFHACK_PLUGIN_IS_ENABLED(enabled); + +REQUIRE_GLOBAL(world); +REQUIRE_GLOBAL(ui); void checkFarms(color_ostream& out, void* ptr); command_result treefarm (color_ostream &out, std::vector & parameters); @@ -30,9 +33,6 @@ command_result treefarm (color_ostream &out, std::vector & paramet EventManager::EventHandler handler(&checkFarms, -1); int32_t frequency = 1200*30; -DFHACK_PLUGIN_IS_ENABLED(enabled); -DFHACK_PLUGIN("treefarm"); - DFhackCExport command_result plugin_init ( color_ostream &out, std::vector &commands) { commands.push_back(PluginCommand( diff --git a/plugins/tubefill.cpp b/plugins/tubefill.cpp index efdc6f1a9..73c615c9b 100644 --- a/plugins/tubefill.cpp +++ b/plugins/tubefill.cpp @@ -17,7 +17,9 @@ using namespace DFHack; using namespace df::enums; -using df::global::world; + +DFHACK_PLUGIN("tubefill"); +REQUIRE_GLOBAL(world); bool isDesignatedHollow(df::coord pos) { @@ -33,8 +35,6 @@ bool isDesignatedHollow(df::coord pos) command_result tubefill(color_ostream &out, std::vector & params); -DFHACK_PLUGIN("tubefill"); - DFhackCExport command_result plugin_init ( color_ostream &out, std::vector &commands) { commands.push_back(PluginCommand("tubefill","Fill in all the adamantine tubes again.",tubefill, false, diff --git a/plugins/tweak/tweak.cpp b/plugins/tweak/tweak.cpp index d49fbe2da..8e53dc0a7 100644 --- a/plugins/tweak/tweak.cpp +++ b/plugins/tweak/tweak.cpp @@ -92,19 +92,20 @@ using std::endl; using namespace DFHack; using namespace df::enums; -using df::global::ui; -using df::global::world; -using df::global::ui_build_selector; -using df::global::ui_menu_width; -using df::global::ui_area_map_width; +DFHACK_PLUGIN("tweak"); + +REQUIRE_GLOBAL(ui); +REQUIRE_GLOBAL(ui_build_selector); +REQUIRE_GLOBAL(ui_building_item_cursor); +REQUIRE_GLOBAL(ui_menu_width); +REQUIRE_GLOBAL(ui_area_map_width); +REQUIRE_GLOBAL(world); using namespace DFHack::Gui; static command_result tweak(color_ostream &out, vector & parameters); static std::multimap tweak_hooks; -DFHACK_PLUGIN("tweak"); - #define TWEAK_HOOK(tweak, cls, func) tweak_hooks.insert(std::pair\ (tweak, INTERPOSE_HOOK(cls, func))) diff --git a/plugins/weather.cpp b/plugins/weather.cpp index e94f56dab..481c1a779 100644 --- a/plugins/weather.cpp +++ b/plugins/weather.cpp @@ -13,15 +13,15 @@ using std::string; using namespace DFHack; using namespace df::enums; -using df::global::current_weather; +DFHACK_PLUGIN("weather"); + +REQUIRE_GLOBAL(current_weather); bool locked = false; unsigned char locked_data[25]; command_result weather (color_ostream &out, vector & parameters); -DFHACK_PLUGIN("weather"); - DFhackCExport command_result plugin_init ( color_ostream &out, std::vector &commands) { commands.push_back(PluginCommand( diff --git a/plugins/workNow.cpp b/plugins/workNow.cpp index e8f34939a..b26428f8a 100644 --- a/plugins/workNow.cpp +++ b/plugins/workNow.cpp @@ -14,10 +14,9 @@ using namespace std; using namespace DFHack; -using df::global::process_jobs; -using df::global::process_dig; - DFHACK_PLUGIN("workNow"); +REQUIRE_GLOBAL(process_jobs); +REQUIRE_GLOBAL(process_dig); static int mode = 0; diff --git a/plugins/workflow.cpp b/plugins/workflow.cpp index 16baec260..3ee0097df 100644 --- a/plugins/workflow.cpp +++ b/plugins/workflow.cpp @@ -49,10 +49,12 @@ using std::flush; using namespace DFHack; using namespace df::enums; -using df::global::world; -using df::global::ui; -using df::global::ui_workshop_job_cursor; -using df::global::job_next_id; +DFHACK_PLUGIN("workflow"); + +REQUIRE_GLOBAL(world); +REQUIRE_GLOBAL(ui); +REQUIRE_GLOBAL(ui_workshop_job_cursor); +REQUIRE_GLOBAL(job_next_id); /* Plugin registration */ @@ -61,8 +63,6 @@ static command_result workflow_cmd(color_ostream &out, vector & paramet static void init_state(color_ostream &out); static void cleanup_state(color_ostream &out); -DFHACK_PLUGIN("workflow"); - DFhackCExport command_result plugin_init (color_ostream &out, std::vector &commands) { if (!world || !ui) diff --git a/plugins/zone.cpp b/plugins/zone.cpp index c88e82154..386200d41 100644 --- a/plugins/zone.cpp +++ b/plugins/zone.cpp @@ -74,23 +74,27 @@ using std::vector; using std::string; using namespace DFHack; using namespace df::enums; -using df::global::world; -using df::global::cursor; -using df::global::ui; -using df::global::ui_build_selector; -using df::global::gps; -using df::global::cur_year; -using df::global::cur_year_tick; - -using df::global::ui_building_item_cursor; -using df::global::ui_building_assign_type; -using df::global::ui_building_assign_is_marked; -using df::global::ui_building_assign_units; -using df::global::ui_building_assign_items; -using df::global::ui_building_in_assign; - -using df::global::ui_menu_width; -using df::global::ui_area_map_width; + +DFHACK_PLUGIN("zone"); +DFHACK_PLUGIN_IS_ENABLED(is_enabled); + +REQUIRE_GLOBAL(world); +REQUIRE_GLOBAL(cursor); +REQUIRE_GLOBAL(ui); +REQUIRE_GLOBAL(ui_build_selector); +REQUIRE_GLOBAL(gps); +REQUIRE_GLOBAL(cur_year); +REQUIRE_GLOBAL(cur_year_tick); + +REQUIRE_GLOBAL(ui_building_item_cursor); +REQUIRE_GLOBAL(ui_building_assign_type); +REQUIRE_GLOBAL(ui_building_assign_is_marked); +REQUIRE_GLOBAL(ui_building_assign_units); +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; @@ -98,10 +102,6 @@ command_result df_zone (color_ostream &out, vector & parameters); command_result df_autonestbox (color_ostream &out, vector & parameters); command_result df_autobutcher(color_ostream &out, vector & parameters); -DFHACK_PLUGIN("zone"); - -DFHACK_PLUGIN_IS_ENABLED(is_enabled); - DFhackCExport command_result plugin_enable ( color_ostream &out, bool enable); const string zone_help =