Browse Source

Add 0.4.3

master
Perttu Ahola 10 years ago
parent
commit
c5722e5e9e
  1. 1
      rules.d/020-0.4.3/tag
  2. 92
      rules.d/020-0.4.3/worldtest_generate.patch
  3. 120
      rules.d/020-0.4.3/worldtest_lua.patch

1
rules.d/020-0.4.3/tag

@ -0,0 +1 @@
0.4.3

92
rules.d/020-0.4.3/worldtest_generate.patch

@ -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;

120
rules.d/020-0.4.3/worldtest_lua.patch

@ -0,0 +1,120 @@
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,115 @@ 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 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({x=0, y=0, z=2}, "text", "Foo Bar")
+ check_node_meta({x=0, y=0, z=2}, "infotext", "\"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_string("text", "Foo Bar");
+ minetest.env:get_meta({x=0, y=0, z=2}):set_string("infotext", "\"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…
Cancel
Save