Skip to content

Commit

Permalink
Update remaining plugins to use REQUIRE_GLOBAL
Browse files Browse the repository at this point in the history
  • Loading branch information
lethosor committed Dec 7, 2014
1 parent 5de3e61 commit a615723
Show file tree
Hide file tree
Showing 47 changed files with 236 additions and 261 deletions.
7 changes: 2 additions & 5 deletions plugins/fastdwarf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
5 changes: 2 additions & 3 deletions plugins/feature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 <string> &parameters)
Expand Down Expand Up @@ -92,8 +93,6 @@ static command_result feature(color_ostream &out, vector <string> &parameters)
return CR_OK;
}

DFHACK_PLUGIN("feature");

DFhackCExport command_result plugin_init (color_ostream &out, std::vector <PluginCommand> &commands)
{
commands.push_back(PluginCommand(
Expand Down
5 changes: 2 additions & 3 deletions plugins/fixpositions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<string> &parameters)
{
Expand Down Expand Up @@ -226,8 +227,6 @@ command_result df_fixmerchants (color_ostream &out, vector<string> &parameters)
return CR_OK;
}

DFHACK_PLUGIN("fixpositions");

DFhackCExport command_result plugin_init ( color_ostream &out, std::vector <PluginCommand> &commands)
{
commands.push_back(PluginCommand(
Expand Down
5 changes: 2 additions & 3 deletions plugins/fixveins.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -95,8 +96,6 @@ command_result df_fixveins (color_ostream &out, vector <string> & parameters)
return CR_OK;
}

DFHACK_PLUGIN("fixveins");

DFhackCExport command_result plugin_init ( color_ostream &out, std::vector <PluginCommand> &commands)
{
commands.push_back(PluginCommand("fixveins",
Expand Down
5 changes: 2 additions & 3 deletions plugins/flows.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 <string> & parameters)
{
Expand Down Expand Up @@ -56,8 +57,6 @@ command_result df_flows (color_ostream &out, vector <string> & parameters)
return CR_OK;
}

DFHACK_PLUGIN("flows");

DFhackCExport command_result plugin_init ( color_ostream &out, std::vector <PluginCommand> &commands)
{
commands.push_back(PluginCommand("flows",
Expand Down
7 changes: 3 additions & 4 deletions plugins/follow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,16 @@
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 <std::string> & parameters);

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 <PluginCommand> &commands)
{
commands.push_back(PluginCommand(
Expand Down
6 changes: 3 additions & 3 deletions plugins/forceequip.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 <string> & parameters);

const string forceequip_help =
Expand Down
5 changes: 2 additions & 3 deletions plugins/getplants.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 <string> & parameters)
{
Expand Down Expand Up @@ -148,8 +149,6 @@ command_result df_getplants (color_ostream &out, vector <string> & parameters)
return CR_OK;
}

DFHACK_PLUGIN("getplants");

DFhackCExport command_result plugin_init ( color_ostream &out, vector <PluginCommand> &commands)
{
commands.push_back(PluginCommand(
Expand Down
5 changes: 2 additions & 3 deletions plugins/infiniteSky.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 <std::string> & parameters);

DFHACK_PLUGIN("infiniteSky");

DFhackCExport command_result plugin_init ( color_ostream &out, std::vector <PluginCommand> &commands)
{
commands.push_back(PluginCommand(
Expand Down
5 changes: 2 additions & 3 deletions plugins/initflags.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 <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)
{
if (d_init) {
Expand Down
14 changes: 5 additions & 9 deletions plugins/isoworldremote.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 <PluginCommand> &commands)
{
Expand Down
13 changes: 6 additions & 7 deletions plugins/jobutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 */

Expand All @@ -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_cmd(color_ostream &out, vector <string> & parameters);

DFHACK_PLUGIN("jobutils");

DFhackCExport command_result plugin_init (color_ostream &out, std::vector <PluginCommand> &commands)
{
if (!world || !ui)
Expand Down
2 changes: 1 addition & 1 deletion plugins/lair.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
6 changes: 3 additions & 3 deletions plugins/liquids.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 <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)
{
liquids_hist.load("liquids.history");
Expand Down
14 changes: 6 additions & 8 deletions plugins/manipulator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -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)
Expand Down
9 changes: 4 additions & 5 deletions plugins/misery.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<int, int> processedThoughtCountTable;

Expand All @@ -28,8 +29,6 @@ static vector<std::pair<int,int> > fakeThoughts;
static int count;
const int maxCount = 1000;

DFHACK_PLUGIN("misery");

command_result misery(color_ostream& out, vector<string>& parameters);

DFhackCExport command_result plugin_shutdown(color_ostream& out) {
Expand Down
9 changes: 4 additions & 5 deletions plugins/mousequery.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
8 changes: 4 additions & 4 deletions plugins/petcapRemover.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 <std::string> & parameters);

DFHACK_PLUGIN("petcapRemover");

DFhackCExport command_result plugin_init ( color_ostream &out, std::vector <PluginCommand> &commands)
{
commands.push_back(PluginCommand(
Expand Down
6 changes: 3 additions & 3 deletions plugins/plants.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 4 additions & 5 deletions plugins/power-meter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Loading

0 comments on commit a615723

Please sign in to comment.