]> git.xonotic.org Git - xonotic/xonotic.git/commitdiff
Merge remote branch 'origin/fruitiex/sev-skin'
authorRudolf Polzer <divVerent@alientrap.org>
Sat, 8 May 2010 12:51:54 +0000 (14:51 +0200)
committerRudolf Polzer <divVerent@alientrap.org>
Sat, 8 May 2010 12:51:54 +0000 (14:51 +0200)
all
data/common-spog.pk3 [deleted file]
misc/tools/nexuiz-map-compiler [deleted file]
misc/tools/xonotic-map-compiler [new file with mode: 0755]
misc/tools/xonotic-map-compiler-autobuild [new file with mode: 0755]
server/rcon2irc/rcon2irc.pl

diff --git a/all b/all
index 09292ee0d19a0cf22d8e25041925523fa6247814..cf7e101d3472e7fd9cf697583f5b1994d7173508 100755 (executable)
--- a/all
+++ b/all
@@ -108,28 +108,53 @@ enter()
 }
 
 repos_urls="
-       .
-       data/xonotic-data.pk3dir
-       data/xonotic-maps.pk3dir
-       data/xonotic-music.pk3dir
-       data/xonotic-nexcompat.pk3dir
-       darkplaces
-       fteqcc@git://github.com/Blub/qclib.git
-       div0-gittools@git://git.icculus.org/divverent/div0-gittools.git
-       netradiant
+.                             |                                                   | master
+data/xonotic-data.pk3dir      |                                                   | master
+data/xonotic-maps.pk3dir      |                                                   | master
+data/xonotic-music.pk3dir     |                                                   | master
+data/xonotic-nexcompat.pk3dir |                                                   | master
+darkplaces                    |                                                   | div0-stable
+fteqcc                        | git://github.com/Blub/qclib.git                   | master
+div0-gittools                 | git://git.icculus.org/divverent/div0-gittools.git | master
+netradiant                    |                                                   | master
 "
+# todo: in darkplaces, change repobranch to div0-stable
 
-repos_urls=`
-       for X in $repos_urls; do 
-               d="${X%%@*}"
-               p="${d%dir}"
-               if [ x"$p" = x"$d" ] || [ -d "$d" ] || ! [ -f "$p" ]; then
-                       echo "$X"
+repos=`echo "$repos_urls" | grep . | cut -d '|' -f 1 | tr -d ' '`
+
+base=`git config remote.origin.url`
+base=${base%xonotic.git}
+
+repourl()
+{
+       t=`echo "$repos_urls" | grep "^$1 " | cut -d '|' -f 2 | tr -d ' '`
+       if [ -n "$t" ]; then
+               echo "$t"
+       else
+               if [ x"$1" = x"." ]; then
+                       echo "$base""xonotic.git"
+               else
+                       echo "$base${1##*/}.git"
                fi
-       done
-`
+       fi
+}
 
-repos=`for X in $repos_urls; do echo "${X%%@*}"; done`
+repobranch()
+{
+       t=`echo "$repos_urls" | grep "^$1 " | cut -d '|' -f 3 | tr -d ' '`
+       if [ -n "$t" ]; then
+               echo "$t"
+       else
+               echo "master"
+       fi
+}
+
+repos=`for d in $repos; do
+       p="${d%dir}"
+       if [ x"$p" = x"$d" ] || [ -d "$d" ] || ! [ -f "$p" ]; then
+               echo "$d"
+       fi
+done`
 
 if [ "$#" = 0 ]; then
        set -- help
@@ -139,32 +164,12 @@ shift
 
 case "$cmd" in
        update|pull)
-               base=`git config remote.origin.url`
-               base=${base%xonotic.git}
-               for dcomplete in $repos_urls; do
-                       case "$dcomplete" in
-                               *@*)
-                                       d=${dcomplete%%@*}
-                                       url=${dcomplete#*@}
-                                       switch=false
-                                       ;;
-                               *)
-                                       d=${dcomplete%%@*}
-                                       url=$base${d##*/}.git
-                                       switch=true
-                                       ;;
-                       esac
+               for d in $repos; do
+                       url=`repourl "$d"`
+                       branch=`repobranch "$d"`
                        if [ -d "$d0/$d" ]; then
                                enter "$d0/$d" verbose
-                               case "$d" in
-                                       .)
-                                               ;;
-                                       *)
-                                               if $switch; then
-                                                       verbose git config remote.origin.url "$url"
-                                               fi
-                                               ;;
-                               esac
+                               verbose git config remote.origin.url "$url"
                                verbose git config remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*"
                                        # TODO remove this line later
 
@@ -188,6 +193,9 @@ case "$cmd" in
                                cd "$d0"
                        else
                                verbose git clone "$url" "$d0/$d"
+                               enter "$d0/$d" verbose
+                               verbose git checkout "$branch"
+                               cd "$d0"
                        fi
                done
                ;;
@@ -208,7 +216,7 @@ case "$cmd" in
                                exists=true
                                verbose git checkout --track -b "$branch" "$remote/$branch"
                        else
-                               verbose git checkout master
+                               verbose git checkout "`repobranch "$d"`"
                        fi
                        cd "$d00"
                        checkself "$cmd" "$@"
@@ -227,9 +235,6 @@ case "$cmd" in
                        branch=$remote
                        remote=origin
                fi
-               if [ -z "$srcbranch" ]; then
-                       srcbranch=master
-               fi
                if [ -z "$branch" ]; then
                        for d in $repos; do
                                enter "$d0/$d"
@@ -251,7 +256,13 @@ case "$cmd" in
                                                read -r a
                                        done
                                        if [ x"$a" = x"y" ]; then
-                                               verbose git push "$remote" "$srcbranch":"$branch"
+                                               if [ -n "$srcbranch" ]; then
+                                                       b=$srcbranch
+                                               else
+                                                       b="`repobranch "$d"`"
+                                               fi
+                                               # TODO do this without pushing
+                                               verbose git push "$remote" "$b":"$branch"
                                                verbose git checkout --track -b "$branch" "$remote/$branch"
                                        fi
                                fi
@@ -289,21 +300,58 @@ case "$cmd" in
                        done
                done
                ;;
+       branches_short)
+               for d in $repos; do
+                       cd "$d0/$d" # am in a pipe, shouldn't use enter
+                       git branch -a -v -v | cut -c 3- | sed "s,^,$d ,"
+                       cd "$d0"
+               done | {
+                       branches_list=
+                       # branches_repos_*=
+                       while read -r d BRANCH REV UPSTREAM TEXT; do
+                               case "$UPSTREAM" in
+                                       \[*)
+                                               UPSTREAM=${UPSTREAM#\[}
+                                               UPSTREAM=${UPSTREAM%\]}
+                                               UPSTREAM=${UPSTREAM%:*}
+                                               ;;
+                                       *)
+                                               TEXT="$UPSTREAM $TEXT"
+                                               UPSTREAM=
+                                               ;;
+                               esac
+                               if [ x"$REV" = x"->" ]; then
+                                       continue
+                               fi
+                               BRANCH=${BRANCH#remotes/}
+                               ID=`echo "$BRANCH" | tr -c "A-Za-z0-9." "_"`
+                               branches_list="$branches_list $BRANCH" # TEH SORT MAKEZ IT UNIEQ
+                               eval "r=\$branches_repos_$ID"
+                               r="$r $d:$UPSTREAM"
+                               eval "branches_repos_$ID=\$r"
+                       done
+                       echo -n "$branches_list" | xargs -n 1 echo | sort -u | while IFS= read -r BRANCH; do
+                               ID=`echo "$BRANCH" | tr -c "A-Za-z0-9." "_"`
+                               eval "r=\$branches_repos_$ID"
+                               echo "$BRANCH: $r"
+                       done
+               }
+               ;;
        merge)
                for d in $repos; do
                        dv=`visible_repo_name "$d"`
                        enter "$d0/$d" verbose
                        r=`git symbolic-ref HEAD`
                        r=${r#refs/heads/}
-                       if git log HEAD..origin/master | grep .; then
+                       if git log HEAD..origin/"`repobranch "$d"`" | grep .; then
                                # we have uncommitted changes
                                a=
                                while [ x"$a" != x"y" -a x"$a" != x"n" ]; do
-                                       echo "Could merge from \"master\" into \"$r\" in $dv. Do it?"
+                                       echo "Could merge from \"`repobranch "$d"`\" into \"$r\" in $dv. Do it?"
                                        read -r a
                                done
                                if [ x"$a" = x"y" ]; then
-                                       if ! verbose git merge origin/master; then
+                                       if ! verbose git merge origin/"`repobranch "$d"`"; then
                                                check_mergeconflict "$d"
                                                exit 1 # this should ALWAYS be fatal
                                        fi
@@ -331,7 +379,7 @@ case "$cmd" in
                                fi
                        fi
                        rem=`git config "branch.$r.remote" || echo origin`
-                       if { git log "$rem/$r".."$r" || git log origin/master.."$r"; } | grep .; then
+                       if { git log "$rem/$r".."$r" || git log origin/"`repobranch "$d"`".."$r"; } | grep .; then
                                a=
                                while [ x"$a" != x"y" -a x"$a" != x"n" ]; do
                                        echo "Push \"$r\" in $dv?"
@@ -357,6 +405,15 @@ case "$cmd" in
                else
                        TARGETS="sv-debug cl-debug sdl-debug"
                fi
+               case "$1" in
+                       -c)
+                               clean=true
+                               shift
+                               ;;
+                       *)
+                               clean=false
+                               ;;
+               esac
                case "$1" in
                        sdl)
                                TARGETS="sdl-debug"
@@ -378,20 +435,37 @@ case "$cmd" in
                                        MAKEFLAGS=-j$ncpus
                                fi
                        fi
+                       case "`uname`" in
+                               Linux|*BSD)
+                                       MAKEFLAGS="$MAKEFLAGS DP_LINK_TO_LIBJPEG=1"
+                                       ;;
+                       esac
                fi
                enter "$d0/fteqcc" verbose
+               if $clean; then
+                       verbose make $MAKEFLAGS clean
+               fi
                verbose make $MAKEFLAGS
                enter "$d0/data/xonotic-data.pk3dir" verbose
-               verbose make FTEQCC="$d0/fteqcc/fteqcc.bin" $MAKEFLAGS
+               if $clean; then
+                       verbose make $MAKEFLAGS clean
+               fi
+               verbose make FTEQCC="$d0/fteqcc/fteqcc.bin" "$@" $MAKEFLAGS
                enter "$d0/darkplaces" verbose
+               if $clean; then
+                       verbose make $MAKEFLAGS clean
+               fi
                for T in $TARGETS; do
-                       verbose make $MAKEFLAGS "$T"
+                       verbose make $MAKEFLAGS "$@" "$T"
                done
                ;;
        run)
                if [ -n "$WE_HATE_OUR_USERS" ]; then
                        client=
                        export PATH="$d0/misc/buildfiles/w32:$PATH"
+               elif [ x"`uname`" = x"Darwin" ]; then
+                       export DYLD_LIBRARY_PATH="$d0/misc/buildfiles/osx/Nexuiz.app/Contents/MacOS"
+                       client=-sdl
                else
                        client=-sdl
                fi
@@ -413,8 +487,11 @@ case "$cmd" in
                                exit 1
                        fi
                fi
-               #verbose "darkplaces/darkplaces$client" -xonotic "$@"
-               verbose "darkplaces/darkplaces$client" -nexuiz -customgamename Xonotic -customgamedirname1 data -customgamedirname2 "" -customgamescreenshotname xonotic -customgameuserdirname xonotic "$@"
+               set -- "darkplaces/darkplaces$client" -nexuiz -customgamename Xonotic -customgamedirname1 data -customgamedirname2 "" -customgamescreenshotname xonotic -customgameuserdirname xonotic "$@"
+               if [ -n "$USE_GDB" ]; then
+                       set -- gdb --args "$@"
+               fi
+               "$@"
                ;;
        each|foreach)
                for d in $repos; do
@@ -439,7 +516,7 @@ case "$cmd" in
                                                        TRACK=true
                                                        ;;
                                                *)
-                                                       UPSTREAM=origin/master
+                                                       UPSTREAM=origin/"`repobranch "$d"`"
                                                        TRACK=false
                                                        ;;
                                        esac
@@ -485,6 +562,9 @@ case "$cmd" in
                rm -rf "$patchdir"
                ;;
        admin-merge)
+               if [ "$#" = 1 ]; then
+                       set -- "${1%%/*}" "${1#*/}"
+               fi
                for d in $repos; do
                        enter "$d0/$d" verbose
                        git rev-parse "$1/$2" || continue
@@ -528,8 +608,8 @@ case "$cmd" in
                echo "  $SELF branch [<remote>] <branchname>"
                echo "  $SELF branch <remote> <branchname> <srcbranchname>"
                echo "  $SELF checkout [<remote>] <branchname>"
-               echo "  $SELF compile"
-               echo "  $SELF run <client> <options>"
+               echo "  $SELF compile [-c] [<client>] <options>"
+               echo "  $SELF run [<client>] <options>"
                echo "  $SELF each <command>"
                ;;
 esac
diff --git a/data/common-spog.pk3 b/data/common-spog.pk3
deleted file mode 100644 (file)
index 3696bbb..0000000
Binary files a/data/common-spog.pk3 and /dev/null differ
diff --git a/misc/tools/nexuiz-map-compiler b/misc/tools/nexuiz-map-compiler
deleted file mode 100755 (executable)
index b552971..0000000
+++ /dev/null
@@ -1,307 +0,0 @@
-#!/usr/bin/perl
-
-use strict;
-use warnings;
-use POSIX;
-use File::Temp;
-
-# change these to match your system, or define them in ~/.nexuiz-map-compiler
-# (just copy paste this part to the file ~/.nexuiz-map-compiler)
-
-       # Path to Nexuiz (where the data directory is in)
-       our $NEXUIZDIR   = '/home/polzer/Nexvn/nexuiz';
-
-       # Path to your q3map2 program. You find it in your GtkRadiant/install
-       # directory.
-       our $Q3MAP2      = '/home/users4/ommz/polzer/bin/q3map2.x86';
-
-       # General flags for q3map2 (for example -threads 4)
-       our $Q3MAP2FLAGS = '';
-
-       # Default flags for the -bsp stage
-       our $BSPFLAGS    = '-meta -samplesize 8 -minsamplesize 4 -mv 1000000 -mi 6000000';
-
-       # Default flags for the -vis stage
-       our $VISFLAGS    = '';
-
-       # Default flags for the -light stage
-       our $LIGHTFLAGS  = '-deluxe -patchshadows -samples 3 -lightmapsize 512 -bounce 8 -fastbounce -bouncegrid';
-
-       # Default flags for the -minimap stage
-       our $MINIMAPFLAGS = '';
-
-       # Default order of commands
-       our $ORDER = 'light,vis,minimap';
-
-# end of user changable part
-
-do "$ENV{HOME}/.nexuiz-map-compiler";
-
-sub Usage()
-{
-       print <<EOF;
-Usage:
-$0 mapname [-bsp bspflags...] [-vis visflags...] [-light lightflags...]
-EOF
-       exit 1;
-}
-
-my $options =
-{
-       bsp => [split /\s+/, $BSPFLAGS],
-       vis => [split /\s+/, $VISFLAGS],
-       light => [split /\s+/, $LIGHTFLAGS],
-       minimap => [split /\s+/, $MINIMAPFLAGS],
-       order => [split /\s*,\s*/, $ORDER],
-       maps => [],
-       scale => 1
-};
-
-my $curmode = 'maps';
-
-while(@ARGV)
-{
-       $_ = shift @ARGV;
-       my $enterflags = undef;
-       if($_ eq '-bsp')
-       {
-               $enterflags = 'bsp';
-       }
-       elsif($_ eq '-vis')
-       {
-               $enterflags = 'vis';
-       }
-       elsif($_ eq '-light')
-       {
-               $enterflags = 'light';
-       }
-       elsif($_ eq '-minimap')
-       {
-               $enterflags = 'minimap';
-       }
-       elsif($_ eq '-map')
-       {
-               $curmode = 'maps';
-       }
-       elsif($_ eq '-scale')
-       {
-               $options->{scale} = (shift @ARGV) || 1;
-       }
-       elsif($_ eq '-novis')
-       {
-               $options->{vis} = undef;
-       }
-       elsif($_ eq '-nolight')
-       {
-               $options->{light} = undef;
-       }
-       elsif($_ eq '-nominimap')
-       {
-               $options->{minimap} = undef;
-       }
-       elsif($_ eq '-order')
-       {
-               $options->{order} = [split /\s*,\s*/, shift @ARGV];
-       }
-       elsif($_ =~ /^-(-.*)/)
-       {
-               if($curmode eq 'maps')
-               {
-                       $curmode = 'bsp';
-               }
-               push @{$options->{$curmode}}, $1;
-       }
-       elsif($_ =~ /^-/ and $curmode eq 'maps')
-       {
-               $curmode = 'bsp';
-               push @{$options->{$curmode}}, $_;
-       }
-       else
-       {
-               push @{$options->{$curmode}}, $_;
-       }
-       if(defined $enterflags)
-       {
-               $curmode = $enterflags;
-               if($ARGV[0] eq '+')
-               {
-                       shift @ARGV;
-               }
-               else
-               {
-                       $options->{$curmode} = [];
-               }
-       }
-}
-
-my $linkdir = File::Temp::tempdir("nexuiz-map-compiler.XXXXXX", TMPDIR => 1, CLEANUP => 1);
-
-sub q3map2(@)
-{
-       my @args = ($Q3MAP2, split(/\s+/, $Q3MAP2FLAGS), '-game', 'nexuiz', '-fs_basepath', $NEXUIZDIR, '-fs_basepath', $linkdir, '-v', @_);
-       print "\$ @args\n";
-       return !system @args;
-}
-
-(my $mapdir = getcwd()) =~ s!/[^/]*(?:$)!!;
-$mapdir = "/" if $mapdir eq "";
-symlink "$mapdir", "$linkdir/data";
-
-my ($prescale, $postscale) = ($options->{scale} =~ /^([0-9.]+)(?::([0-9.]+))?$/);
-$postscale = 1 if not defined $postscale;
-
-for my $m(@{$options->{maps}})
-{
-       $m =~ s/\.(?:map|bsp)$//;
-       if($prescale != 1)
-       {
-               open my $checkfh, "<", "$m.map"
-                       or die "open $m.map: $!";
-               my $keeplights = 0;
-               while(<$checkfh>)
-               {
-                       /^\s*"_keeplights"\s+"1"\s*$/
-                               or next;
-                       $keeplights = 1;
-               }
-               close $checkfh;
-               die "$m does not define _keeplights to 1"
-                       unless $keeplights;
-       }
-
-       my %shaders = map { m!/([^/.]*)\.shader(?:$)! ? ($1 => 1) : () } glob "../scripts/*.shader";
-
-       my $previous_shaderlist = undef;
-       my $shaderlist = "";
-       if(open my $fh, "<", "$NEXUIZDIR/scripts/shaderlist.txt")
-       {
-               while(<$fh>)
-               {
-                       $shaderlist .= $_;
-               }
-
-               # we may have to restore the file on exit
-               $previous_shaderlist = $shaderlist
-                       if "$NEXUIZDIR/data" eq $mapdir;
-       }
-       else
-       {
-               # possibly extract the shader list from a pk3?
-               local $ENV{N} = $NEXUIZDIR;
-               $shaderlist = `cd "\$N" && for X in "\$N"/data/data*.pk3; do Y=\$X; done; unzip -p "\$Y" scripts/shaderlist.txt`;
-       }
-
-       my $shaderlist_new = "";
-       for(split /\r?\n|\r/, $shaderlist)
-       {
-               delete $shaders{$_};
-               $shaderlist_new .= "$_\n";
-       }
-       if(%shaders)
-       {
-               for(sort keys %shaders)
-               {
-                       $shaderlist_new .= "$_\n";
-               }
-       }
-       else
-       {
-               $shaderlist_new = undef;
-       }
-
-       my $restore_shaderlist = sub
-       {
-               if(defined $shaderlist_new)
-               {
-                       if(defined $previous_shaderlist)
-                       {
-                               open my $fh, ">", "$mapdir/scripts/shaderlist.txt";
-                               print $fh $previous_shaderlist;
-                               close $fh;
-                       }
-                       else
-                       {
-                               unlink "$mapdir/scripts/shaderlist.txt";
-                       }
-               }
-       };
-       local $SIG{INT} = sub
-       {
-               print "SIGINT caught, cleaning up...\n";
-               $restore_shaderlist->();
-               exit 0;
-       };
-
-       eval
-       {
-               if(defined $shaderlist_new)
-               {
-                       mkdir "$mapdir/scripts";
-                       open my $fh, ">", "$mapdir/scripts/shaderlist.txt";
-                       print $fh $shaderlist_new;
-                       close $fh;
-               }
-
-               unlink <$m/lm_*>; # delete old external lightmaps
-               q3map2 '-bsp', @{$options->{bsp}},   "$m.map"
-                       or die "-bsp: $?";
-               if($prescale != 1)
-               {
-                       q3map2 '-scale', $prescale, "$m.bsp"
-                               or die "-scale: $?";
-                       rename "${m}_s.bsp", "$m.bsp"
-                               or die "rename ${m}_s.bsp $m.bsp: $!";
-               }
-               my @o = @{$options->{order}};
-               push @o, qw/light vis minimap/;
-               my %o = ();
-
-               for(@o)
-               {
-                       next if $o{$_}++;
-                       if($_ eq 'light')
-                       {
-                               if(defined $options->{light})
-                               {
-                                       q3map2 '-light',        @{$options->{light}}, "$m.map"
-                                               or die "-light: $?";
-                               }
-                       }
-                       if($_ eq 'vis')
-                       {
-                               if(defined $options->{vis})
-                               {
-                                       q3map2 '-vis',          @{$options->{vis}},   "$m.map"
-                                               or die "-vis: $?";
-                               }
-                       }
-                       if($_ eq 'minimap')
-                       {
-                               if(defined $options->{minimap})
-                               {
-                                       q3map2 '-minimap',      @{$options->{minimap}}, "$m.map"
-                                               or die "-minimap: $?";
-                               }
-                       }
-               }
-
-               if($postscale != 1)
-               {
-                       q3map2 '-scale', $postscale, "$m.bsp"
-                               or die "-scale: $?";
-                       rename "${m}_s.bsp", "$m.bsp"
-                               or die "rename ${m}_s.bsp $m.bsp: $!";
-               }
-
-               unlink "$m.srf";
-               unlink "$m.prt";
-
-               $restore_shaderlist->();
-               1;
-       }
-       or do
-       {
-               $restore_shaderlist->();
-               die $@;
-       };
-}
diff --git a/misc/tools/xonotic-map-compiler b/misc/tools/xonotic-map-compiler
new file mode 100755 (executable)
index 0000000..8b6cd4d
--- /dev/null
@@ -0,0 +1,316 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+use POSIX;
+use File::Temp;
+
+# change these to match your system, or define them in ~/.xonotic-map-compiler
+# (just copy paste this part to the file ~/.xonotic-map-compiler)
+
+       # Path to Xonotic (where the data directory is in)
+       our $XONOTICDIR   = '/home/rpolzer/Games/Xonotic';
+
+       # Path to your q3map2 program. You find it in your GtkRadiant/install
+       # directory.
+       our $Q3MAP2      = '/home/rpolzer/Games/Xonotic/netradiant/install/q3map2.x86';
+
+       # General flags for q3map2 (for example -threads 4)
+       our $Q3MAP2FLAGS = '';
+
+       # Default flags for the -bsp stage
+       our $BSPFLAGS    = '-meta -samplesize 8 -minsamplesize 4 -mv 1000000 -mi 6000000';
+
+       # Default flags for the -vis stage
+       our $VISFLAGS    = '';
+
+       # Default flags for the -light stage
+       our $LIGHTFLAGS  = '-deluxe -patchshadows -samples 3 -lightmapsize 512 -bounce 8 -fastbounce -bouncegrid';
+
+       # Default flags for the -minimap stage
+       our $MINIMAPFLAGS = '';
+
+       # Default order of commands
+       our $ORDER = 'light,vis,minimap';
+
+# end of user changable part
+
+do "$ENV{HOME}/.xonotic-map-compiler";
+
+sub Usage()
+{
+       print <<EOF;
+Usage:
+$0 mapname [-bsp bspflags...] [-vis visflags...] [-light lightflags...]
+EOF
+       exit 1;
+}
+
+my $options =
+{
+       bsp => [split /\s+/, $BSPFLAGS],
+       vis => [split /\s+/, $VISFLAGS],
+       light => [split /\s+/, $LIGHTFLAGS],
+       minimap => [split /\s+/, $MINIMAPFLAGS],
+       order => [split /\s*,\s*/, $ORDER],
+       maps => [],
+       scale => 1
+};
+
+my $curmode = 'maps';
+
+while(@ARGV)
+{
+       $_ = shift @ARGV;
+       my $enterflags = undef;
+       if($_ eq '-bsp')
+       {
+               $enterflags = 'bsp';
+       }
+       elsif($_ eq '-vis')
+       {
+               $enterflags = 'vis';
+       }
+       elsif($_ eq '-light')
+       {
+               $enterflags = 'light';
+       }
+       elsif($_ eq '-minimap')
+       {
+               $enterflags = 'minimap';
+       }
+       elsif($_ eq '-map')
+       {
+               $curmode = 'maps';
+       }
+       elsif($_ eq '-scale')
+       {
+               $options->{scale} = (shift @ARGV) || 1;
+       }
+       elsif($_ eq '-novis')
+       {
+               $options->{vis} = undef;
+       }
+       elsif($_ eq '-nolight')
+       {
+               $options->{light} = undef;
+       }
+       elsif($_ eq '-nominimap')
+       {
+               $options->{minimap} = undef;
+       }
+       elsif($_ eq '-noshaderlist')
+       {
+               $options->{noshaderlist} = 1;
+       }
+       elsif($_ eq '-order')
+       {
+               $options->{order} = [split /\s*,\s*/, shift @ARGV];
+       }
+       elsif($_ =~ /^-(-.*)/)
+       {
+               if($curmode eq 'maps')
+               {
+                       $curmode = 'bsp';
+               }
+               push @{$options->{$curmode}}, $1;
+       }
+       elsif($_ =~ /^-/ and $curmode eq 'maps')
+       {
+               $curmode = 'bsp';
+               push @{$options->{$curmode}}, $_;
+       }
+       else
+       {
+               push @{$options->{$curmode}}, $_;
+       }
+       if(defined $enterflags)
+       {
+               $curmode = $enterflags;
+               if($ARGV[0] eq '+')
+               {
+                       shift @ARGV;
+               }
+               else
+               {
+                       $options->{$curmode} = [];
+               }
+       }
+}
+
+my $linkdir = File::Temp::tempdir("xonotic-map-compiler.XXXXXX", TMPDIR => 1, CLEANUP => 1);
+
+sub q3map2(@)
+{
+       my @args = ($Q3MAP2, split(/\s+/, $Q3MAP2FLAGS), '-game', 'xonotic', '-fs_basepath', $XONOTICDIR, '-fs_basepath', $linkdir, '-v', @_);
+       print "\$ @args\n";
+       return !system @args;
+}
+
+(my $mapdir = getcwd()) =~ s!/[^/]*(?:$)!!;
+$mapdir = "/" if $mapdir eq "";
+symlink "$mapdir", "$linkdir/data";
+
+my ($prescale, $postscale) = ($options->{scale} =~ /^([0-9.]+)(?::([0-9.]+))?$/);
+$postscale = 1 if not defined $postscale;
+
+for my $m(@{$options->{maps}})
+{
+       $m =~ s/\.(?:map|bsp)$//;
+       if($prescale != 1)
+       {
+               open my $checkfh, "<", "$m.map"
+                       or die "open $m.map: $!";
+               my $keeplights = 0;
+               while(<$checkfh>)
+               {
+                       /^\s*"_keeplights"\s+"1"\s*$/
+                               or next;
+                       $keeplights = 1;
+               }
+               close $checkfh;
+               die "$m does not define _keeplights to 1"
+                       unless $keeplights;
+       }
+
+       my %shaders = map { m!/([^/.]*)\.shader(?:$)! ? ($1 => 1) : () } glob "../scripts/*.shader";
+
+       my $restore_shaderlist = sub { };
+       if(!$options->{noshaderlist})
+       {
+               my $previous_shaderlist = undef;
+               my $shaderlist = "";
+               if(open my $fh, "<", "$XONOTICDIR/data/xonotic-maps.pk3dir/scripts/shaderlist.txt")
+               {
+                       while(<$fh>)
+                       {
+                               $shaderlist .= $_;
+                       }
+
+                       # we may have to restore the file on exit
+                       $previous_shaderlist = $shaderlist
+                               if "$XONOTICDIR/data" eq $mapdir;
+               }
+               else
+               {
+                       # possibly extract the shader list from a pk3?
+                       local $ENV{N} = $XONOTICDIR;
+                       $shaderlist = `cd "\$N" && for X in "\$N"/data/data*.pk3; do Y=\$X; done; unzip -p "\$Y" scripts/shaderlist.txt`;
+               }
+
+               my $shaderlist_new = "";
+               for(split /\r?\n|\r/, $shaderlist)
+               {
+                       delete $shaders{$_};
+                       $shaderlist_new .= "$_\n";
+               }
+               if(%shaders)
+               {
+                       for(sort keys %shaders)
+                       {
+                               $shaderlist_new .= "$_\n";
+                       }
+               }
+               else
+               {
+                       $shaderlist_new = undef;
+               }
+
+               $restore_shaderlist = sub
+               {
+                       if(defined $shaderlist_new)
+                       {
+                               if(defined $previous_shaderlist)
+                               {
+                                       open my $fh, ">", "$mapdir/scripts/shaderlist.txt";
+                                       print $fh $previous_shaderlist;
+                                       close $fh;
+                               }
+                               else
+                               {
+                                       unlink "$mapdir/scripts/shaderlist.txt";
+                               }
+                       }
+               };
+
+               if(defined $shaderlist_new)
+               {
+                       mkdir "$mapdir/scripts";
+                       open my $fh, ">", "$mapdir/scripts/shaderlist.txt";
+                       print $fh $shaderlist_new;
+                       close $fh;
+               }
+       }
+
+       local $SIG{INT} = sub
+       {
+               print "SIGINT caught, cleaning up...\n";
+               $restore_shaderlist->();
+               exit 0;
+       };
+
+       eval
+       {
+               unlink <$m/lm_*>; # delete old external lightmaps
+               q3map2 '-bsp', @{$options->{bsp}},   "$m.map"
+                       or die "-bsp: $?";
+               if($prescale != 1)
+               {
+                       q3map2 '-scale', $prescale, "$m.bsp"
+                               or die "-scale: $?";
+                       rename "${m}_s.bsp", "$m.bsp"
+                               or die "rename ${m}_s.bsp $m.bsp: $!";
+               }
+               my @o = @{$options->{order}};
+               push @o, qw/light vis minimap/;
+               my %o = ();
+
+               for(@o)
+               {
+                       next if $o{$_}++;
+                       if($_ eq 'light')
+                       {
+                               if(defined $options->{light})
+                               {
+                                       q3map2 '-light',        @{$options->{light}}, "$m.map"
+                                               or die "-light: $?";
+                               }
+                       }
+                       if($_ eq 'vis')
+                       {
+                               if(defined $options->{vis})
+                               {
+                                       q3map2 '-vis',          @{$options->{vis}},   "$m.map"
+                                               or die "-vis: $?";
+                               }
+                       }
+                       if($_ eq 'minimap')
+                       {
+                               if(defined $options->{minimap})
+                               {
+                                       q3map2 '-minimap',      @{$options->{minimap}}, "$m.map"
+                                               or die "-minimap: $?";
+                               }
+                       }
+               }
+
+               if($postscale != 1)
+               {
+                       q3map2 '-scale', $postscale, "$m.bsp"
+                               or die "-scale: $?";
+                       rename "${m}_s.bsp", "$m.bsp"
+                               or die "rename ${m}_s.bsp $m.bsp: $!";
+               }
+
+               unlink "$m.srf";
+               unlink "$m.prt";
+
+               $restore_shaderlist->();
+               1;
+       }
+       or do
+       {
+               $restore_shaderlist->();
+               die $@;
+       };
+}
diff --git a/misc/tools/xonotic-map-compiler-autobuild b/misc/tools/xonotic-map-compiler-autobuild
new file mode 100755 (executable)
index 0000000..8249686
--- /dev/null
@@ -0,0 +1,30 @@
+#!/bin/sh
+
+bspdir="$PWD/bspfiles"
+mkdir -p "$bspdir"
+cd data/xonotic-maps.pk3dir
+git for-each-ref 'refs/remotes' | while read -r HASH TYPE REFNAME; do
+       git reset --hard
+       git clean -xfd
+       git checkout "$HASH"
+       for F in maps/*.map.options; do
+               if ! [ -f "$F" ]; then
+                       continue
+               fi
+               if ! [ -f "${F%.options}" ]; then
+                       continue
+               fi
+               M=${F#maps/}
+               M=${M%.map.options}
+               blobhash="$M"-`git ls-files -s -- "$F" | cut -d ' ' -f 2`-`git ls-files -s -- "${F%.options}" | cut -d ' ' -f 2`
+               if [ -f "$bspdir/$blobhash.pk3" ]; then
+                       continue
+               fi
+               (
+                       cd maps
+                       ../../../misc/tools/xonotic-map-compiler "$M" -noshaderlist `head -n 1 "../$F"` 2>&1 | tee "$M.log"
+               )
+               zip -9r "$bspdir/$blobhash.pk3" "maps/$M.bsp" "maps/$M.log" "maps/$M/" "maps/$M.lin" "gfx/${M}_mini.tga"
+       done
+done
+git checkout master
index 489a7e17a3eb9a1d7bfbe04bcd639338a96bb9f1..c1c2a4efb5c16d649fe972f0e29f87c80ae53b0f 100755 (executable)
@@ -1293,6 +1293,18 @@ sub cond($)
        [ irc => q{:[^ ]* 001 .*} => sub {
                $store{irc_seen_welcome} = 1;
                $store{irc_nick} = $store{irc_nick_requested};
+               
+               # If users for quakenet are listed, parse them into a hash and schedule a sub to query information
+               if ($config{irc_quakenet_authusers} ne '') {
+                       $store{irc_quakenet_users} = { map { $_ => 1 } split / /, $config{irc_quakenet_authusers} };
+       
+                       schedule sub {
+                               my ($timer) = @_;
+                               out irc => 0, "PRIVMSG Q :users " . $config{irc_channel};
+                               schedule $timer => 300;;
+                       } => 1;
+               }
+
                return irc_joinstage(0);
        } ],
 
@@ -1688,17 +1700,6 @@ for my $p(split ' ', $config{plugins})
 }
 
 
-# If users for quakenet are listed, parse them into a hash and schedule a sub to query information
-if ($config{irc_quakenet_authusers} ne '') {
-       $store{irc_quakenet_users} = { map { $_ => 1 } split / /, $config{irc_quakenet_authusers} };
-       
-       schedule sub {
-               my ($timer) = @_;
-               out irc => 0, "PRIVMSG Q :users " . $config{irc_channel};
-               schedule $timer => 300;;
-       } => 1;
-}
-
 
 # verify that the server is up by letting it echo back a string that causes
 # re-initialization of the required aliases