Add rules for 0.4.dev-20120122-1 and 0.4.dev-20120408
This commit is contained in:
parent
5a9755c609
commit
17b76556eb
1
rules.d/010-0.4.dev-20120122-1/tag
Normal file
1
rules.d/010-0.4.dev-20120122-1/tag
Normal file
@ -0,0 +1 @@
|
|||||||
|
0.4.dev-20120122-1
|
12
rules.d/010-0.4.dev-20120122-1/unistd.patch
Normal file
12
rules.d/010-0.4.dev-20120122-1/unistd.patch
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
diff --git a/src/filesys.cpp b/src/filesys.cpp
|
||||||
|
index ab950d4..bd82a4c 100644
|
||||||
|
--- a/src/filesys.cpp
|
||||||
|
+++ b/src/filesys.cpp
|
||||||
|
@@ -214,6 +214,7 @@ bool DeleteSingleFileOrEmptyDirectory(std::string path)
|
||||||
|
#include <errno.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <sys/wait.h>
|
||||||
|
+#include <unistd.h>
|
||||||
|
|
||||||
|
std::vector<DirListNode> GetDirListing(std::string pathstring)
|
||||||
|
{
|
92
rules.d/010-0.4.dev-20120122-1/worldtest_generate.patch
Normal file
92
rules.d/010-0.4.dev-20120122-1/worldtest_generate.patch
Normal file
@ -0,0 +1,92 @@
|
|||||||
|
diff --git a/src/server.cpp b/src/server.cpp
|
||||||
|
index 893d03b..06cdaad 100644
|
||||||
|
--- a/src/server.cpp
|
||||||
|
+++ b/src/server.cpp
|
||||||
|
@@ -212,6 +212,10 @@ void * EmergeThread::Thread()
|
||||||
|
*/
|
||||||
|
|
||||||
|
bool only_from_disk = true;
|
||||||
|
+ // <worldtest hack>
|
||||||
|
+ // This doesn't seem to really work in our case
|
||||||
|
+ only_from_disk = false;
|
||||||
|
+ // </worldtest hack>
|
||||||
|
|
||||||
|
{
|
||||||
|
core::map<u16, u8>::Iterator i;
|
||||||
|
@@ -1306,6 +1310,47 @@ void Server::AsyncRunStep()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
+ // <worldtest hack>
|
||||||
|
+ // Quit when blocks near origin have been loaded or generated
|
||||||
|
+ {
|
||||||
|
+ JMutexAutoLock envlock(m_env_mutex);
|
||||||
|
+ // Make sure EmergeThread runs
|
||||||
|
+ m_emergethread.trigger();
|
||||||
|
+ // Check area near origin
|
||||||
|
+ Map *map = &m_env->getMap();
|
||||||
|
+ if(
|
||||||
|
+ map->getBlockNoCreateNoEx(v3s16(0,0,0)) &&
|
||||||
|
+ map->getBlockNoCreateNoEx(v3s16(0,0,0))->isGenerated() &&
|
||||||
|
+ map->getBlockNoCreateNoEx(v3s16(0,0,-1)) &&
|
||||||
|
+ map->getBlockNoCreateNoEx(v3s16(0,0,-1))->isGenerated() &&
|
||||||
|
+ map->getBlockNoCreateNoEx(v3s16(0,-1,0)) &&
|
||||||
|
+ map->getBlockNoCreateNoEx(v3s16(0,-1,0))->isGenerated() &&
|
||||||
|
+ map->getBlockNoCreateNoEx(v3s16(0,-1,-1)) &&
|
||||||
|
+ map->getBlockNoCreateNoEx(v3s16(0,-1,-1))->isGenerated() &&
|
||||||
|
+ map->getBlockNoCreateNoEx(v3s16(-1,0,0)) &&
|
||||||
|
+ map->getBlockNoCreateNoEx(v3s16(-1,0,0))->isGenerated() &&
|
||||||
|
+ map->getBlockNoCreateNoEx(v3s16(-1,0,-1)) &&
|
||||||
|
+ map->getBlockNoCreateNoEx(v3s16(-1,0,-1))->isGenerated() &&
|
||||||
|
+ map->getBlockNoCreateNoEx(v3s16(-1,-1,0)) &&
|
||||||
|
+ map->getBlockNoCreateNoEx(v3s16(-1,-1,0))->isGenerated() &&
|
||||||
|
+ map->getBlockNoCreateNoEx(v3s16(-1,-1,-1)) &&
|
||||||
|
+ map->getBlockNoCreateNoEx(v3s16(-1,-1,-1))->isGenerated()
|
||||||
|
+ ){
|
||||||
|
+ static bool message_triggered = false;
|
||||||
|
+ static float t = 0;
|
||||||
|
+ t += dtime;
|
||||||
|
+ if(!message_triggered){
|
||||||
|
+ dstream<<DTIME<<"Worldtest server: Loaded all blocks."<<std::endl;
|
||||||
|
+ dstream<<DTIME<<"Worldtest server: Will exit after 10 seconds."
|
||||||
|
+ <<std::endl;
|
||||||
|
+ message_triggered = true;
|
||||||
|
+ }
|
||||||
|
+ if(t >= 10)
|
||||||
|
+ m_shutdown_requested = true;
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+ // </worldtest hack>
|
||||||
|
+
|
||||||
|
{
|
||||||
|
JMutexAutoLock lock(m_env_mutex);
|
||||||
|
// Step environment
|
||||||
|
@@ -1318,6 +1363,7 @@ void Server::AsyncRunStep()
|
||||||
|
if(m_map_timer_and_unload_interval.step(dtime, map_timer_and_unload_dtime))
|
||||||
|
{
|
||||||
|
JMutexAutoLock lock(m_env_mutex);
|
||||||
|
+
|
||||||
|
// Run Map's timers and unload unused data
|
||||||
|
ScopeProfiler sp(g_profiler, "Server: map timer and unload");
|
||||||
|
m_env->getMap().timerUpdate(map_timer_and_unload_dtime,
|
||||||
|
@@ -4853,6 +4899,20 @@ void dedicated_server_loop(Server &server, bool &kill)
|
||||||
|
{
|
||||||
|
DSTACK(__FUNCTION_NAME);
|
||||||
|
|
||||||
|
+ // <worldtest hack>
|
||||||
|
+ // Load or generate blocks near origin
|
||||||
|
+ dstream<<DTIME<<"Worldtest hack server started."<<std::endl;
|
||||||
|
+ dstream<<DTIME<<"Will load or generate origin and quit."<<std::endl;
|
||||||
|
+ server.queueBlockEmerge(v3s16(0,0,0), true);
|
||||||
|
+ server.queueBlockEmerge(v3s16(0,0,-1), true);
|
||||||
|
+ server.queueBlockEmerge(v3s16(0,-1,0), true);
|
||||||
|
+ server.queueBlockEmerge(v3s16(0,-1,-1), true);
|
||||||
|
+ server.queueBlockEmerge(v3s16(-1,0,0), true);
|
||||||
|
+ server.queueBlockEmerge(v3s16(-1,0,-1), true);
|
||||||
|
+ server.queueBlockEmerge(v3s16(-1,-1,0), true);
|
||||||
|
+ server.queueBlockEmerge(v3s16(-1,-1,-1), true);
|
||||||
|
+ // </worldtest hack>
|
||||||
|
+
|
||||||
|
infostream<<DTIME<<std::endl;
|
||||||
|
infostream<<"========================"<<std::endl;
|
||||||
|
infostream<<"Running dedicated server"<<std::endl;
|
128
rules.d/010-0.4.dev-20120122-1/worldtest_lua.patch
Normal file
128
rules.d/010-0.4.dev-20120122-1/worldtest_lua.patch
Normal file
@ -0,0 +1,128 @@
|
|||||||
|
diff --git a/data/builtin.lua b/builtin/builtin.lua
|
||||||
|
index bd5adf9..766ea06 100644
|
||||||
|
--- a/data/builtin.lua
|
||||||
|
+++ b/data/builtin.lua
|
||||||
|
@@ -867,3 +867,123 @@
|
||||||
|
math.randomseed(os.time())
|
||||||
|
|
||||||
|
-- END
|
||||||
|
+-- Worldtest implementation
|
||||||
|
+
|
||||||
|
+-- Requires a modified server that will:
|
||||||
|
+-- - Load or generate all the MapBlocks surrounding the origin
|
||||||
|
+-- - Quit after 10 seconds from startup
|
||||||
|
+
|
||||||
|
+local worldtest = {}
|
||||||
|
+worldtest.done = false
|
||||||
|
+worldtest.timer = 0
|
||||||
|
+worldtest.player_joined = false
|
||||||
|
+worldtest.errors = 0
|
||||||
|
+
|
||||||
|
+function worldtest.out(s)
|
||||||
|
+ if worldtest.f then
|
||||||
|
+ worldtest.f:write(s.."\n")
|
||||||
|
+ end
|
||||||
|
+ minetest.log("action", "Worldtest(Lua): "..s)
|
||||||
|
+end
|
||||||
|
+
|
||||||
|
+function check_node_name(p, checkname)
|
||||||
|
+ local readnode = minetest.env:get_node(p)
|
||||||
|
+ local readname = "<nil>"
|
||||||
|
+ if readnode then
|
||||||
|
+ readname = readnode.name
|
||||||
|
+ end
|
||||||
|
+ if readname == checkname then
|
||||||
|
+ worldtest.out("GOOD: "..minetest.pos_to_string(p)..".name = \""..readname.."\"")
|
||||||
|
+ return
|
||||||
|
+ end
|
||||||
|
+ worldtest.errors = worldtest.errors + 1
|
||||||
|
+ worldtest.out("BAD: "..minetest.pos_to_string(p).." should be \""..checkname.."\", is \""..readname.."\"")
|
||||||
|
+end
|
||||||
|
+
|
||||||
|
+function check_node_light(p, checkday, checknight)
|
||||||
|
+ local readday = minetest.env:get_node_light(p, 0.5)
|
||||||
|
+ local readnight = minetest.env:get_node_light(p, 0.0)
|
||||||
|
+ if readday == checkday and readnight == checknight then
|
||||||
|
+ worldtest.out("GOOD: "..minetest.pos_to_string(p).." day="..dump(readday).." night="..dump(readnight))
|
||||||
|
+ return
|
||||||
|
+ end
|
||||||
|
+ worldtest.errors = worldtest.errors + 1
|
||||||
|
+ worldtest.out("BAD: "..minetest.pos_to_string(p).." should have day="..dump(checkday).." night="..dump(checknight)..", has day="..dump(readday).." night="..dump(readnight))
|
||||||
|
+end
|
||||||
|
+
|
||||||
|
+function check_node_meta(p, field, checkvalue)
|
||||||
|
+ local readvalue = minetest.env:get_meta(p):get_string(field)
|
||||||
|
+ readvalue = readvalue or ""
|
||||||
|
+ if readvalue == checkvalue then
|
||||||
|
+ worldtest.out("GOOD: "..minetest.pos_to_string(p)..".meta[\""..field.."\"] = \""..readvalue.."\"")
|
||||||
|
+ return
|
||||||
|
+ end
|
||||||
|
+ worldtest.errors = worldtest.errors + 1
|
||||||
|
+ worldtest.out("BAD: "..minetest.pos_to_string(p)..".meta[\""..field.."\"] should be \""..checkvalue.."\", is \""..readvalue.."\"")
|
||||||
|
+end
|
||||||
|
+
|
||||||
|
+function check_node_meta_text(p, checkvalue)
|
||||||
|
+ local readvalue = minetest.env:get_meta(p):get_text()
|
||||||
|
+ readvalue = readvalue or ""
|
||||||
|
+ if readvalue == checkvalue then
|
||||||
|
+ worldtest.out("GOOD: "..minetest.pos_to_string(p)..".text = \""..readvalue.."\"")
|
||||||
|
+ return
|
||||||
|
+ end
|
||||||
|
+ worldtest.errors = worldtest.errors + 1
|
||||||
|
+ worldtest.out("BAD: "..minetest.pos_to_string(p)..".text should be \""..checkvalue.."\", is \""..readvalue.."\"")
|
||||||
|
+end
|
||||||
|
+
|
||||||
|
+function worldtest.check_and_set()
|
||||||
|
+ -- Open result file
|
||||||
|
+ worldtest.f = io.open("worldtest_result.txt", "w")
|
||||||
|
+ -- Check nodes
|
||||||
|
+ check_node_name({x=-1, y=-1, z=-1}, "default:nyancat")
|
||||||
|
+ check_node_name({x=0, y=3, z=0}, "default:nyancat")
|
||||||
|
+ check_node_name({x=0, y=2, z=0}, "default:torch")
|
||||||
|
+ check_node_name({x=0, y=1, z=0}, "default:glass")
|
||||||
|
+ check_node_name({x=0, y=0, z=0}, "air")
|
||||||
|
+ check_node_light({x=0, y=2, z=0}, 13, 13)
|
||||||
|
+ check_node_light({x=0, y=1, z=0}, 12, 12)
|
||||||
|
+ check_node_light({x=0, y=0, z=0}, 11, 11)
|
||||||
|
+ check_node_name({x=0, y=0, z=2}, "default:sign_wall")
|
||||||
|
+ check_node_meta_text({x=0, y=0, z=2}, "Foo Bar")
|
||||||
|
+ -- Print error count
|
||||||
|
+ worldtest.out("ERRORS: "..dump(worldtest.errors))
|
||||||
|
+ -- Close result file
|
||||||
|
+ worldtest.f:close()
|
||||||
|
+ -- Set nodes
|
||||||
|
+ for x0=-1,1 do
|
||||||
|
+ for y0=-1,3 do
|
||||||
|
+ for z0=-1,1 do
|
||||||
|
+ minetest.env:add_node({x=x0, y=y0, z=z0}, {name="default:nyancat"})
|
||||||
|
+ end
|
||||||
|
+ end
|
||||||
|
+ end
|
||||||
|
+ minetest.env:add_node({x=0, y=2, z=0}, {name="default:torch"})
|
||||||
|
+ minetest.env:add_node({x=0, y=1, z=0}, {name="default:glass"})
|
||||||
|
+ minetest.env:add_node({x=0, y=0, z=0}, {name="air"})
|
||||||
|
+ minetest.env:add_node({x=0, y=0, z=2}, {name="default:sign_wall"})
|
||||||
|
+ minetest.env:get_meta({x=0, y=0, z=2}):set_text("Foo Bar")
|
||||||
|
+end
|
||||||
|
+
|
||||||
|
+minetest.register_globalstep(function(dtime)
|
||||||
|
+ if worldtest.done then
|
||||||
|
+ return
|
||||||
|
+ end
|
||||||
|
+
|
||||||
|
+ -- Wait until patched server has loaded world
|
||||||
|
+ worldtest.timer = worldtest.timer + dtime
|
||||||
|
+ if worldtest.timer < 5 then
|
||||||
|
+ return
|
||||||
|
+ end
|
||||||
|
+
|
||||||
|
+ minetest.log("action", "Worldtest(Lua): world loaded or generated")
|
||||||
|
+
|
||||||
|
+ worldtest.check_and_set()
|
||||||
|
+
|
||||||
|
+ minetest.log("action", "Worldtest(Lua): done")
|
||||||
|
+
|
||||||
|
+ -- Patched server will quit in 10s from startup
|
||||||
|
+ worldtest.done = true
|
||||||
|
+end)
|
||||||
|
+
|
1
rules.d/010-0.4.dev-20120408/tag
Normal file
1
rules.d/010-0.4.dev-20120408/tag
Normal file
@ -0,0 +1 @@
|
|||||||
|
0.4.dev-20120408
|
92
rules.d/010-0.4.dev-20120408/worldtest_generate.patch
Normal file
92
rules.d/010-0.4.dev-20120408/worldtest_generate.patch
Normal file
@ -0,0 +1,92 @@
|
|||||||
|
diff --git a/src/server.cpp b/src/server.cpp
|
||||||
|
index 893d03b..06cdaad 100644
|
||||||
|
--- a/src/server.cpp
|
||||||
|
+++ b/src/server.cpp
|
||||||
|
@@ -212,6 +212,10 @@ void * EmergeThread::Thread()
|
||||||
|
*/
|
||||||
|
|
||||||
|
bool only_from_disk = true;
|
||||||
|
+ // <worldtest hack>
|
||||||
|
+ // This doesn't seem to really work in our case
|
||||||
|
+ only_from_disk = false;
|
||||||
|
+ // </worldtest hack>
|
||||||
|
|
||||||
|
{
|
||||||
|
core::map<u16, u8>::Iterator i;
|
||||||
|
@@ -1306,6 +1310,47 @@ void Server::AsyncRunStep()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
+ // <worldtest hack>
|
||||||
|
+ // Quit when blocks near origin have been loaded or generated
|
||||||
|
+ {
|
||||||
|
+ JMutexAutoLock envlock(m_env_mutex);
|
||||||
|
+ // Make sure EmergeThread runs
|
||||||
|
+ m_emergethread.trigger();
|
||||||
|
+ // Check area near origin
|
||||||
|
+ Map *map = &m_env->getMap();
|
||||||
|
+ if(
|
||||||
|
+ map->getBlockNoCreateNoEx(v3s16(0,0,0)) &&
|
||||||
|
+ map->getBlockNoCreateNoEx(v3s16(0,0,0))->isGenerated() &&
|
||||||
|
+ map->getBlockNoCreateNoEx(v3s16(0,0,-1)) &&
|
||||||
|
+ map->getBlockNoCreateNoEx(v3s16(0,0,-1))->isGenerated() &&
|
||||||
|
+ map->getBlockNoCreateNoEx(v3s16(0,-1,0)) &&
|
||||||
|
+ map->getBlockNoCreateNoEx(v3s16(0,-1,0))->isGenerated() &&
|
||||||
|
+ map->getBlockNoCreateNoEx(v3s16(0,-1,-1)) &&
|
||||||
|
+ map->getBlockNoCreateNoEx(v3s16(0,-1,-1))->isGenerated() &&
|
||||||
|
+ map->getBlockNoCreateNoEx(v3s16(-1,0,0)) &&
|
||||||
|
+ map->getBlockNoCreateNoEx(v3s16(-1,0,0))->isGenerated() &&
|
||||||
|
+ map->getBlockNoCreateNoEx(v3s16(-1,0,-1)) &&
|
||||||
|
+ map->getBlockNoCreateNoEx(v3s16(-1,0,-1))->isGenerated() &&
|
||||||
|
+ map->getBlockNoCreateNoEx(v3s16(-1,-1,0)) &&
|
||||||
|
+ map->getBlockNoCreateNoEx(v3s16(-1,-1,0))->isGenerated() &&
|
||||||
|
+ map->getBlockNoCreateNoEx(v3s16(-1,-1,-1)) &&
|
||||||
|
+ map->getBlockNoCreateNoEx(v3s16(-1,-1,-1))->isGenerated()
|
||||||
|
+ ){
|
||||||
|
+ static bool message_triggered = false;
|
||||||
|
+ if(!message_triggered){
|
||||||
|
+ dstream<<DTIME<<"Worldtest server: Loaded all blocks."<<std::endl;
|
||||||
|
+ dstream<<DTIME<<"Worldtest server: Will exit once the Lua part "
|
||||||
|
+ <<"sets \"worldtest_command\" = \"done\"."<<std::endl;
|
||||||
|
+ message_triggered = true;
|
||||||
|
+ g_settings->set("worldtest_command", "loaded");
|
||||||
|
+ }
|
||||||
|
+ if(g_settings->exists("worldtest_command") &&
|
||||||
|
+ g_settings->get("worldtest_command") == "done")
|
||||||
|
+ m_shutdown_requested = true;
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+ // </worldtest hack>
|
||||||
|
+
|
||||||
|
{
|
||||||
|
JMutexAutoLock lock(m_env_mutex);
|
||||||
|
// Step environment
|
||||||
|
@@ -1318,6 +1363,7 @@ void Server::AsyncRunStep()
|
||||||
|
if(m_map_timer_and_unload_interval.step(dtime, map_timer_and_unload_dtime))
|
||||||
|
{
|
||||||
|
JMutexAutoLock lock(m_env_mutex);
|
||||||
|
+
|
||||||
|
// Run Map's timers and unload unused data
|
||||||
|
ScopeProfiler sp(g_profiler, "Server: map timer and unload");
|
||||||
|
m_env->getMap().timerUpdate(map_timer_and_unload_dtime,
|
||||||
|
@@ -4853,6 +4899,20 @@ void dedicated_server_loop(Server &server, bool &kill)
|
||||||
|
{
|
||||||
|
DSTACK(__FUNCTION_NAME);
|
||||||
|
|
||||||
|
+ // <worldtest hack>
|
||||||
|
+ // Load or generate blocks near origin
|
||||||
|
+ dstream<<DTIME<<"Worldtest hack server started."<<std::endl;
|
||||||
|
+ dstream<<DTIME<<"Will load or generate origin and quit."<<std::endl;
|
||||||
|
+ server.queueBlockEmerge(v3s16(0,0,0), true);
|
||||||
|
+ server.queueBlockEmerge(v3s16(0,0,-1), true);
|
||||||
|
+ server.queueBlockEmerge(v3s16(0,-1,0), true);
|
||||||
|
+ server.queueBlockEmerge(v3s16(0,-1,-1), true);
|
||||||
|
+ server.queueBlockEmerge(v3s16(-1,0,0), true);
|
||||||
|
+ server.queueBlockEmerge(v3s16(-1,0,-1), true);
|
||||||
|
+ server.queueBlockEmerge(v3s16(-1,-1,0), true);
|
||||||
|
+ server.queueBlockEmerge(v3s16(-1,-1,-1), true);
|
||||||
|
+ // </worldtest hack>
|
||||||
|
+
|
||||||
|
verbosestream<<"dedicated_server_loop()"<<std::endl;
|
||||||
|
|
||||||
|
IntervalLimiter m_profiler_interval;
|
129
rules.d/010-0.4.dev-20120408/worldtest_lua.patch
Normal file
129
rules.d/010-0.4.dev-20120408/worldtest_lua.patch
Normal file
@ -0,0 +1,129 @@
|
|||||||
|
diff --git a/builtin/builtin.lua b/builtin/builtin.lua
|
||||||
|
index bd5adf9..766ea06 100644
|
||||||
|
--- a/builtin/builtin.lua
|
||||||
|
+++ b/builtin/builtin.lua
|
||||||
|
@@ -22,3 +22,124 @@ dofile(minetest.get_modpath("__builtin").."/auth.lua")
|
||||||
|
dofile(minetest.get_modpath("__builtin").."/chatcommands.lua")
|
||||||
|
dofile(minetest.get_modpath("__builtin").."/static_spawn.lua")
|
||||||
|
|
||||||
|
+-- Worldtest implementation
|
||||||
|
+
|
||||||
|
+-- Requires a modified server that will:
|
||||||
|
+-- - Load or generate all the MapBlocks surrounding the origin
|
||||||
|
+-- - When loaded, sets setting worldtest_command = "laoded"
|
||||||
|
+-- - Quits when setting worldtest_command == "done"
|
||||||
|
+
|
||||||
|
+local worldtest = {}
|
||||||
|
+worldtest.done = false
|
||||||
|
+worldtest.timer = 0
|
||||||
|
+worldtest.player_joined = false
|
||||||
|
+worldtest.errors = 0
|
||||||
|
+
|
||||||
|
+function worldtest.out(s)
|
||||||
|
+ if worldtest.f then
|
||||||
|
+ worldtest.f:write(s.."\n")
|
||||||
|
+ end
|
||||||
|
+ minetest.log("action", "Worldtest(Lua): "..s)
|
||||||
|
+end
|
||||||
|
+
|
||||||
|
+function check_node_name(p, checkname)
|
||||||
|
+ local readnode = minetest.env:get_node(p)
|
||||||
|
+ local readname = "<nil>"
|
||||||
|
+ if readnode then
|
||||||
|
+ readname = readnode.name
|
||||||
|
+ end
|
||||||
|
+ if readname == checkname then
|
||||||
|
+ worldtest.out("GOOD: "..minetest.pos_to_string(p)..".name = \""..readname.."\"")
|
||||||
|
+ return
|
||||||
|
+ end
|
||||||
|
+ worldtest.errors = worldtest.errors + 1
|
||||||
|
+ worldtest.out("BAD: "..minetest.pos_to_string(p).." should be \""..checkname.."\", is \""..readname.."\"")
|
||||||
|
+end
|
||||||
|
+
|
||||||
|
+function check_node_light(p, checkday, checknight)
|
||||||
|
+ local readday = minetest.env:get_node_light(p, 0.5)
|
||||||
|
+ local readnight = minetest.env:get_node_light(p, 0.0)
|
||||||
|
+ if readday == checkday and readnight == checknight then
|
||||||
|
+ worldtest.out("GOOD: "..minetest.pos_to_string(p).." day="..dump(readday).." night="..dump(readnight))
|
||||||
|
+ return
|
||||||
|
+ end
|
||||||
|
+ worldtest.errors = worldtest.errors + 1
|
||||||
|
+ worldtest.out("BAD: "..minetest.pos_to_string(p).." should have day="..dump(checkday).." night="..dump(checknight)..", has day="..dump(readday).." night="..dump(readnight))
|
||||||
|
+end
|
||||||
|
+
|
||||||
|
+function check_node_meta(p, field, checkvalue)
|
||||||
|
+ local readvalue = minetest.env:get_meta(p):get_string(field)
|
||||||
|
+ readvalue = readvalue or ""
|
||||||
|
+ if readvalue == checkvalue then
|
||||||
|
+ worldtest.out("GOOD: "..minetest.pos_to_string(p)..".meta[\""..field.."\"] = \""..readvalue.."\"")
|
||||||
|
+ return
|
||||||
|
+ end
|
||||||
|
+ worldtest.errors = worldtest.errors + 1
|
||||||
|
+ worldtest.out("BAD: "..minetest.pos_to_string(p)..".meta[\""..field.."\"] should be \""..checkvalue.."\", is \""..readvalue.."\"")
|
||||||
|
+end
|
||||||
|
+
|
||||||
|
+function check_node_meta_text(p, checkvalue)
|
||||||
|
+ local readvalue = minetest.env:get_meta(p):get_text()
|
||||||
|
+ readvalue = readvalue or ""
|
||||||
|
+ if readvalue == checkvalue then
|
||||||
|
+ worldtest.out("GOOD: "..minetest.pos_to_string(p)..".text = \""..readvalue.."\"")
|
||||||
|
+ return
|
||||||
|
+ end
|
||||||
|
+ worldtest.errors = worldtest.errors + 1
|
||||||
|
+ worldtest.out("BAD: "..minetest.pos_to_string(p)..".text should be \""..checkvalue.."\", is \""..readvalue.."\"")
|
||||||
|
+end
|
||||||
|
+
|
||||||
|
+function worldtest.check_and_set()
|
||||||
|
+ -- Open result file
|
||||||
|
+ worldtest.f = io.open("worldtest_result.txt", "w")
|
||||||
|
+ -- Check nodes
|
||||||
|
+ check_node_name({x=-1, y=-1, z=-1}, "default:nyancat")
|
||||||
|
+ check_node_name({x=0, y=3, z=0}, "default:nyancat")
|
||||||
|
+ check_node_name({x=0, y=2, z=0}, "default:torch")
|
||||||
|
+ check_node_name({x=0, y=1, z=0}, "default:glass")
|
||||||
|
+ check_node_name({x=0, y=0, z=0}, "air")
|
||||||
|
+ check_node_light({x=0, y=2, z=0}, 13, 13)
|
||||||
|
+ check_node_light({x=0, y=1, z=0}, 12, 12)
|
||||||
|
+ check_node_light({x=0, y=0, z=0}, 11, 11)
|
||||||
|
+ check_node_name({x=0, y=0, z=2}, "default:sign_wall")
|
||||||
|
+ check_node_meta_text({x=0, y=0, z=2}, "Foo Bar")
|
||||||
|
+ -- Print error count
|
||||||
|
+ worldtest.out("ERRORS: "..dump(worldtest.errors))
|
||||||
|
+ -- Close result file
|
||||||
|
+ worldtest.f:close()
|
||||||
|
+ -- Set nodes
|
||||||
|
+ for x0=-1,1 do
|
||||||
|
+ for y0=-1,3 do
|
||||||
|
+ for z0=-1,1 do
|
||||||
|
+ minetest.env:set_node({x=x0, y=y0, z=z0}, {name="default:nyancat"})
|
||||||
|
+ end
|
||||||
|
+ end
|
||||||
|
+ end
|
||||||
|
+ minetest.env:set_node({x=0, y=2, z=0}, {name="default:torch"})
|
||||||
|
+ minetest.env:set_node({x=0, y=1, z=0}, {name="default:glass"})
|
||||||
|
+ minetest.env:set_node({x=0, y=0, z=0}, {name="air"})
|
||||||
|
+ minetest.env:set_node({x=0, y=0, z=2}, {name="default:sign_wall"})
|
||||||
|
+ minetest.env:get_meta({x=0, y=0, z=2}):set_text("Foo Bar")
|
||||||
|
+end
|
||||||
|
+
|
||||||
|
+minetest.register_globalstep(function(dtime)
|
||||||
|
+ if worldtest.done then
|
||||||
|
+ return
|
||||||
|
+ end
|
||||||
|
+
|
||||||
|
+ -- Wait until patched server has loaded world
|
||||||
|
+ if minetest.setting_get("worldtest_command") ~= "loaded" then
|
||||||
|
+ return
|
||||||
|
+ end
|
||||||
|
+
|
||||||
|
+ minetest.log("action", "Worldtest(Lua): world loaded or generated")
|
||||||
|
+
|
||||||
|
+ worldtest.check_and_set()
|
||||||
|
+
|
||||||
|
+ minetest.log("action", "Worldtest(Lua): done")
|
||||||
|
+
|
||||||
|
+ -- Command patched server to quit
|
||||||
|
+ minetest.setting_set("worldtest_command", "done")
|
||||||
|
+ worldtest.done = true
|
||||||
|
+end)
|
||||||
|
+
|
Loading…
x
Reference in New Issue
Block a user