From 22016c4182887888baecf2a439969e52697f5fc5 Mon Sep 17 00:00:00 2001 From: HybridDog Date: Sun, 17 Jan 2016 14:14:44 +0100 Subject: [PATCH] =?UTF-8?q?Parallel=20minetestmapper=20execution=20?= =?UTF-8?q?=E2=86=92=20a=20lot=20faster,=20fix=20geometry=20setting=20and?= =?UTF-8?q?=20abort=20if=20minetestmapper=20isn't=20found=20to=20avoid=20s?= =?UTF-8?q?pamming?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- mapper.sh | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/mapper.sh b/mapper.sh index 9a94721..8489378 100755 --- a/mapper.sh +++ b/mapper.sh @@ -4,10 +4,19 @@ MAPDIR=$1 SPAWNPOS=$2 DIMENSIONS=$3 +echo "map dir set to "$MAPDIR + if [ -z $MAPPERDIR ]; then MAPPERDIR=. fi +MAPPERDIR=$MAPPERDIR/minetestmapper + +if [ ! -e $MAPPERDIR ]; then + echo "error, "$MAPPERDIR" doesn't exist." + exit +fi + scriptdir=`readlink -f $0` scriptdir=`dirname $scriptdir` @@ -31,8 +40,17 @@ do do posx=$(($spawnx+$tilesize*($x-$tilenum/2))) posy=$(($spawny+$tilesize*($tilenum/2-$y))) - $MAPPERDIR/minetestmapper ${MAPPERPARAMS} -i ${MAPDIR} --geometry ${posx},${posy}+${tilesize}+${tilesize} -o ${tiledir}/20/map_${x}_${y}.png - done + $MAPPERDIR ${MAPPERPARAMS} -i ${MAPDIR} --geometry ${posx}:${posy}+${tilesize}+${tilesize} -o ${tiledir}/20/map_${x}_${y}.png & + done & +done + +delay=0 +while [ $(ps -C minetestmapper | wc -l) != 1 ] +do + #minetestmappers are unfinished + sleep 1 + delay=$(($delay+1)) + echo $delay" seconds slept waiting for minetestmapper" done #join the images and make them smaller @@ -59,4 +77,4 @@ done zoommin=$((20-$zoomlevelnum)) #write the resulting config into a json file -echo "{\"mapsize\":$DIMENSIONS, \"spawn\":{\"x\":$spawnx,\"y\":$spawny}, \"zoommin\":$zoommin}" > $scriptdir/www/conf.json \ No newline at end of file +echo "{\"mapsize\":$DIMENSIONS, \"spawn\":{\"x\":$spawnx,\"y\":$spawny}, \"zoommin\":$zoommin}" > $scriptdir/www/conf.json