Dissolve the World module class into a namespace.

It made accessing persistent data way too cumbersome.
develop
Alexander Gavrilov 2012-10-06 13:46:20 +04:00
parent 696cc4a911
commit 459c69046b
17 changed files with 134 additions and 245 deletions

@ -627,8 +627,7 @@ command_result Core::runCommand(color_ostream &con, const std::string &first, ve
} }
else if(first == "fpause") else if(first == "fpause")
{ {
World * w = getWorld(); World::SetPauseState(true);
w->SetPauseState(true);
con.print("The game was forced to pause!\n"); con.print("The game was forced to pause!\n");
} }
else if(first == "cls") else if(first == "cls")
@ -1125,7 +1124,7 @@ void Core::doUpdate(color_ostream &out, bool first_update)
last_world_data_ptr = new_wdata; last_world_data_ptr = new_wdata;
last_local_map_ptr = new_mapdata; last_local_map_ptr = new_mapdata;
getWorld()->ClearPersistentCache(); World::ClearPersistentCache();
// and if the world is going away, we report the map change first // and if the world is going away, we report the map change first
if(had_map) if(had_map)
@ -1143,7 +1142,7 @@ void Core::doUpdate(color_ostream &out, bool first_update)
if (isMapLoaded() != had_map) if (isMapLoaded() != had_map)
{ {
getWorld()->ClearPersistentCache(); World::ClearPersistentCache();
onStateChange(out, new_mapdata ? SC_MAP_LOADED : SC_MAP_UNLOADED); onStateChange(out, new_mapdata ? SC_MAP_LOADED : SC_MAP_UNLOADED);
} }
} }
@ -1681,7 +1680,6 @@ TYPE * Core::get##TYPE() \
return s_mods.p##TYPE;\ return s_mods.p##TYPE;\
} }
MODULE_GETTER(World);
MODULE_GETTER(Materials); MODULE_GETTER(Materials);
MODULE_GETTER(Notes); MODULE_GETTER(Notes);
MODULE_GETTER(Graphic); MODULE_GETTER(Graphic);

@ -258,7 +258,7 @@ static PersistentDataItem persistent_by_struct(lua_State *state, int idx)
int id = lua_tointeger(state, -1); int id = lua_tointeger(state, -1);
lua_pop(state, 1); lua_pop(state, 1);
PersistentDataItem ref = Core::getInstance().getWorld()->GetPersistentData(id); PersistentDataItem ref = World::GetPersistentData(id);
if (ref.isValid()) if (ref.isValid())
{ {
@ -323,7 +323,7 @@ static PersistentDataItem get_persistent(lua_State *state)
{ {
const char *str = luaL_checkstring(state, 1); const char *str = luaL_checkstring(state, 1);
return Core::getInstance().getWorld()->GetPersistentData(str); return World::GetPersistentData(str);
} }
} }
@ -342,7 +342,7 @@ static int dfhack_persistent_delete(lua_State *state)
auto ref = get_persistent(state); auto ref = get_persistent(state);
bool ok = Core::getInstance().getWorld()->DeletePersistentData(ref); bool ok = World::DeletePersistentData(ref);
lua_pushboolean(state, ok); lua_pushboolean(state, ok);
return 1; return 1;
@ -356,7 +356,7 @@ static int dfhack_persistent_get_all(lua_State *state)
bool prefix = (lua_gettop(state)>=2 ? lua_toboolean(state,2) : false); bool prefix = (lua_gettop(state)>=2 ? lua_toboolean(state,2) : false);
std::vector<PersistentDataItem> data; std::vector<PersistentDataItem> data;
Core::getInstance().getWorld()->GetPersistentData(&data, str, prefix); World::GetPersistentData(&data, str, prefix);
if (data.empty()) if (data.empty())
{ {
@ -396,7 +396,7 @@ static int dfhack_persistent_save(lua_State *state)
if (add) if (add)
{ {
ref = Core::getInstance().getWorld()->AddPersistentData(str); ref = World::AddPersistentData(str);
added = true; added = true;
} }
else if (lua_getmetatable(state, 1)) else if (lua_getmetatable(state, 1))
@ -409,13 +409,13 @@ static int dfhack_persistent_save(lua_State *state)
} }
else else
{ {
ref = Core::getInstance().getWorld()->GetPersistentData(str); ref = World::GetPersistentData(str);
} }
// Auto-add if not found // Auto-add if not found
if (!ref.isValid()) if (!ref.isValid())
{ {
ref = Core::getInstance().getWorld()->AddPersistentData(str); ref = World::AddPersistentData(str);
if (!ref.isValid()) if (!ref.isValid())
luaL_error(state, "cannot create persistent entry"); luaL_error(state, "cannot create persistent entry");
added = true; added = true;

@ -54,7 +54,6 @@ namespace DFHack
{ {
class Process; class Process;
class Module; class Module;
class World;
class Materials; class Materials;
class Notes; class Notes;
struct VersionInfo; struct VersionInfo;
@ -120,8 +119,6 @@ namespace DFHack
/// Is everything OK? /// Is everything OK?
bool isValid(void) { return !errorstate; } bool isValid(void) { return !errorstate; }
/// get the world module
World * getWorld();
/// get the materials module /// get the materials module
Materials * getMaterials(); Materials * getMaterials();
/// get the notes module /// get the notes module
@ -205,7 +202,6 @@ namespace DFHack
// Module storage // Module storage
struct struct
{ {
World * pWorld;
Materials * pMaterials; Materials * pMaterials;
Notes * pNotes; Notes * pNotes;
Graphic * pGraphic; Graphic * pGraphic;

@ -55,8 +55,6 @@ namespace DFHack
class DFContextShared; class DFContextShared;
class DFHACK_EXPORT PersistentDataItem { class DFHACK_EXPORT PersistentDataItem {
friend class World;
int id; int id;
std::string key_value; std::string key_value;
@ -65,13 +63,17 @@ namespace DFHack
public: public:
static const int NumInts = 7; static const int NumInts = 7;
bool isValid() { return id != 0; } bool isValid() const { return id != 0; }
int entry_id() { return -id; } int entry_id() const { return -id; }
int raw_id() const { return id; }
const std::string &key() { return key_value; } const std::string &key() const { return key_value; }
std::string &val() { return *str_value; } std::string &val() { return *str_value; }
const std::string &val() const { return *str_value; }
int &ival(int i) { return int_values[i]; } int &ival(int i) { return int_values[i]; }
int ival(int i) const { return int_values[i]; }
PersistentDataItem() : id(0), str_value(0), int_values(0) {} PersistentDataItem() : id(0), str_value(0), int_values(0) {}
PersistentDataItem(int id, const std::string &key, std::string *sv, int *iv) PersistentDataItem(int id, const std::string &key, std::string *sv, int *iv)
@ -83,54 +85,42 @@ namespace DFHack
* \ingroup grp_modules * \ingroup grp_modules
* \ingroup grp_world * \ingroup grp_world
*/ */
class DFHACK_EXPORT World : public Module namespace World
{ {
public:
World();
~World();
bool Start();
bool Finish();
///true if paused, false if not ///true if paused, false if not
bool ReadPauseState(); DFHACK_EXPORT bool ReadPauseState();
///true if paused, false if not ///true if paused, false if not
void SetPauseState(bool paused); DFHACK_EXPORT void SetPauseState(bool paused);
uint32_t ReadCurrentTick(); DFHACK_EXPORT uint32_t ReadCurrentTick();
uint32_t ReadCurrentYear(); DFHACK_EXPORT uint32_t ReadCurrentYear();
uint32_t ReadCurrentMonth(); DFHACK_EXPORT uint32_t ReadCurrentMonth();
uint32_t ReadCurrentDay(); DFHACK_EXPORT uint32_t ReadCurrentDay();
uint8_t ReadCurrentWeather(); DFHACK_EXPORT uint8_t ReadCurrentWeather();
void SetCurrentWeather(uint8_t weather); DFHACK_EXPORT void SetCurrentWeather(uint8_t weather);
bool ReadGameMode(t_gamemodes& rd); DFHACK_EXPORT bool ReadGameMode(t_gamemodes& rd);
bool WriteGameMode(const t_gamemodes & wr); // this is very dangerous DFHACK_EXPORT bool WriteGameMode(const t_gamemodes & wr); // this is very dangerous
std::string ReadWorldFolder(); DFHACK_EXPORT std::string ReadWorldFolder();
// Store data in fake historical figure names. // Store data in fake historical figure names.
// This ensures that the values are stored in save games. // This ensures that the values are stored in save games.
PersistentDataItem AddPersistentData(const std::string &key); DFHACK_EXPORT PersistentDataItem AddPersistentData(const std::string &key);
PersistentDataItem GetPersistentData(const std::string &key); DFHACK_EXPORT PersistentDataItem GetPersistentData(const std::string &key);
PersistentDataItem GetPersistentData(int entry_id); DFHACK_EXPORT PersistentDataItem GetPersistentData(int entry_id);
// Calls GetPersistentData(key); if not found, adds and sets added to true. // Calls GetPersistentData(key); if not found, adds and sets added to true.
// The result can still be not isValid() e.g. if the world is not loaded. // The result can still be not isValid() e.g. if the world is not loaded.
PersistentDataItem GetPersistentData(const std::string &key, bool *added); DFHACK_EXPORT PersistentDataItem GetPersistentData(const std::string &key, bool *added);
// Lists all items with the given key. // Lists all items with the given key.
// If prefix is true, search for keys starting with key+"/". // If prefix is true, search for keys starting with key+"/".
// GetPersistentData(&vec,"",true) returns all items. // GetPersistentData(&vec,"",true) returns all items.
// Items have alphabetic order by key; same key ordering is undefined. // Items have alphabetic order by key; same key ordering is undefined.
void GetPersistentData(std::vector<PersistentDataItem> *vec, DFHACK_EXPORT void GetPersistentData(std::vector<PersistentDataItem> *vec,
const std::string &key, bool prefix = false); const std::string &key, bool prefix = false);
// Deletes the item; returns true if success. // Deletes the item; returns true if success.
bool DeletePersistentData(const PersistentDataItem &item); DFHACK_EXPORT bool DeletePersistentData(const PersistentDataItem &item);
void ClearPersistentCache(); DFHACK_EXPORT void ClearPersistentCache();
}
private:
struct Private;
Private *d;
bool BuildPersistentCache();
};
} }
#endif #endif

@ -48,89 +48,34 @@ using namespace DFHack;
using df::global::world; using df::global::world;
Module* DFHack::createWorld() static int next_persistent_id = 0;
{ static std::multimap<std::string, int> persistent_index;
return new World();
}
struct World::Private
{
Private()
{
Inited = PauseInited = StartedWeather = StartedMode = false;
next_persistent_id = 0;
}
bool Inited;
bool PauseInited;
bool StartedWeather;
bool StartedMode;
int next_persistent_id;
std::multimap<std::string, int> persistent_index;
Process * owner;
};
typedef std::pair<std::string, int> T_persistent_item; typedef std::pair<std::string, int> T_persistent_item;
World::World()
{
Core & c = Core::getInstance();
d = new Private;
d->owner = c.p;
if(df::global::pause_state)
d->PauseInited = true;
if(df::global::current_weather)
d->StartedWeather = true;
if (df::global::gamemode && df::global::gametype)
d->StartedMode = true;
d->Inited = true;
}
World::~World()
{
delete d;
}
bool World::Start()
{
return true;
}
bool World::Finish()
{
return true;
}
bool World::ReadPauseState() bool World::ReadPauseState()
{ {
if(!d->PauseInited) return false; return DF_GLOBAL_VALUE(pause_state, false);
return *df::global::pause_state;
} }
void World::SetPauseState(bool paused) void World::SetPauseState(bool paused)
{ {
if (d->PauseInited) bool dummy;
*df::global::pause_state = paused; DF_GLOBAL_VALUE(pause_state, dummy) = paused;
} }
uint32_t World::ReadCurrentYear() uint32_t World::ReadCurrentYear()
{ {
return *df::global::cur_year; return DF_GLOBAL_VALUE(cur_year, 0);
} }
uint32_t World::ReadCurrentTick() uint32_t World::ReadCurrentTick()
{ {
return *df::global::cur_year_tick; return DF_GLOBAL_VALUE(cur_year_tick, 0);
} }
bool World::ReadGameMode(t_gamemodes& rd) bool World::ReadGameMode(t_gamemodes& rd)
{ {
if(d->Inited && d->StartedMode) if(df::global::gamemode && df::global::gametype)
{ {
rd.g_mode = (DFHack::GameMode)*df::global::gamemode; rd.g_mode = (DFHack::GameMode)*df::global::gamemode;
rd.g_type = (DFHack::GameType)*df::global::gametype; rd.g_type = (DFHack::GameType)*df::global::gametype;
@ -140,7 +85,7 @@ bool World::ReadGameMode(t_gamemodes& rd)
} }
bool World::WriteGameMode(const t_gamemodes & wr) bool World::WriteGameMode(const t_gamemodes & wr)
{ {
if(d->Inited && d->StartedMode) if(df::global::gamemode && df::global::gametype)
{ {
*df::global::gamemode = wr.g_mode; *df::global::gamemode = wr.g_mode;
*df::global::gametype = wr.g_type; *df::global::gametype = wr.g_type;
@ -173,24 +118,24 @@ specified by memory.xml gets me the current month/date.
*/ */
uint32_t World::ReadCurrentMonth() uint32_t World::ReadCurrentMonth()
{ {
return this->ReadCurrentTick() / 1200 / 28; return ReadCurrentTick() / 1200 / 28;
} }
uint32_t World::ReadCurrentDay() uint32_t World::ReadCurrentDay()
{ {
return ((this->ReadCurrentTick() / 1200) % 28) + 1; return ((ReadCurrentTick() / 1200) % 28) + 1;
} }
uint8_t World::ReadCurrentWeather() uint8_t World::ReadCurrentWeather()
{ {
if (d->Inited && d->StartedWeather) if (df::global::current_weather)
return (*df::global::current_weather)[2][2]; return (*df::global::current_weather)[2][2];
return 0; return 0;
} }
void World::SetCurrentWeather(uint8_t weather) void World::SetCurrentWeather(uint8_t weather)
{ {
if (d->Inited && d->StartedWeather) if (df::global::current_weather)
memset(df::global::current_weather, weather, 25); memset(df::global::current_weather, weather, 25);
} }
@ -206,13 +151,13 @@ static PersistentDataItem dataFromHFig(df::historical_figure *hfig)
void World::ClearPersistentCache() void World::ClearPersistentCache()
{ {
d->next_persistent_id = 0; next_persistent_id = 0;
d->persistent_index.clear(); persistent_index.clear();
} }
bool World::BuildPersistentCache() static bool BuildPersistentCache()
{ {
if (d->next_persistent_id) if (next_persistent_id)
return true; return true;
if (!Core::getInstance().isWorldLoaded()) if (!Core::getInstance().isWorldLoaded())
return false; return false;
@ -220,20 +165,20 @@ bool World::BuildPersistentCache()
std::vector<df::historical_figure*> &hfvec = df::historical_figure::get_vector(); std::vector<df::historical_figure*> &hfvec = df::historical_figure::get_vector();
// Determine the next entry id as min(-100, lowest_id-1) // Determine the next entry id as min(-100, lowest_id-1)
d->next_persistent_id = -100; next_persistent_id = -100;
if (hfvec.size() > 0 && hfvec[0]->id <= -100) if (hfvec.size() > 0 && hfvec[0]->id <= -100)
d->next_persistent_id = hfvec[0]->id-1; next_persistent_id = hfvec[0]->id-1;
// Add the entries to the lookup table // Add the entries to the lookup table
d->persistent_index.clear(); persistent_index.clear();
for (size_t i = 0; i < hfvec.size() && hfvec[i]->id <= -100; i++) for (size_t i = 0; i < hfvec.size() && hfvec[i]->id <= -100; i++)
{ {
if (!hfvec[i]->name.has_name || hfvec[i]->name.first_name.empty()) if (!hfvec[i]->name.has_name || hfvec[i]->name.first_name.empty())
continue; continue;
d->persistent_index.insert(T_persistent_item(hfvec[i]->name.first_name, -hfvec[i]->id)); persistent_index.insert(T_persistent_item(hfvec[i]->name.first_name, -hfvec[i]->id));
} }
return true; return true;
@ -247,14 +192,14 @@ PersistentDataItem World::AddPersistentData(const std::string &key)
std::vector<df::historical_figure*> &hfvec = df::historical_figure::get_vector(); std::vector<df::historical_figure*> &hfvec = df::historical_figure::get_vector();
df::historical_figure *hfig = new df::historical_figure(); df::historical_figure *hfig = new df::historical_figure();
hfig->id = d->next_persistent_id--; hfig->id = next_persistent_id--;
hfig->name.has_name = true; hfig->name.has_name = true;
hfig->name.first_name = key; hfig->name.first_name = key;
memset(hfig->name.words, 0xFF, sizeof(hfig->name.words)); memset(hfig->name.words, 0xFF, sizeof(hfig->name.words));
hfvec.insert(hfvec.begin(), hfig); hfvec.insert(hfvec.begin(), hfig);
d->persistent_index.insert(T_persistent_item(key, -hfig->id)); persistent_index.insert(T_persistent_item(key, -hfig->id));
return dataFromHFig(hfig); return dataFromHFig(hfig);
} }
@ -264,8 +209,8 @@ PersistentDataItem World::GetPersistentData(const std::string &key)
if (!BuildPersistentCache()) if (!BuildPersistentCache())
return PersistentDataItem(); return PersistentDataItem();
auto it = d->persistent_index.find(key); auto it = persistent_index.find(key);
if (it != d->persistent_index.end()) if (it != persistent_index.end())
return GetPersistentData(it->second); return GetPersistentData(it->second);
return PersistentDataItem(); return PersistentDataItem();
@ -305,24 +250,24 @@ void World::GetPersistentData(std::vector<PersistentDataItem> *vec, const std::s
if (!BuildPersistentCache()) if (!BuildPersistentCache())
return; return;
auto eqrange = d->persistent_index.equal_range(key); auto eqrange = persistent_index.equal_range(key);
if (prefix) if (prefix)
{ {
if (key.empty()) if (key.empty())
{ {
eqrange.first = d->persistent_index.begin(); eqrange.first = persistent_index.begin();
eqrange.second = d->persistent_index.end(); eqrange.second = persistent_index.end();
} }
else else
{ {
std::string bound = key; std::string bound = key;
if (bound[bound.size()-1] != '/') if (bound[bound.size()-1] != '/')
bound += "/"; bound += "/";
eqrange.first = d->persistent_index.lower_bound(bound); eqrange.first = persistent_index.lower_bound(bound);
bound[bound.size()-1]++; bound[bound.size()-1]++;
eqrange.second = d->persistent_index.lower_bound(bound); eqrange.second = persistent_index.lower_bound(bound);
} }
} }
@ -336,25 +281,26 @@ void World::GetPersistentData(std::vector<PersistentDataItem> *vec, const std::s
bool World::DeletePersistentData(const PersistentDataItem &item) bool World::DeletePersistentData(const PersistentDataItem &item)
{ {
if (item.id > -100) int id = item.raw_id();
if (id > -100)
return false; return false;
if (!BuildPersistentCache()) if (!BuildPersistentCache())
return false; return false;
std::vector<df::historical_figure*> &hfvec = df::historical_figure::get_vector(); std::vector<df::historical_figure*> &hfvec = df::historical_figure::get_vector();
auto eqrange = d->persistent_index.equal_range(item.key_value); auto eqrange = persistent_index.equal_range(item.key());
for (auto it2 = eqrange.first; it2 != eqrange.second; ) for (auto it2 = eqrange.first; it2 != eqrange.second; )
{ {
auto it = it2; ++it2; auto it = it2; ++it2;
if (it->second != -item.id) if (it->second != -id)
continue; continue;
d->persistent_index.erase(it); persistent_index.erase(it);
int idx = binsearch_index(hfvec, item.id); int idx = binsearch_index(hfvec, id);
if (idx >= 0) { if (idx >= 0) {
delete hfvec[idx]; delete hfvec[idx];

@ -547,9 +547,7 @@ static void reset_labor(df::unit_labor labor)
static void init_state() static void init_state()
{ {
auto pworld = Core::getInstance().getWorld(); config = World::GetPersistentData("autolabor/config");
config = pworld->GetPersistentData("autolabor/config");
if (config.isValid() && config.ival(0) == -1) if (config.isValid() && config.ival(0) == -1)
config.ival(0) = 0; config.ival(0) = 0;
@ -558,7 +556,7 @@ static void init_state()
if (!enable_autolabor) if (!enable_autolabor)
return; return;
auto cfg_haulpct = pworld->GetPersistentData("autolabor/haulpct"); auto cfg_haulpct = World::GetPersistentData("autolabor/haulpct");
if (cfg_haulpct.isValid()) if (cfg_haulpct.isValid())
{ {
hauler_pct = cfg_haulpct.ival(0); hauler_pct = cfg_haulpct.ival(0);
@ -572,7 +570,7 @@ static void init_state()
labor_infos.resize(ARRAY_COUNT(default_labor_infos)); labor_infos.resize(ARRAY_COUNT(default_labor_infos));
std::vector<PersistentDataItem> items; std::vector<PersistentDataItem> items;
pworld->GetPersistentData(&items, "autolabor/labors/", true); World::GetPersistentData(&items, "autolabor/labors/", true);
for (auto p = items.begin(); p != items.end(); p++) for (auto p = items.begin(); p != items.end(); p++)
{ {
@ -594,7 +592,7 @@ static void init_state()
std::stringstream name; std::stringstream name;
name << "autolabor/labors/" << i; name << "autolabor/labors/" << i;
labor_infos[i].config = pworld->AddPersistentData(name.str()); labor_infos[i].config = World::AddPersistentData(name.str());
labor_infos[i].is_exclusive = default_labor_infos[i].is_exclusive; labor_infos[i].is_exclusive = default_labor_infos[i].is_exclusive;
labor_infos[i].active_dwarfs = 0; labor_infos[i].active_dwarfs = 0;
@ -633,11 +631,9 @@ static void generate_labor_to_skill_map()
static void enable_plugin(color_ostream &out) static void enable_plugin(color_ostream &out)
{ {
auto pworld = Core::getInstance().getWorld();
if (!config.isValid()) if (!config.isValid())
{ {
config = pworld->AddPersistentData("autolabor/config"); config = World::AddPersistentData("autolabor/config");
config.ival(0) = 0; config.ival(0) = 0;
} }

@ -281,7 +281,7 @@ static void reset_tracking()
static void init_map(color_ostream &out) static void init_map(color_ostream &out)
{ {
auto config = Core::getInstance().getWorld()->GetPersistentData("burrows/config"); auto config = World::GetPersistentData("burrows/config");
if (config.isValid()) if (config.isValid())
{ {
auto_grow = !!(config.ival(0) & 1); auto_grow = !!(config.ival(0) & 1);
@ -307,7 +307,7 @@ static void deinit_map(color_ostream &out)
static PersistentDataItem create_config(color_ostream &out) static PersistentDataItem create_config(color_ostream &out)
{ {
bool created; bool created;
auto rv = Core::getInstance().getWorld()->GetPersistentData("burrows/config", &created); auto rv = World::GetPersistentData("burrows/config", &created);
if (created && rv.isValid()) if (created && rv.isValid())
rv.ival(0) = 0; rv.ival(0) = 0;
if (!rv.isValid()) if (!rv.isValid())

@ -65,8 +65,7 @@ DFhackCExport command_result plugin_onupdate ( color_ostream &out )
{ {
if (!followedUnit) return CR_OK; //Don't do anything if we're not following a unit if (!followedUnit) return CR_OK; //Don't do anything if we're not following a unit
DFHack::World *world = Core::getInstance().getWorld(); if (World::ReadPauseState() && prevX==-1) return CR_OK; //Wait until the game is unpaused after first running "follow" to begin following
if (world->ReadPauseState() && prevX==-1) return CR_OK; //Wait until the game is unpaused after first running "follow" to begin following
df::coord &unitPos = followedUnit->pos; df::coord &unitPos = followedUnit->pos;
@ -120,7 +119,7 @@ DFhackCExport command_result plugin_onupdate ( color_ostream &out )
Gui::setViewCoords(x, y, z); Gui::setViewCoords(x, y, z);
//If, for some reason, the cursor is active and the screen is still moving, move the cursor along with the screen //If, for some reason, the cursor is active and the screen is still moving, move the cursor along with the screen
if (c_x != -30000 && !world->ReadPauseState()) if (c_x != -30000 && !World::ReadPauseState())
Gui::setCursorCoords(c_x - (prevX-x), c_y - (prevY-y), z); Gui::setCursorCoords(c_x - (prevX-x), c_y - (prevY-y), z);
//Save this round's stuff for next time so we can monitor for changes made by the user //Save this round's stuff for next time so we can monitor for changes made by the user

@ -117,13 +117,9 @@ command_result mode (color_ostream &out_, vector <string> & parameters)
return CR_WRONG_USAGE; return CR_WRONG_USAGE;
} }
World *world;
{ {
CoreSuspender suspend; CoreSuspender suspend;
world = Core::getInstance().getWorld(); World::ReadGameMode(gm);
world->Start();
world->ReadGameMode(gm);
} }
printCurrentModes(gm, out); printCurrentModes(gm, out);
@ -202,7 +198,7 @@ command_result mode (color_ostream &out_, vector <string> & parameters)
{ {
CoreSuspender suspend; CoreSuspender suspend;
world->WriteGameMode(gm); World::WriteGameMode(gm);
} }
out << endl; out << endl;

@ -177,8 +177,7 @@ static bool makePowerMeter(df::pressure_plate_info *info, int min_power, int max
if (!enabled) if (!enabled)
{ {
auto pworld = Core::getInstance().getWorld(); auto entry = World::GetPersistentData("power-meter/enabled", NULL);
auto entry = pworld->GetPersistentData("power-meter/enabled", NULL);
if (!entry.isValid()) if (!entry.isValid())
return false; return false;
@ -202,8 +201,7 @@ DFhackCExport command_result plugin_onstatechange(color_ostream &out, state_chan
switch (event) { switch (event) {
case SC_WORLD_LOADED: case SC_WORLD_LOADED:
{ {
auto pworld = Core::getInstance().getWorld(); bool enable = World::GetPersistentData("power-meter/enabled").isValid();
bool enable = pworld->GetPersistentData("power-meter/enabled").isValid();
if (enable) if (enable)
{ {

@ -215,8 +215,7 @@ static void init_buildings(bool enable)
if (enable) if (enable)
{ {
auto pworld = Core::getInstance().getWorld(); auto entry = World::GetPersistentData("rename/building_types");
auto entry = pworld->GetPersistentData("rename/building_types");
if (entry.isValid()) if (entry.isValid())
{ {
@ -245,8 +244,7 @@ static bool renameBuilding(df::building *bld, std::string name)
if (!name.empty() && !is_enabled_building(code)) if (!name.empty() && !is_enabled_building(code))
{ {
auto pworld = Core::getInstance().getWorld(); auto entry = World::GetPersistentData("rename/building_types", NULL);
auto entry = pworld->GetPersistentData("rename/building_types", NULL);
if (!entry.isValid()) if (!entry.isValid())
return false; return false;

@ -87,19 +87,18 @@ DFhackCExport command_result plugin_init ( color_ostream &out, vector <PluginCom
DFhackCExport command_result plugin_onupdate ( color_ostream &out ) DFhackCExport command_result plugin_onupdate ( color_ostream &out )
{ {
World *World = Core::getInstance().getWorld();
t_gamemodes gm; t_gamemodes gm;
World->ReadGameMode(gm); World::ReadGameMode(gm);
if(gm.g_mode == game_mode::DWARF) if(gm.g_mode == game_mode::DWARF)
{ {
// if the map is revealed and we're in fortress mode, force the game to pause. // if the map is revealed and we're in fortress mode, force the game to pause.
if(revealed == REVEALED) if(revealed == REVEALED)
{ {
World->SetPauseState(true); World::SetPauseState(true);
} }
else if(nopause_state) else if(nopause_state)
{ {
World->SetPauseState(false); World::SetPauseState(false);
} }
} }
return CR_OK; return CR_OK;
@ -185,14 +184,13 @@ command_result reveal(color_ostream &out, vector<string> & params)
CoreSuspender suspend; CoreSuspender suspend;
World *World = Core::getInstance().getWorld();
if (!Maps::IsValid()) if (!Maps::IsValid())
{ {
out.printerr("Map is not available!\n"); out.printerr("Map is not available!\n");
return CR_FAILURE; return CR_FAILURE;
} }
t_gamemodes gm; t_gamemodes gm;
World->ReadGameMode(gm); World::ReadGameMode(gm);
if(gm.g_mode == game_mode::ADVENTURE) if(gm.g_mode == game_mode::ADVENTURE)
{ {
revealAdventure(out); revealAdventure(out);
@ -234,7 +232,7 @@ command_result reveal(color_ostream &out, vector<string> & params)
if(pause) if(pause)
{ {
revealed = REVEALED; revealed = REVEALED;
World->SetPauseState(true); World::SetPauseState(true);
} }
else else
revealed = DEMON_REVEALED; revealed = DEMON_REVEALED;
@ -264,14 +262,13 @@ command_result unreveal(color_ostream &out, vector<string> & params)
} }
CoreSuspender suspend; CoreSuspender suspend;
World *World = Core::getInstance().getWorld();
if (!Maps::IsValid()) if (!Maps::IsValid())
{ {
out.printerr("Map is not available!\n"); out.printerr("Map is not available!\n");
return CR_FAILURE; return CR_FAILURE;
} }
t_gamemodes gm; t_gamemodes gm;
World->ReadGameMode(gm); World::ReadGameMode(gm);
if(gm.g_mode != game_mode::DWARF) if(gm.g_mode != game_mode::DWARF)
{ {
con.printerr("Only in fortress mode.\n"); con.printerr("Only in fortress mode.\n");
@ -337,7 +334,6 @@ command_result revflood(color_ostream &out, vector<string> & params)
} }
CoreSuspender suspend; CoreSuspender suspend;
uint32_t x_max,y_max,z_max; uint32_t x_max,y_max,z_max;
World * World = Core::getInstance().getWorld();
if (!Maps::IsValid()) if (!Maps::IsValid())
{ {
out.printerr("Map is not available!\n"); out.printerr("Map is not available!\n");
@ -349,7 +345,7 @@ command_result revflood(color_ostream &out, vector<string> & params)
return CR_FAILURE; return CR_FAILURE;
} }
t_gamemodes gm; t_gamemodes gm;
World->ReadGameMode(gm); World::ReadGameMode(gm);
if(gm.g_type != game_type::DWARF_MAIN && gm.g_mode != game_mode::DWARF ) if(gm.g_type != game_type::DWARF_MAIN && gm.g_mode != game_mode::DWARF )
{ {
out.printerr("Only in proper dwarf mode.\n"); out.printerr("Only in proper dwarf mode.\n");

@ -106,9 +106,8 @@ command_result df_seedwatch(color_ostream &out, vector<string>& parameters)
materialsReverser[world->raws.plants.all[i]->id] = i; materialsReverser[world->raws.plants.all[i]->id] = i;
} }
World *w = Core::getInstance().getWorld();
t_gamemodes gm; t_gamemodes gm;
w->ReadGameMode(gm);// FIXME: check return value World::ReadGameMode(gm);// FIXME: check return value
// if game mode isn't fortress mode // if game mode isn't fortress mode
if(gm.g_mode != game_mode::DWARF || if(gm.g_mode != game_mode::DWARF ||
@ -296,9 +295,8 @@ DFhackCExport command_result plugin_onupdate(color_ostream &out)
return CR_OK; return CR_OK;
counter = 0; counter = 0;
World *w = Core::getInstance().getWorld();
t_gamemodes gm; t_gamemodes gm;
w->ReadGameMode(gm);// FIXME: check return value World::ReadGameMode(gm);// FIXME: check return value
// if game mode isn't fortress mode // if game mode isn't fortress mode
if(gm.g_mode != game_mode::DWARF || if(gm.g_mode != game_mode::DWARF ||
!(gm.g_type == game_type::DWARF_MAIN || gm.g_type == game_type::DWARF_RECLAIM)) !(gm.g_type == game_type::DWARF_MAIN || gm.g_type == game_type::DWARF_RECLAIM))

@ -347,10 +347,9 @@ static void load_engines()
{ {
clear_engines(); clear_engines();
auto pworld = Core::getInstance().getWorld();
std::vector<PersistentDataItem> vec; std::vector<PersistentDataItem> vec;
pworld->GetPersistentData(&vec, "siege-engine/target/", true); World::GetPersistentData(&vec, "siege-engine/target/", true);
for (auto it = vec.begin(); it != vec.end(); ++it) for (auto it = vec.begin(); it != vec.end(); ++it)
{ {
auto engine = find_engine(df::building::find(it->ival(0)), true); auto engine = find_engine(df::building::find(it->ival(0)), true);
@ -359,7 +358,7 @@ static void load_engines()
engine->target.second = df::coord(it->ival(4), it->ival(5), it->ival(6)); engine->target.second = df::coord(it->ival(4), it->ival(5), it->ival(6));
} }
pworld->GetPersistentData(&vec, "siege-engine/ammo/", true); World::GetPersistentData(&vec, "siege-engine/ammo/", true);
for (auto it = vec.begin(); it != vec.end(); ++it) for (auto it = vec.begin(); it != vec.end(); ++it)
{ {
auto engine = find_engine(df::building::find(it->ival(0)), true); auto engine = find_engine(df::building::find(it->ival(0)), true);
@ -368,7 +367,7 @@ static void load_engines()
engine->ammo_item_type = (df::item_type)it->ival(2); engine->ammo_item_type = (df::item_type)it->ival(2);
} }
pworld->GetPersistentData(&vec, "siege-engine/stockpiles/", true); World::GetPersistentData(&vec, "siege-engine/stockpiles/", true);
for (auto it = vec.begin(); it != vec.end(); ++it) for (auto it = vec.begin(); it != vec.end(); ++it)
{ {
auto engine = find_engine(df::building::find(it->ival(0)), true); auto engine = find_engine(df::building::find(it->ival(0)), true);
@ -377,14 +376,14 @@ static void load_engines()
auto pile = df::building::find(it->ival(1)); auto pile = df::building::find(it->ival(1));
if (!pile || pile->getType() != building_type::Stockpile) if (!pile || pile->getType() != building_type::Stockpile)
{ {
pworld->DeletePersistentData(*it); World::DeletePersistentData(*it);
continue;; continue;;
} }
engine->stockpiles.insert(it->ival(1)); engine->stockpiles.insert(it->ival(1));
} }
pworld->GetPersistentData(&vec, "siege-engine/profiles/", true); World::GetPersistentData(&vec, "siege-engine/profiles/", true);
for (auto it = vec.begin(); it != vec.end(); ++it) for (auto it = vec.begin(); it != vec.end(); ++it)
{ {
auto engine = find_engine(df::building::find(it->ival(0)), true); auto engine = find_engine(df::building::find(it->ival(0)), true);
@ -393,7 +392,7 @@ static void load_engines()
engine->profile.max_level = it->ival(2); engine->profile.max_level = it->ival(2);
} }
pworld->GetPersistentData(&vec, "siege-engine/profile-workers/", true); World::GetPersistentData(&vec, "siege-engine/profile-workers/", true);
for (auto it = vec.begin(); it != vec.end(); ++it) for (auto it = vec.begin(); it != vec.end(); ++it)
{ {
auto engine = find_engine(df::building::find(it->ival(0)), true); auto engine = find_engine(df::building::find(it->ival(0)), true);
@ -402,7 +401,7 @@ static void load_engines()
auto unit = df::unit::find(it->ival(1)); auto unit = df::unit::find(it->ival(1));
if (!unit || !Units::isCitizen(unit)) if (!unit || !Units::isCitizen(unit))
{ {
pworld->DeletePersistentData(*it); World::DeletePersistentData(*it);
continue; continue;
} }
engine->profile.permitted_workers.push_back(it->ival(1)); engine->profile.permitted_workers.push_back(it->ival(1));
@ -434,9 +433,8 @@ static void clearTargetArea(df::building_siegeenginest *bld)
if (auto engine = find_engine(bld)) if (auto engine = find_engine(bld))
engine->target = coord_range(); engine->target = coord_range();
auto pworld = Core::getInstance().getWorld();
auto key = stl_sprintf("siege-engine/target/%d", bld->id); auto key = stl_sprintf("siege-engine/target/%d", bld->id);
pworld->DeletePersistentData(pworld->GetPersistentData(key)); World::DeletePersistentData(World::GetPersistentData(key));
} }
static bool setTargetArea(df::building_siegeenginest *bld, df::coord target_min, df::coord target_max) static bool setTargetArea(df::building_siegeenginest *bld, df::coord target_min, df::coord target_max)
@ -447,9 +445,8 @@ static bool setTargetArea(df::building_siegeenginest *bld, df::coord target_min,
if (!enable_plugin()) if (!enable_plugin())
return false; return false;
auto pworld = Core::getInstance().getWorld();
auto key = stl_sprintf("siege-engine/target/%d", bld->id); auto key = stl_sprintf("siege-engine/target/%d", bld->id);
auto entry = pworld->GetPersistentData(key, NULL); auto entry = World::GetPersistentData(key, NULL);
if (!entry.isValid()) if (!entry.isValid())
return false; return false;
@ -491,9 +488,8 @@ static int setAmmoItem(lua_State *L)
if (!is_valid_enum_item(item_type)) if (!is_valid_enum_item(item_type))
luaL_argerror(L, 2, "invalid item type"); luaL_argerror(L, 2, "invalid item type");
auto pworld = Core::getInstance().getWorld();
auto key = stl_sprintf("siege-engine/ammo/%d", engine->id); auto key = stl_sprintf("siege-engine/ammo/%d", engine->id);
auto entry = pworld->GetPersistentData(key, NULL); auto entry = World::GetPersistentData(key, NULL);
if (!entry.isValid()) if (!entry.isValid())
return 0; return 0;
@ -523,9 +519,8 @@ static void forgetStockpileLink(EngineInfo *engine, int pile_id)
{ {
engine->stockpiles.erase(pile_id); engine->stockpiles.erase(pile_id);
auto pworld = Core::getInstance().getWorld();
auto key = stl_sprintf("siege-engine/stockpiles/%d/%d", engine->id, pile_id); auto key = stl_sprintf("siege-engine/stockpiles/%d/%d", engine->id, pile_id);
pworld->DeletePersistentData(pworld->GetPersistentData(key)); World::DeletePersistentData(World::GetPersistentData(key));
} }
static void update_stockpile_links(EngineInfo *engine) static void update_stockpile_links(EngineInfo *engine)
@ -583,9 +578,8 @@ static bool addStockpileLink(df::building_siegeenginest *bld, df::building_stock
if (!enable_plugin()) if (!enable_plugin())
return false; return false;
auto pworld = Core::getInstance().getWorld();
auto key = stl_sprintf("siege-engine/stockpiles/%d/%d", bld->id, pile->id); auto key = stl_sprintf("siege-engine/stockpiles/%d/%d", bld->id, pile->id);
auto entry = pworld->GetPersistentData(key, NULL); auto entry = World::GetPersistentData(key, NULL);
if (!entry.isValid()) if (!entry.isValid())
return false; return false;
@ -620,9 +614,8 @@ static df::workshop_profile *saveWorkshopProfile(df::building_siegeenginest *bld
return NULL; return NULL;
// Save skill limits // Save skill limits
auto pworld = Core::getInstance().getWorld();
auto key = stl_sprintf("siege-engine/profiles/%d", bld->id); auto key = stl_sprintf("siege-engine/profiles/%d", bld->id);
auto entry = pworld->GetPersistentData(key, NULL); auto entry = World::GetPersistentData(key, NULL);
if (!entry.isValid()) if (!entry.isValid())
return NULL; return NULL;
@ -637,18 +630,18 @@ static df::workshop_profile *saveWorkshopProfile(df::building_siegeenginest *bld
auto &workers = engine->profile.permitted_workers; auto &workers = engine->profile.permitted_workers;
key = stl_sprintf("siege-engine/profile-workers/%d", bld->id); key = stl_sprintf("siege-engine/profile-workers/%d", bld->id);
pworld->GetPersistentData(&vec, key, true); World::GetPersistentData(&vec, key, true);
for (auto it = vec.begin(); it != vec.end(); ++it) for (auto it = vec.begin(); it != vec.end(); ++it)
{ {
if (linear_index(workers, it->ival(1)) < 0) if (linear_index(workers, it->ival(1)) < 0)
pworld->DeletePersistentData(*it); World::DeletePersistentData(*it);
} }
for (size_t i = 0; i < workers.size(); i++) for (size_t i = 0; i < workers.size(); i++)
{ {
key = stl_sprintf("siege-engine/profile-workers/%d/%d", bld->id, workers[i]); key = stl_sprintf("siege-engine/profile-workers/%d/%d", bld->id, workers[i]);
entry = pworld->GetPersistentData(key, NULL); entry = World::GetPersistentData(key, NULL);
if (!entry.isValid()) if (!entry.isValid())
continue; continue;
entry.ival(0) = engine->id; entry.ival(0) = engine->id;
@ -1802,8 +1795,7 @@ static bool enable_plugin()
if (is_enabled) if (is_enabled)
return true; return true;
auto pworld = Core::getInstance().getWorld(); auto entry = World::GetPersistentData("siege-engine/enabled", NULL);
auto entry = pworld->GetPersistentData("siege-engine/enabled", NULL);
if (!entry.isValid()) if (!entry.isValid())
return false; return false;
@ -1828,8 +1820,7 @@ DFhackCExport command_result plugin_onstatechange(color_ostream &out, state_chan
case SC_MAP_LOADED: case SC_MAP_LOADED:
if (!gamemode || *gamemode == game_mode::DWARF) if (!gamemode || *gamemode == game_mode::DWARF)
{ {
auto pworld = Core::getInstance().getWorld(); bool enable = World::GetPersistentData("siege-engine/enabled").isValid();
bool enable = pworld->GetPersistentData("siege-engine/enabled").isValid();
if (enable) if (enable)
{ {

@ -84,7 +84,6 @@ command_result weather (color_ostream &con, vector <string> & parameters)
CoreSuspender suspend; CoreSuspender suspend;
DFHack::World * w = Core::getInstance().getWorld();
if(!df::global::current_weather) if(!df::global::current_weather)
{ {
con << "Weather support seems broken :(" << std::endl; con << "Weather support seems broken :(" << std::endl;
@ -123,22 +122,22 @@ command_result weather (color_ostream &con, vector <string> & parameters)
if(rain) if(rain)
{ {
con << "Here comes the rain." << std::endl; con << "Here comes the rain." << std::endl;
w->SetCurrentWeather(weather_type::Rain); World::SetCurrentWeather(weather_type::Rain);
} }
if(snow) if(snow)
{ {
con << "Snow everywhere!" << std::endl; con << "Snow everywhere!" << std::endl;
w->SetCurrentWeather(weather_type::Snow); World::SetCurrentWeather(weather_type::Snow);
} }
if(clear) if(clear)
{ {
con << "Suddenly, sunny weather!" << std::endl; con << "Suddenly, sunny weather!" << std::endl;
w->SetCurrentWeather(weather_type::None); World::SetCurrentWeather(weather_type::None);
} }
if(val_override != -1) if(val_override != -1)
{ {
con << "I have no damn idea what this is... " << val_override << std::endl; con << "I have no damn idea what this is... " << val_override << std::endl;
w->SetCurrentWeather(val_override); World::SetCurrentWeather(val_override);
} }
// FIXME: weather lock needs map ID to work reliably... needs to be implemented. // FIXME: weather lock needs map ID to work reliably... needs to be implemented.
} }

@ -438,9 +438,7 @@ static void start_protect(color_ostream &out)
static void init_state(color_ostream &out) static void init_state(color_ostream &out)
{ {
auto pworld = Core::getInstance().getWorld(); config = World::GetPersistentData("workflow/config");
config = pworld->GetPersistentData("workflow/config");
if (config.isValid() && config.ival(0) == -1) if (config.isValid() && config.ival(0) == -1)
config.ival(0) = 0; config.ival(0) = 0;
@ -448,14 +446,14 @@ static void init_state(color_ostream &out)
// Parse constraints // Parse constraints
std::vector<PersistentDataItem> items; std::vector<PersistentDataItem> items;
pworld->GetPersistentData(&items, "workflow/constraints"); World::GetPersistentData(&items, "workflow/constraints");
for (int i = items.size()-1; i >= 0; i--) { for (int i = items.size()-1; i >= 0; i--) {
if (get_constraint(out, items[i].val(), &items[i])) if (get_constraint(out, items[i].val(), &items[i]))
continue; continue;
out.printerr("Lost constraint %s\n", items[i].val().c_str()); out.printerr("Lost constraint %s\n", items[i].val().c_str());
pworld->DeletePersistentData(items[i]); World::DeletePersistentData(items[i]);
} }
last_tick_frame_count = world->frame_counter; last_tick_frame_count = world->frame_counter;
@ -469,11 +467,9 @@ static void init_state(color_ostream &out)
static void enable_plugin(color_ostream &out) static void enable_plugin(color_ostream &out)
{ {
auto pworld = Core::getInstance().getWorld();
if (!config.isValid()) if (!config.isValid())
{ {
config = pworld->AddPersistentData("workflow/config"); config = World::AddPersistentData("workflow/config");
config.ival(0) = 0; config.ival(0) = 0;
} }
@ -729,7 +725,7 @@ static ItemConstraint *get_constraint(color_ostream &out, const std::string &str
nct->config = *cfg; nct->config = *cfg;
else else
{ {
nct->config = Core::getInstance().getWorld()->AddPersistentData("workflow/constraints"); nct->config = World::AddPersistentData("workflow/constraints");
nct->init(str); nct->init(str);
} }
@ -743,7 +739,7 @@ static void delete_constraint(ItemConstraint *cv)
if (idx >= 0) if (idx >= 0)
vector_erase_at(constraints, idx); vector_erase_at(constraints, idx);
Core::getInstance().getWorld()->DeletePersistentData(cv->config); World::DeletePersistentData(cv->config);
delete cv; delete cv;
} }

@ -2769,10 +2769,7 @@ public:
if(!rconfig.isValid()) if(!rconfig.isValid())
{ {
string keyname = "autobutcher/watchlist/" + getRaceName(raceId); string keyname = "autobutcher/watchlist/" + getRaceName(raceId);
auto pworld = Core::getInstance().getWorld(); rconfig = World::GetPersistentData(keyname, NULL);
rconfig = pworld->GetPersistentData(keyname);
if(!rconfig.isValid())
rconfig = pworld->AddPersistentData(keyname);
} }
if(rconfig.isValid()) if(rconfig.isValid())
{ {
@ -2795,7 +2792,7 @@ public:
{ {
if(!rconfig.isValid()) if(!rconfig.isValid())
return; return;
Core::getInstance().getWorld()->DeletePersistentData(rconfig); World::DeletePersistentData(rconfig);
} }
void SortUnitsByAge() void SortUnitsByAge()
@ -3405,13 +3402,11 @@ command_result autoButcher( color_ostream &out, bool verbose = false )
command_result start_autobutcher(color_ostream &out) command_result start_autobutcher(color_ostream &out)
{ {
auto pworld = Core::getInstance().getWorld();
enable_autobutcher = true; enable_autobutcher = true;
if (!config_autobutcher.isValid()) if (!config_autobutcher.isValid())
{ {
config_autobutcher = pworld->AddPersistentData("autobutcher/config"); config_autobutcher = World::AddPersistentData("autobutcher/config");
if (!config_autobutcher.isValid()) if (!config_autobutcher.isValid())
{ {
@ -3437,9 +3432,8 @@ command_result start_autobutcher(color_ostream &out)
command_result init_autobutcher(color_ostream &out) command_result init_autobutcher(color_ostream &out)
{ {
cleanup_autobutcher(out); cleanup_autobutcher(out);
auto pworld = Core::getInstance().getWorld();
config_autobutcher = pworld->GetPersistentData("autobutcher/config"); config_autobutcher = World::GetPersistentData("autobutcher/config");
if(config_autobutcher.isValid()) if(config_autobutcher.isValid())
{ {
if (config_autobutcher.ival(0) == -1) if (config_autobutcher.ival(0) == -1)
@ -3471,7 +3465,7 @@ command_result init_autobutcher(color_ostream &out)
// read watchlist from save // read watchlist from save
std::vector<PersistentDataItem> items; std::vector<PersistentDataItem> items;
pworld->GetPersistentData(&items, "autobutcher/watchlist/", true); World::GetPersistentData(&items, "autobutcher/watchlist/", true);
for (auto p = items.begin(); p != items.end(); p++) for (auto p = items.begin(); p != items.end(); p++)
{ {
string key = p->key(); string key = p->key();
@ -3502,12 +3496,11 @@ command_result cleanup_autobutcher(color_ostream &out)
command_result start_autonestbox(color_ostream &out) command_result start_autonestbox(color_ostream &out)
{ {
auto pworld = Core::getInstance().getWorld();
enable_autonestbox = true; enable_autonestbox = true;
if (!config_autobutcher.isValid()) if (!config_autobutcher.isValid())
{ {
config_autonestbox = pworld->AddPersistentData("autonestbox/config"); config_autonestbox = World::AddPersistentData("autonestbox/config");
if (!config_autobutcher.isValid()) if (!config_autobutcher.isValid())
{ {
@ -3528,9 +3521,8 @@ command_result start_autonestbox(color_ostream &out)
command_result init_autonestbox(color_ostream &out) command_result init_autonestbox(color_ostream &out)
{ {
cleanup_autonestbox(out); cleanup_autonestbox(out);
auto pworld = Core::getInstance().getWorld();
config_autonestbox = pworld->GetPersistentData("autonestbox/config"); config_autonestbox = World::GetPersistentData("autonestbox/config");
if(config_autonestbox.isValid()) if(config_autonestbox.isValid())
{ {
if (config_autonestbox.ival(0) == -1) if (config_autonestbox.ival(0) == -1)