+set -e
+
+bspdir="$PWD/data"
+url_http=http://beta.xonotic.org/autobuild-bsp/
+url_ssh=xonotic-beta:autobuild-bsp/
+build_cachedir="$HOME/xonotic-map-compiler.cache/"
+screenshot_cachedir="$HOME/xonotic-map-screenshot.cache/"
+build_override="-bsp_timeout 900 -vis_timeout 3600 -light_timeout 14400 -minimap_timeout 900 -scale_timeout 900"
+screenshot_override="9 600 +g_ctf 1"
+
+getthemap_fail=false
+
+allmaps()
+{
+ commithash=$1
+ shift
+ for F in `git show "${commithash}:maps/"`; do
+ case "$F" in
+ *.map.options)
+ ;;
+ *)
+ continue
+ ;;
+ esac
+ M=${F%.map.options}
+ blobhash=`git rev-parse --revs-only "${commithash}:maps/$M.map.options" || true`-`git rev-parse --revs-only "${commithash}:maps/$M.map" || true`
+ case "$blobhash" in
+ -*)
+ ;;
+ *-)
+ ;;
+ *)
+ "$@" "$M" "$blobhash" "$commithash"
+ ;;
+ esac
+ done
+}
+
+pre2spam()
+{
+ map=$1
+ url=$2
+ branch=$3
+ hash=$4
+
+ branch=${branch##refs/heads/}
+ branch=${branch##refs/remotes/}
+ branch=${branch##origin/}
+ hash=`echo "$hash" | cut -c 1-7`
+
+ echo "[$branch $hash] starting map compile of $map"
+}
+
+ss2spam()
+{
+ map=$1
+ url=$2
+ branch=$3
+ hash=$4
+ status=$5
+
+ branch=${branch##refs/heads/}
+ branch=${branch##refs/remotes/}
+ branch=${branch##origin/}
+ hash=`echo "$hash" | cut -c 1-7`
+
+ s_error=
+
+ if [ "$status" -ne 0 ]; then
+ s_error="exited with status $status"
+ fi
+
+ if [ -n "$s_error" ]; then
+ echo "[$branch $hash] \ 34screenshots of $map could not be made: $s_error"
+ else
+ echo "[$branch $hash] screenshots of $map are available on $url"
+ fi
+}
+
+log2spam()
+{
+ map=$1
+ url=$2
+ branch=$3
+ hash=$4
+ status=$5
+ time=$6
+
+ hash=`echo "$hash" | cut -c 1-7`
+
+ branch=${branch##refs/heads/}
+ branch=${branch##refs/remotes/}
+ branch=${branch##origin/}
+
+ s_samplesize=
+ s_failshaders=
+ s_leaked=
+ s_error=
+
+ if [ "$status" -ne 0 ]; then
+ s_error="exited with status $status"
+ fi
+ while IFS= read -r L; do
+ case "$L" in
+ WARNING:\ surface\ at\ *\ too\ large\ for\ desired\ samplesize*)
+ s=${L##* }
+ if [ -z "$s_samplesize" ] || [ "$s" -gt "$s_samplesize" ]; then
+ s_samplesize=$s
+ fi
+ ;;
+ WARNING:\ Couldn\'t\ find\ image\ for\ shader\ textures/NULL)
+ # radiant stupid
+ ;;
+ WARNING:\ Couldn\'t\ find\ image\ for\ shader\ *)
+ s_failshaders="$s_failshaders ${L##* }"
+ ;;
+ '******* leaked *******')
+ s_leaked=1
+ ;;
+ '************ ERROR ************')
+ IFS= read -r s_error
+ ;;
+ esac
+ done
+ s_failshaders=`echo "$s_failshaders" | sed "s, textures/, ,g"`
+ s_failshaders=${s_failshaders# }
+ if [ -n "$s_error" ]; then
+ echo -n "[$branch $hash] \ 34failed"
+ else
+ echo -n "[$branch $hash] finished"
+ fi
+ echo -n " map compile of $map ($url): $time sec"
+ if [ -n "$s_samplesize" ]; then
+ echo -n ", FIX samplesize >= $s_samplesize"
+ fi
+ if [ -n "$s_failshaders" ]; then
+ if [ -n "`echo "$s_failshaders" | cut -d ' ' -f 4-`" ]; then
+ s_failshaders="`echo "$s_failshaders" | cut -d ' ' -f 1-3`..."
+ fi
+ echo -n ", FIX shaders $s_failshaders"
+ fi
+ if [ -n "$s_leaked" ]; then
+ echo -n ", FIX LEAK"
+ fi
+ if [ -n "$s_error" ]; then
+ s_error=`echo "$s_error" | sed "s,$PWD/\?,,g"`
+ echo -n ", ERROR: $s_error"
+ fi
+ echo
+}
+
+buildthemap()
+{
+ REFNAME=$1
+ url=$2
+ M=$3
+ blobhash=$4
+ commithash=$5
+ if HEAD "$url$M-$blobhash.pk3"; then
+ continue
+ fi
+