Skip to content

Commit cac2245

Browse files
committed
Update some plugins to use REQUIRE_GLOBAL
1 parent e206c24 commit cac2245

31 files changed

Lines changed: 85 additions & 100 deletions

library/include/PluginManager.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ distribution.
2727
#include "Export.h"
2828
#include "Hooks.h"
2929
#include "ColorText.h"
30+
#include "MiscUtils.h"
3031
#include <map>
3132
#include <string>
3233
#include <vector>

plugins/add-spatter.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,13 @@ using std::stack;
4141
using namespace DFHack;
4242
using namespace df::enums;
4343

44-
using df::global::gps;
45-
using df::global::world;
46-
using df::global::ui;
47-
48-
typedef df::reaction_product_item_improvementst improvement_product;
49-
5044
DFHACK_PLUGIN("add-spatter");
5145
DFHACK_PLUGIN_IS_ENABLED(is_enabled);
46+
REQUIRE_GLOBAL(gps);
47+
REQUIRE_GLOBAL(world);
48+
REQUIRE_GLOBAL(ui);
49+
50+
typedef df::reaction_product_item_improvementst improvement_product;
5251

5352
struct ReagentSource {
5453
int idx;

plugins/advtools.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,15 @@
3737
using namespace DFHack;
3838
using namespace df::enums;
3939

40-
using df::global::world;
41-
using df::global::ui_advmode;
42-
4340
using df::nemesis_record;
4441
using df::historical_figure;
4542

4643
using namespace DFHack::Translation;
4744

45+
DFHACK_PLUGIN("advtools");
46+
REQUIRE_GLOBAL(world);
47+
REQUIRE_GLOBAL(ui_advmode);
48+
4849
/*********************
4950
* PLUGIN INTERFACE *
5051
*********************/
@@ -54,8 +55,6 @@ static bool bodyswap_hotkey(df::viewscreen *top);
5455
command_result adv_bodyswap (color_ostream &out, std::vector <std::string> & parameters);
5556
command_result adv_tools (color_ostream &out, std::vector <std::string> & parameters);
5657

57-
DFHACK_PLUGIN("advtools");
58-
5958
DFhackCExport command_result plugin_init (color_ostream &out, std::vector <PluginCommand> &commands)
6059
{
6160
if (!ui_advmode)

plugins/autochop.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,10 @@ using std::set;
3636
using namespace DFHack;
3737
using namespace df::enums;
3838

39-
using df::global::world;
40-
using df::global::ui;
41-
4239
#define PLUGIN_VERSION 0.3
4340
DFHACK_PLUGIN("autochop");
44-
41+
REQUIRE_GLOBAL(world);
42+
REQUIRE_GLOBAL(ui);
4543

4644
static bool autochop_enabled = false;
4745
static int min_logs, max_logs;

plugins/autodump.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,10 @@ using namespace df::enums;
3434
using MapExtras::Block;
3535
using MapExtras::MapCache;
3636

37-
using df::global::world;
3837
using df::building_stockpilest;
3938

4039
DFHACK_PLUGIN("autodump");
40+
REQUIRE_GLOBAL(world);
4141

4242
// Stockpile interface START
4343
static const string PERSISTENCE_KEY = "autodump/stockpiles";

plugins/autolabor.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,10 @@ using std::endl;
4444
using std::vector;
4545
using namespace DFHack;
4646
using namespace df::enums;
47-
using df::global::ui;
48-
using df::global::world;
47+
48+
DFHACK_PLUGIN("autolabor");
49+
REQUIRE_GLOBAL(ui);
50+
REQUIRE_GLOBAL(world);
4951

5052
#define ARRAY_COUNT(array) (sizeof(array)/sizeof((array)[0]))
5153

@@ -91,10 +93,6 @@ enum ConfigFlags {
9193
// mostly to allow having the mandatory stuff on top of the file and commands on the bottom
9294
command_result autolabor (color_ostream &out, std::vector <std::string> & parameters);
9395

94-
// A plugin must be able to return its name and version.
95-
// The name string provided must correspond to the filename - autolabor.plug.so or autolabor.plug.dll in this case
96-
DFHACK_PLUGIN("autolabor");
97-
9896
static void generate_labor_to_skill_map();
9997

10098
enum labor_mode {

plugins/automaterial.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,11 @@ using std::vector;
4343

4444
using namespace DFHack;
4545
using namespace df::enums;
46-
using df::global::gps;
47-
using df::global::ui;
48-
using df::global::ui_build_selector;
4946

5047
DFHACK_PLUGIN("automaterial");
48+
REQUIRE_GLOBAL(gps);
49+
REQUIRE_GLOBAL(ui);
50+
REQUIRE_GLOBAL(ui_build_selector);
5151

5252
struct MaterialDescriptor
5353
{

plugins/automelt.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@
1414
#include "modules/World.h"
1515
#include "df/item_quality.h"
1616

17-
using df::global::world;
18-
using df::global::cursor;
19-
using df::global::ui;
2017
using df::building_stockpilest;
2118

2219
DFHACK_PLUGIN("automelt");
2320
#define PLUGIN_VERSION 0.3
21+
REQUIRE_GLOBAL(world);
22+
REQUIRE_GLOBAL(cursor);
23+
REQUIRE_GLOBAL(ui);
2424

2525
static const string PERSISTENCE_KEY = "automelt/stockpiles";
2626

plugins/autotrade.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@
1919
#include "df/mandate.h"
2020
#include "modules/Maps.h"
2121

22-
using df::global::world;
23-
using df::global::cursor;
24-
using df::global::ui;
2522
using df::building_stockpilest;
2623

2724
DFHACK_PLUGIN("autotrade");
25+
REQUIRE_GLOBAL(world);
26+
REQUIRE_GLOBAL(cursor);
27+
REQUIRE_GLOBAL(ui);
2828

2929
static const string PERSISTENCE_KEY = "autotrade/stockpiles";
3030

plugins/building-hacks.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,10 @@
2424

2525
using namespace DFHack;
2626
using namespace df::enums;
27-
using df::global::world;
2827

2928
DFHACK_PLUGIN("building-hacks");
29+
REQUIRE_GLOBAL(world);
30+
3031
struct graphic_tile //could do just 31x31 and be done, but it's nicer to have flexible imho.
3132
{
3233
int16_t tile; //originally uint8_t but we need to indicate non-animated tiles

0 commit comments

Comments
 (0)