Skip to content

Commit ccff679

Browse files
committed
migrate plugins to new API
1 parent 628b25d commit ccff679

22 files changed

Lines changed: 66 additions & 66 deletions

plugins/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ if(BUILD_SUPPORTED)
167167
#dfhack_plugin(title-folder title-folder.cpp)
168168
dfhack_plugin(tubefill tubefill.cpp)
169169
#add_subdirectory(tweak)
170-
dfhack_plugin(workflow workflow.cpp LINK_LIBRARIES lua)
170+
#dfhack_plugin(workflow workflow.cpp LINK_LIBRARIES lua)
171171
dfhack_plugin(work-now work-now.cpp)
172172
dfhack_plugin(xlsxreader xlsxreader.cpp LINK_LIBRARIES lua xlsxio_read_STATIC zip expat)
173173
dfhack_plugin(zone zone.cpp LINK_LIBRARIES lua)

plugins/autobutcher.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -125,11 +125,11 @@ DFhackCExport command_result plugin_shutdown (color_ostream &out) {
125125

126126
DFhackCExport command_result plugin_load_data (color_ostream &out) {
127127
cycle_timestamp = 0;
128-
config = World::GetPersistentData(CONFIG_KEY);
128+
config = World::GetPersistentSiteData(CONFIG_KEY);
129129

130130
if (!config.isValid()) {
131131
DEBUG(status,out).print("no config found in this save; initializing\n");
132-
config = World::AddPersistentData(CONFIG_KEY);
132+
config = World::AddPersistentSiteData(CONFIG_KEY);
133133
set_config_bool(CONFIG_IS_ENABLED, is_enabled);
134134
set_config_bool(CONFIG_AUTOWATCH, true);
135135
set_config_val(CONFIG_DEFAULT_FK, 4);
@@ -325,7 +325,7 @@ struct WatchedRace {
325325
void UpdateConfig(color_ostream &out) {
326326
if(!rconfig.isValid()) {
327327
string keyname = WATCHLIST_CONFIG_KEY_PREFIX + Units::getRaceNameById(raceId);
328-
rconfig = World::GetPersistentData(keyname, NULL);
328+
rconfig = World::GetPersistentSiteData(keyname, true);
329329
}
330330
if(rconfig.isValid()) {
331331
rconfig.ival(0) = raceId;
@@ -449,7 +449,7 @@ static void init_autobutcher(color_ostream &out) {
449449
}
450450

451451
std::vector<PersistentDataItem> watchlist;
452-
World::GetPersistentData(&watchlist, WATCHLIST_CONFIG_KEY_PREFIX, true);
452+
World::GetPersistentSiteData(&watchlist, WATCHLIST_CONFIG_KEY_PREFIX, true);
453453
for (auto & p : watchlist) {
454454
DEBUG(status,out).print("Reading from save: %s\n", p.key().c_str());
455455
WatchedRace *w = new WatchedRace(out, p);

plugins/autochop.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ static PersistentDataItem & ensure_burrow_config(color_ostream &out, int id) {
9191
return watched_burrows[watched_burrows_indices[id]];
9292
string keyname = BURROW_CONFIG_KEY_PREFIX + int_to_string(id);
9393
DEBUG(status,out).print("creating new persistent key for burrow %d\n", id);
94-
watched_burrows.emplace_back(World::GetPersistentData(keyname, NULL));
94+
watched_burrows.emplace_back(World::GetPersistentSiteData(keyname, true));
9595
size_t idx = watched_burrows.size()-1;
9696
watched_burrows_indices.emplace(id, idx);
9797
return watched_burrows[idx];
@@ -161,11 +161,11 @@ DFhackCExport command_result plugin_shutdown (color_ostream &out) {
161161

162162
DFhackCExport command_result plugin_load_data (color_ostream &out) {
163163
cycle_timestamp = 0;
164-
config = World::GetPersistentData(CONFIG_KEY);
164+
config = World::GetPersistentSiteData(CONFIG_KEY);
165165

166166
if (!config.isValid()) {
167167
DEBUG(status,out).print("no config found in this save; initializing\n");
168-
config = World::AddPersistentData(CONFIG_KEY);
168+
config = World::AddPersistentSiteData(CONFIG_KEY);
169169
set_config_bool(config, CONFIG_IS_ENABLED, is_enabled);
170170
set_config_val(config, CONFIG_MAX_LOGS, 200);
171171
set_config_val(config, CONFIG_MIN_LOGS, 160);
@@ -178,7 +178,7 @@ DFhackCExport command_result plugin_load_data (color_ostream &out) {
178178
is_enabled = get_config_bool(config, CONFIG_IS_ENABLED);
179179
DEBUG(status,out).print("loading persisted enabled state: %s\n",
180180
is_enabled ? "true" : "false");
181-
World::GetPersistentData(&watched_burrows, BURROW_CONFIG_KEY_PREFIX, true);
181+
World::GetPersistentSiteData(&watched_burrows, BURROW_CONFIG_KEY_PREFIX, true);
182182
watched_burrows_indices.clear();
183183
const size_t num_watched_burrows = watched_burrows.size();
184184
for (size_t idx = 0; idx < num_watched_burrows; ++idx) {

plugins/autoclothing.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ DFhackCExport command_result plugin_enable(color_ostream& out, bool enable) {
275275
}
276276

277277
if (enable != autoclothing_enabled) {
278-
auto enabled = World::GetPersistentData("autoclothing/enabled");
278+
auto enabled = World::GetPersistentSiteData("autoclothing/enabled");
279279
autoclothing_enabled = enable;
280280
DEBUG(report, out).print("%s from the API; persisting\n",
281281
autoclothing_enabled ? "enabled" : "disabled");
@@ -695,7 +695,7 @@ static void cleanup_state(color_ostream &out)
695695

696696
static void init_state(color_ostream &out)
697697
{
698-
auto enabled = World::GetPersistentData("autoclothing/enabled");
698+
auto enabled = World::GetPersistentSiteData("autoclothing/enabled");
699699
if (enabled.isValid() && enabled.ival(0) == 1)
700700
{
701701
out << "autoclothing enabled" << endl;
@@ -708,7 +708,7 @@ static void init_state(color_ostream &out)
708708

709709
// Parse constraints
710710
vector<PersistentDataItem> items;
711-
World::GetPersistentData(&items, "autoclothing/clothingItems");
711+
World::GetPersistentSiteData(&items, "autoclothing/clothingItems");
712712

713713
for (auto& item : items)
714714
{
@@ -723,21 +723,21 @@ static void init_state(color_ostream &out)
723723

724724
static void save_state(color_ostream &out)
725725
{
726-
auto enabled = World::GetPersistentData("autoclothing/enabled");
726+
auto enabled = World::GetPersistentSiteData("autoclothing/enabled");
727727
if (!enabled.isValid())
728-
enabled = World::AddPersistentData("autoclothing/enabled");
728+
enabled = World::AddPersistentSiteData("autoclothing/enabled");
729729
enabled.ival(0) = autoclothing_enabled;
730730

731731
for (auto& order : clothingOrders)
732732
{
733-
auto orderSave = World::AddPersistentData("autoclothing/clothingItems");
733+
auto orderSave = World::AddPersistentSiteData("autoclothing/clothingItems");
734734
orderSave.val() = order.Serialize();
735735
}
736736

737737

738738
// Parse constraints
739739
vector<PersistentDataItem> items;
740-
World::GetPersistentData(&items, "autoclothing/clothingItems");
740+
World::GetPersistentSiteData(&items, "autoclothing/clothingItems");
741741

742742
for (size_t i = 0; i < items.size(); i++)
743743
{
@@ -752,7 +752,7 @@ static void save_state(color_ostream &out)
752752
}
753753
for (size_t i = items.size(); i < clothingOrders.size(); i++)
754754
{
755-
auto item = World::AddPersistentData("autoclothing/clothingItems");
755+
auto item = World::AddPersistentSiteData("autoclothing/clothingItems");
756756
item.val() = clothingOrders[i].Serialize();
757757
}
758758
}

plugins/autofarm.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -363,25 +363,25 @@ class AutoFarm {
363363
if (!(Core::getInstance().isWorldLoaded()))
364364
return;
365365

366-
cfg_enabled = World::GetPersistentData("autofarm/enabled");
366+
cfg_enabled = World::GetPersistentSiteData("autofarm/enabled");
367367
if (cfg_enabled.isValid())
368368
enabled = cfg_enabled.ival(0) != 0;
369369
else {
370-
cfg_enabled = World::AddPersistentData("autofarm/enabled");
370+
cfg_enabled = World::AddPersistentSiteData("autofarm/enabled");
371371
cfg_enabled.ival(0) = enabled;
372372
}
373373

374-
cfg_default_threshold = World::GetPersistentData("autofarm/default_threshold");
374+
cfg_default_threshold = World::GetPersistentSiteData("autofarm/default_threshold");
375375

376376
if (cfg_default_threshold.isValid())
377377
defaultThreshold = cfg_default_threshold.ival(0);
378378
else {
379-
cfg_default_threshold = World::AddPersistentData("autofarm/default_threshold");
379+
cfg_default_threshold = World::AddPersistentSiteData("autofarm/default_threshold");
380380
cfg_default_threshold.ival(0) = defaultThreshold;
381381
}
382382

383383
std::vector<PersistentDataItem> items;
384-
World::GetPersistentData(&items, "autofarm/threshold/", true);
384+
World::GetPersistentSiteData(&items, "autofarm/threshold/", true);
385385
for (auto& i: items) {
386386
if (i.isValid())
387387
{
@@ -409,15 +409,15 @@ class AutoFarm {
409409
cfg_enabled.ival(0) = enabled;
410410

411411
std::vector<PersistentDataItem> items;
412-
World::GetPersistentData(&items, "autofarm/threshold/", true);
412+
World::GetPersistentSiteData(&items, "autofarm/threshold/", true);
413413
for (auto& i : items)
414414
World::DeletePersistentData(i);
415415

416416
for (const auto& t : thresholds)
417417
{
418418
const std::string& plantID = world->raws.plants.all[t.first]->id;
419419
const std::string keyName = "autofarm/threshold/" + plantID;
420-
PersistentDataItem cfgThreshold = World::AddPersistentData(keyName);
420+
PersistentDataItem cfgThreshold = World::AddPersistentSiteData(keyName);
421421
cfgThreshold.val() = plantID;
422422
cfgThreshold.ival(0) = t.second;
423423
}

plugins/autolabor/autolabor.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ static void reset_labor(df::unit_labor labor)
318318

319319
static void init_state()
320320
{
321-
config = World::GetPersistentData("autolabor/config");
321+
config = World::GetPersistentSiteData("autolabor/config");
322322
if (config.isValid() && config.ival(0) == -1)
323323
config.ival(0) = 0;
324324

@@ -329,7 +329,7 @@ static void init_state()
329329

330330
game->external_flag |= 1; // bypass DF's work detail system
331331

332-
auto cfg_haulpct = World::GetPersistentData("autolabor/haulpct");
332+
auto cfg_haulpct = World::GetPersistentSiteData("autolabor/haulpct");
333333
if (cfg_haulpct.isValid())
334334
{
335335
hauler_pct = cfg_haulpct.ival(0);
@@ -343,7 +343,7 @@ static void init_state()
343343
labor_infos.resize(ARRAY_COUNT(default_labor_infos));
344344

345345
std::vector<PersistentDataItem> items;
346-
World::GetPersistentData(&items, "autolabor/labors/", true);
346+
World::GetPersistentSiteData(&items, "autolabor/labors/", true);
347347

348348
for (auto& p : items)
349349
{
@@ -365,7 +365,7 @@ static void init_state()
365365
std::stringstream name;
366366
name << "autolabor/labors/" << i;
367367

368-
labor_infos[i].config = World::AddPersistentData(name.str());
368+
labor_infos[i].config = World::AddPersistentSiteData(name.str());
369369

370370
labor_infos[i].is_exclusive = default_labor_infos[i].is_exclusive;
371371
labor_infos[i].active_dwarfs = 0;
@@ -406,7 +406,7 @@ static void enable_plugin(color_ostream &out)
406406
{
407407
if (!config.isValid())
408408
{
409-
config = World::AddPersistentData("autolabor/config");
409+
config = World::AddPersistentSiteData("autolabor/config");
410410
config.ival(0) = 0;
411411
}
412412

plugins/autonestbox.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,11 +97,11 @@ DFhackCExport command_result plugin_enable(color_ostream &out, bool enable) {
9797

9898
DFhackCExport command_result plugin_load_data (color_ostream &out) {
9999
cycle_timestamp = 0;
100-
config = World::GetPersistentData(CONFIG_KEY);
100+
config = World::GetPersistentSiteData(CONFIG_KEY);
101101

102102
if (!config.isValid()) {
103103
DEBUG(status,out).print("no config found in this save; initializing\n");
104-
config = World::AddPersistentData(CONFIG_KEY);
104+
config = World::AddPersistentSiteData(CONFIG_KEY);
105105
set_config_bool(CONFIG_IS_ENABLED, is_enabled);
106106
set_config_val(CONFIG_CYCLE_TICKS, 6000);
107107
}

plugins/autoslab.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,12 +111,12 @@ DFhackCExport command_result plugin_shutdown(color_ostream &out)
111111
DFhackCExport command_result plugin_load_data(color_ostream &out)
112112
{
113113
cycle_timestamp = 0;
114-
config = World::GetPersistentData(CONFIG_KEY);
114+
config = World::GetPersistentSiteData(CONFIG_KEY);
115115

116116
if (!config.isValid())
117117
{
118118
DEBUG(status, out).print("no config found in this save; initializing\n");
119-
config = World::AddPersistentData(CONFIG_KEY);
119+
config = World::AddPersistentSiteData(CONFIG_KEY);
120120
set_config_bool(CONFIG_IS_ENABLED, is_enabled);
121121
}
122122

plugins/buildingplan/buildingplan.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -325,11 +325,11 @@ static bool is_suspendmanager_enabled(color_ostream &out) {
325325

326326
DFhackCExport command_result plugin_load_data (color_ostream &out) {
327327
cycle_timestamp = 0;
328-
config = World::GetPersistentData(CONFIG_KEY);
328+
config = World::GetPersistentSiteData(CONFIG_KEY);
329329

330330
if (!config.isValid()) {
331331
DEBUG(status,out).print("no config found in this save; initializing\n");
332-
config = World::AddPersistentData(CONFIG_KEY);
332+
config = World::AddPersistentSiteData(CONFIG_KEY);
333333
}
334334
validate_config(out);
335335

@@ -339,14 +339,14 @@ DFhackCExport command_result plugin_load_data (color_ostream &out) {
339339
load_material_cache();
340340

341341
vector<PersistentDataItem> filter_configs;
342-
World::GetPersistentData(&filter_configs, FILTER_CONFIG_KEY);
342+
World::GetPersistentSiteData(&filter_configs, FILTER_CONFIG_KEY);
343343
for (auto &cfg : filter_configs) {
344344
BuildingTypeKey key = DefaultItemFilters::getKey(cfg);
345345
cur_item_filters.emplace(key, DefaultItemFilters(out, cfg, get_job_items(out, key)));
346346
}
347347

348348
vector<PersistentDataItem> building_configs;
349-
World::GetPersistentData(&building_configs, BLD_CONFIG_KEY);
349+
World::GetPersistentSiteData(&building_configs, BLD_CONFIG_KEY);
350350
const size_t num_building_configs = building_configs.size();
351351
bool unsuspend_on_finalize = !is_suspendmanager_enabled(out);
352352
for (size_t idx = 0; idx < num_building_configs; ++idx) {

plugins/buildingplan/defaultitemfilters.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ DefaultItemFilters::DefaultItemFilters(color_ostream &out, BuildingTypeKey key,
4242
: key(key), choose_items(ItemSelectionChoice::ITEM_SELECTION_CHOICE_FILTER) {
4343
DEBUG(status,out).print("creating persistent data for filter key %d,%d,%d\n",
4444
std::get<0>(key), std::get<1>(key), std::get<2>(key));
45-
filter_config = World::AddPersistentData(FILTER_CONFIG_KEY);
45+
filter_config = World::AddPersistentSiteData(FILTER_CONFIG_KEY);
4646
set_config_val(filter_config, FILTER_CONFIG_TYPE, std::get<0>(key));
4747
set_config_val(filter_config, FILTER_CONFIG_SUBTYPE, std::get<1>(key));
4848
set_config_val(filter_config, FILTER_CONFIG_CUSTOM, std::get<2>(key));

0 commit comments

Comments
 (0)