Initial commit
commit
ee475fdfc9
|
@ -0,0 +1,27 @@
|
||||||
|
#!/bin/bash
|
||||||
|
dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||||
|
if [ $# -ne 2 ]; then
|
||||||
|
echo "Usage: $0 <minetest git directory> <world directory>"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
gamedir=$1
|
||||||
|
worlddir=$2
|
||||||
|
|
||||||
|
#echo "-- Making world in $worlddir using $gamedir"
|
||||||
|
echo "-- Making world `basename $worlddir`"
|
||||||
|
|
||||||
|
pushd "$gamedir" &>/dev/null
|
||||||
|
# Configuration file is the common runtime configuration method
|
||||||
|
echo -e "map-dir = $worlddir\nenable_mapgen_debug_info = true\n" > worldtest_config
|
||||||
|
mkdir -p "$worlddir"
|
||||||
|
echo -e 'gameid = minimal' > "$worlddir/world.mt"
|
||||||
|
"$gamedir/bin/minetestserver" --config worldtest_config
|
||||||
|
popd &>/dev/null
|
||||||
|
resultfile=$gamedir/worldtest_result.txt
|
||||||
|
if [ "`grep -c BAD: "$resultfile"`" != "0" ]; then
|
||||||
|
#echo `grep ERRORS: "$resultfile"`
|
||||||
|
return 1
|
||||||
|
else
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
|
|
@ -0,0 +1,120 @@
|
||||||
|
#!/bin/bash
|
||||||
|
dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||||
|
repo=/home/celeron55/softat/minetest
|
||||||
|
|
||||||
|
workdir=$dir/work
|
||||||
|
rulesdir=$dir/rules.d
|
||||||
|
|
||||||
|
worldsdir=$workdir/worlds
|
||||||
|
clonedir=$workdir/repo
|
||||||
|
builddir=$workdir/builds
|
||||||
|
|
||||||
|
mkdir -p "$workdir"
|
||||||
|
mkdir -p "$worldsdir"
|
||||||
|
mkdir -p "$builddir"
|
||||||
|
|
||||||
|
echo "== Cloning repository from $repo to $clonedir"
|
||||||
|
rm -rf "$clonedir"
|
||||||
|
git clone "$repo" "$clonedir"
|
||||||
|
|
||||||
|
# Returns true if a built minetest already exists in $1
|
||||||
|
check_built_minetest ()
|
||||||
|
{
|
||||||
|
mtdir=$1
|
||||||
|
if [ -a "$mtdir/bin/minetestserver" ]; then
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
|
build_minetest ()
|
||||||
|
{
|
||||||
|
tag=$1
|
||||||
|
ruledir=$2
|
||||||
|
pkg=$3
|
||||||
|
mtdir=$4
|
||||||
|
|
||||||
|
rm -rf "$mtdir"
|
||||||
|
mkdir -p "$mtdir"
|
||||||
|
pushd "$mtdir" &>/dev/null
|
||||||
|
# Extract package
|
||||||
|
tar -xf "$pkg"
|
||||||
|
|
||||||
|
# Patch stuff
|
||||||
|
for patchfile in $ruledir/*.patch; do
|
||||||
|
if ! [ -a "$patchfile" ]; then
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
echo "== Patching $tag with $patchfile"
|
||||||
|
patch -p1 < $patchfile
|
||||||
|
if [ "$?" != "0" ]; then
|
||||||
|
echo "!! Patch failed"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
# Build it
|
||||||
|
cmake . -DRUN_IN_PLACE=1 -DBUILD_CLIENT=0
|
||||||
|
make -j2
|
||||||
|
if [ "$?" == "1" ]; then
|
||||||
|
echo "!! Error building $tag"
|
||||||
|
return 1
|
||||||
|
else
|
||||||
|
echo "-- Built $tag"
|
||||||
|
rm -rf CMakeFiles src/CMakeFiles src/lua/CMakeFiles src/lua/build/CMakeFiles src/jthread/CMakeFiles
|
||||||
|
fi
|
||||||
|
popd &>/dev/null
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
# Build all the versions, if not already built
|
||||||
|
for ruledir in $rulesdir/*; do
|
||||||
|
tag=`cat "$ruledir/tag"`
|
||||||
|
echo "== Checking build: $tag"
|
||||||
|
mtdir=$builddir/minetest-$tag
|
||||||
|
# Make package if doesn't already exist
|
||||||
|
pkg="$builddir/$tag.tar"
|
||||||
|
if [ -a "$pkg" ]; then
|
||||||
|
echo "== Package exists for $tag"
|
||||||
|
else
|
||||||
|
echo "== Creating package for $tag"
|
||||||
|
pushd $clonedir &>/dev/null
|
||||||
|
git archive --format tar $tag > "$pkg"
|
||||||
|
popd &>/dev/null
|
||||||
|
fi
|
||||||
|
# Build if hasn't already been built
|
||||||
|
check_built_minetest "$mtdir"
|
||||||
|
if [ "$?" == "0" ]; then
|
||||||
|
echo "== Already built: $tag"
|
||||||
|
else
|
||||||
|
echo "== Building $tag"
|
||||||
|
build_minetest "$tag" "$ruledir" "$pkg" "$mtdir"
|
||||||
|
if ! [ "$?" == "0" ]; then
|
||||||
|
echo "!! Failed to build $tag"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
# Make a world with each version
|
||||||
|
for ruledir in $rulesdir/*; do
|
||||||
|
tag=`cat "$ruledir/tag"`
|
||||||
|
echo "== Making world with version: $tag"
|
||||||
|
mtdir=$builddir/minetest-$tag
|
||||||
|
worlddir=$worldsdir/world-$tag
|
||||||
|
#echo "== Running minetest-worldtest-makeworld.sh for $tag"
|
||||||
|
|
||||||
|
# Check compatibility with itself
|
||||||
|
rm -rf "$worlddir"
|
||||||
|
$dir/minetest-worldtest-check-and-set.sh "$mtdir" "$worlddir"
|
||||||
|
if [ "$?" == "0" ]; then
|
||||||
|
echo "!! $tag returns valid for non-existent world"
|
||||||
|
fi
|
||||||
|
$dir/minetest-worldtest-check-and-set.sh "$mtdir" "$worlddir"
|
||||||
|
if [ "$?" != "0" ]; then
|
||||||
|
echo "!! $tag returns invalid for self-generated world"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# TODO: Check worlds generated by previous versions
|
||||||
|
done
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
0.4.dev-20120606
|
|
@ -0,0 +1,90 @@
|
||||||
|
diff --git a/src/server.cpp b/src/server.cpp
|
||||||
|
index 893d03b..a8fb1be 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,45 @@ 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 nyancat into (-1,-1,-1)"<<std::endl;
|
||||||
|
+ message_triggered = true;
|
||||||
|
+ }
|
||||||
|
+ if(m_nodedef->get(map->getNodeNoEx(v3s16(-1,-1,-1))).name == "default:nyancat")
|
||||||
|
+ m_shutdown_requested = true;
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+ // </worldtest hack>
|
||||||
|
+
|
||||||
|
{
|
||||||
|
JMutexAutoLock lock(m_env_mutex);
|
||||||
|
// Step environment
|
||||||
|
@@ -1318,6 +1361,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 +4897,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;
|
|
@ -0,0 +1,131 @@
|
||||||
|
diff --git a/builtin/builtin.lua b/builtin/builtin.lua
|
||||||
|
index bd5adf9..aca18c2 100644
|
||||||
|
--- a/builtin/builtin.lua
|
||||||
|
+++ b/builtin/builtin.lua
|
||||||
|
@@ -22,3 +22,126 @@ 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 and quits when nyancat is set at (-1,-1,-1).
|
||||||
|
+
|
||||||
|
+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 world is loaded (by patched server code)
|
||||||
|
+ if
|
||||||
|
+ not minetest.env:get_node_or_nil({x=8, y=8, z=8}) or
|
||||||
|
+ not minetest.env:get_node_or_nil({x=8, y=8, z=-8}) or
|
||||||
|
+ not minetest.env:get_node_or_nil({x=8, y=-8, z=8}) or
|
||||||
|
+ not minetest.env:get_node_or_nil({x=8, y=-8, z=-8}) or
|
||||||
|
+ not minetest.env:get_node_or_nil({x=-8, y=8, z=8}) or
|
||||||
|
+ not minetest.env:get_node_or_nil({x=-8, y=8, z=-8}) or
|
||||||
|
+ not minetest.env:get_node_or_nil({x=-8, y=-8, z=8}) or
|
||||||
|
+ not minetest.env:get_node_or_nil({x=-8, y=-8, z=-8})
|
||||||
|
+ then
|
||||||
|
+ return
|
||||||
|
+ end
|
||||||
|
+
|
||||||
|
+ -- Hackily wait more to actually have all blocks generated
|
||||||
|
+ worldtest.timer = worldtest.timer + dtime
|
||||||
|
+ if worldtest.timer < 4.0 then
|
||||||
|
+ return
|
||||||
|
+ end
|
||||||
|
+
|
||||||
|
+ minetest.log("action", "Worldtest(Lua): world loaded or generated (hopefully)")
|
||||||
|
+
|
||||||
|
+ worldtest.check_and_set()
|
||||||
|
+
|
||||||
|
+ minetest.log("action", "Worldtest(Lua): done")
|
||||||
|
+
|
||||||
|
+ worldtest.done = true
|
||||||
|
+end)
|
||||||
|
+
|
|
@ -0,0 +1 @@
|
||||||
|
0.4.1
|
|
@ -0,0 +1,90 @@
|
||||||
|
diff --git a/src/server.cpp b/src/server.cpp
|
||||||
|
index 893d03b..a8fb1be 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,45 @@ 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 nyancat into (-1,-1,-1)"<<std::endl;
|
||||||
|
+ message_triggered = true;
|
||||||
|
+ }
|
||||||
|
+ if(m_nodedef->get(map->getNodeNoEx(v3s16(-1,-1,-1))).name == "default:nyancat")
|
||||||
|
+ m_shutdown_requested = true;
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+ // </worldtest hack>
|
||||||
|
+
|
||||||
|
{
|
||||||
|
JMutexAutoLock lock(m_env_mutex);
|
||||||
|
// Step environment
|
||||||
|
@@ -1318,6 +1361,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 +4897,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;
|
|
@ -0,0 +1,131 @@
|
||||||
|
diff --git a/builtin/builtin.lua b/builtin/builtin.lua
|
||||||
|
index bd5adf9..aca18c2 100644
|
||||||
|
--- a/builtin/builtin.lua
|
||||||
|
+++ b/builtin/builtin.lua
|
||||||
|
@@ -22,3 +22,126 @@ 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 and quits when nyancat is set at (-1,-1,-1).
|
||||||
|
+
|
||||||
|
+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 world is loaded (by patched server code)
|
||||||
|
+ if
|
||||||
|
+ not minetest.env:get_node_or_nil({x=8, y=8, z=8}) or
|
||||||
|
+ not minetest.env:get_node_or_nil({x=8, y=8, z=-8}) or
|
||||||
|
+ not minetest.env:get_node_or_nil({x=8, y=-8, z=8}) or
|
||||||
|
+ not minetest.env:get_node_or_nil({x=8, y=-8, z=-8}) or
|
||||||
|
+ not minetest.env:get_node_or_nil({x=-8, y=8, z=8}) or
|
||||||
|
+ not minetest.env:get_node_or_nil({x=-8, y=8, z=-8}) or
|
||||||
|
+ not minetest.env:get_node_or_nil({x=-8, y=-8, z=8}) or
|
||||||
|
+ not minetest.env:get_node_or_nil({x=-8, y=-8, z=-8})
|
||||||
|
+ then
|
||||||
|
+ return
|
||||||
|
+ end
|
||||||
|
+
|
||||||
|
+ -- Hackily wait more to actually have all blocks generated
|
||||||
|
+ worldtest.timer = worldtest.timer + dtime
|
||||||
|
+ if worldtest.timer < 4.0 then
|
||||||
|
+ return
|
||||||
|
+ end
|
||||||
|
+
|
||||||
|
+ minetest.log("action", "Worldtest(Lua): world loaded or generated (hopefully)")
|
||||||
|
+
|
||||||
|
+ worldtest.check_and_set()
|
||||||
|
+
|
||||||
|
+ minetest.log("action", "Worldtest(Lua): done")
|
||||||
|
+
|
||||||
|
+ worldtest.done = true
|
||||||
|
+end)
|
||||||
|
+
|
Loading…
Reference in New Issue