aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorNovatux <nathanael.courant@laposte.net>2014-01-11 17:54:00 +0100
committerNovatux <nathanael.courant@laposte.net>2014-01-11 17:54:00 +0100
commit84b94eb19804484b689cec441e175628fd10335f (patch)
tree2f94c4bc1d9244160af36df8f6560f3c51c5056e /src
parente21b29f4227581162490cc70aaf4009118544f97 (diff)
downloadminetest-84b94eb19804484b689cec441e175628fd10335f.tar.gz
minetest-84b94eb19804484b689cec441e175628fd10335f.tar.bz2
minetest-84b94eb19804484b689cec441e175628fd10335f.zip
Add forceloading
Diffstat (limited to 'src')
-rw-r--r--src/environment.cpp2
-rw-r--r--src/environment.h3
-rw-r--r--src/script/lua_api/l_env.cpp23
-rw-r--r--src/script/lua_api/l_env.h8
4 files changed, 35 insertions, 1 deletions
diff --git a/src/environment.cpp b/src/environment.cpp
index 7fe5d356a..034db00d5 100644
--- a/src/environment.cpp
+++ b/src/environment.cpp
@@ -258,7 +258,7 @@ void ActiveBlockList::update(std::list<v3s16> &active_positions,
/*
Create the new list
*/
- std::set<v3s16> newlist;
+ std::set<v3s16> newlist = m_forceloaded_list;
for(std::list<v3s16>::iterator i = active_positions.begin();
i != active_positions.end(); ++i)
{
diff --git a/src/environment.h b/src/environment.h
index d9804e781..e439b2ef5 100644
--- a/src/environment.h
+++ b/src/environment.h
@@ -170,6 +170,7 @@ public:
}
std::set<v3s16> m_list;
+ std::set<v3s16> m_forceloaded_list;
private:
};
@@ -305,6 +306,8 @@ public:
// is weather active in this environment?
bool m_use_weather;
+ std::set<v3s16>* getForceloadedBlocks() { return &m_active_blocks.m_forceloaded_list; };
+
private:
/*
diff --git a/src/script/lua_api/l_env.cpp b/src/script/lua_api/l_env.cpp
index d01889401..f75334750 100644
--- a/src/script/lua_api/l_env.cpp
+++ b/src/script/lua_api/l_env.cpp
@@ -798,6 +798,27 @@ int ModApiEnvMod::l_get_humidity(lua_State *L)
return 1;
}
+// minetest.forceload_block(blockpos)
+// blockpos = {x=num, y=num, z=num}
+int ModApiEnvMod::l_forceload_block(lua_State *L)
+{
+ GET_ENV_PTR;
+
+ v3s16 blockpos = read_v3s16(L, 1);
+ env->getForceloadedBlocks()->insert(blockpos);
+ return 0;
+}
+
+// minetest.forceload_free_block(blockpos)
+// blockpos = {x=num, y=num, z=num}
+int ModApiEnvMod::l_forceload_free_block(lua_State *L)
+{
+ GET_ENV_PTR;
+
+ v3s16 blockpos = read_v3s16(L, 1);
+ env->getForceloadedBlocks()->erase(blockpos);
+ return 0;
+}
void ModApiEnvMod::Initialize(lua_State *L, int top)
{
@@ -836,4 +857,6 @@ void ModApiEnvMod::Initialize(lua_State *L, int top)
API_FCT(transforming_liquid_add);
API_FCT(get_heat);
API_FCT(get_humidity);
+ API_FCT(forceload_block);
+ API_FCT(forceload_free_block);
}
diff --git a/src/script/lua_api/l_env.h b/src/script/lua_api/l_env.h
index 126349c6e..7e1cabe3f 100644
--- a/src/script/lua_api/l_env.h
+++ b/src/script/lua_api/l_env.h
@@ -151,6 +151,14 @@ private:
static int l_get_heat(lua_State *L);
static int l_get_humidity(lua_State *L);
+ // minetest.forceload_block(blockpos)
+ // forceloads a block
+ static int l_forceload_block(lua_State *L);
+
+ // minetest.forceload_free_block(blockpos)
+ // stops forceloading a position
+ static int l_forceload_free_block(lua_State *L);
+
public:
static void Initialize(lua_State *L, int top);
};