]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Move scripts to qcsrc/tools
authorTimePath <andrew.hardaker1995@gmail.com>
Mon, 14 Mar 2016 08:34:43 +0000 (19:34 +1100)
committerTimePath <andrew.hardaker1995@gmail.com>
Mon, 14 Mar 2016 08:34:43 +0000 (19:34 +1100)
19 files changed:
qcsrc/Makefile
qcsrc/autocvarize-update.sh [deleted file]
qcsrc/autocvarize.pl [deleted file]
qcsrc/common/monsters/monster/mage.qc
qcsrc/common/mutators/mutator/itemstime.qc
qcsrc/qcc.sh [deleted file]
qcsrc/test/compilationunits.sh [deleted file]
qcsrc/test/headerstyle.sh [deleted file]
qcsrc/tools/autocvarize-update.sh [new file with mode: 0755]
qcsrc/tools/autocvarize.pl [new file with mode: 0644]
qcsrc/tools/compilationunits.sh [new file with mode: 0755]
qcsrc/tools/headerstyle.sh [new file with mode: 0755]
qcsrc/tools/qcc.sh [new file with mode: 0755]
qcsrc/tools/uncrusticracy.sh [new file with mode: 0644]
qcsrc/tools/uncrustify.sh [new file with mode: 0755]
qcsrc/tools/whitespace.sh [new file with mode: 0755]
qcsrc/uncrusticracy.sh [deleted file]
qcsrc/uncrustify.sh [deleted file]
qcsrc/whitespace.sh [deleted file]

index f6cdc7c20a2fa01535487024d128c1d45a66db08..e149f001e469f5698d7d1be152faa456ebf62f55 100644 (file)
@@ -99,15 +99,15 @@ export QCCFLAGS
 
 $(PROGS_OUT)/csprogs.dat: client/progs.inc $(QCCVERSIONFILE) | $(WORKDIR)
        @ echo make[1]: Entering directory \`$(CURDIR)/client\'
-       @ ./qcc.sh client $@ $<
+       @ ./tools/qcc.sh client $@ $<
 -include $(WORKDIR)/client.d
 
 $(PROGS_OUT)/progs.dat: server/progs.inc $(QCCVERSIONFILE) | $(WORKDIR)
        @ echo make[1]: Entering directory \`$(CURDIR)/server\'
-       @ ./qcc.sh server $@ $<
+       @ ./tools/qcc.sh server $@ $<
 -include $(WORKDIR)/server.d
 
 $(PROGS_OUT)/menu.dat: menu/progs.inc $(QCCVERSIONFILE) | $(WORKDIR)
        @ echo make[1]: Entering directory \`$(CURDIR)/menu\'
-       @ ./qcc.sh menu $@ $<
+       @ ./tools/qcc.sh menu $@ $<
 -include $(WORKDIR)/menu.d
diff --git a/qcsrc/autocvarize-update.sh b/qcsrc/autocvarize-update.sh
deleted file mode 100755 (executable)
index 31ecc08..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-#!/bin/sh
-set -ex
-git checkout divVerent/autocvarizer_test
-trap 'git reset --hard; git checkout divVerent/autocvarizer' EXIT
-trap 'exit 1' INT
-git merge --no-commit -s ours divVerent/autocvarizer
-git read-tree -m -u divVerent/autocvarizer # "theirs"
-find server \( -type f -a \( -name \*.c -o -name \*.qc -o -name \*.h -o -name \*.qh \) \) -print0 | AUTOCVARING_SVQC=1 xargs -0 perl autocvarize.pl > server/autocvars.qh.new
-diff -Nu server/autocvars.qh server/autocvars.qh.new || true
-mv server/autocvars.qh.new server/autocvars.qh
-find client \( -type f -a \( -name \*.c -o -name \*.qc -o -name \*.h -o -name \*.qh \) \) -print0 | xargs -0 perl autocvarize.pl > client/autocvars.qh.new
-diff -Nu client/autocvars.qh client/autocvars.qh.new || true
-mv client/autocvars.qh.new client/autocvars.qh
-if make -C .. FTEQCC=../../../../fteqcc/fteqcc.bin FTEQCCFLAGS=; then
-       echo "Commit? ^C to not"
-       read -r L
-       git add server/autocvars.qh
-       git add client/autocvars.qh
-       git commit -a
-else
-       echo "FAILED. Exit this shell when done examining."
-       sh -i
-fi
diff --git a/qcsrc/autocvarize.pl b/qcsrc/autocvarize.pl
deleted file mode 100644 (file)
index 7ac048a..0000000
+++ /dev/null
@@ -1,281 +0,0 @@
-#!/usr/bin/perl
-# this tool generates JUST the autocvar declarations for cvars
-use strict;
-use warnings;
-
-my @files = @ARGV;
-
-my %cvars = ();
-my %old = ();
-my %menu = ();
-my %defaults = ();
-
-sub found($$$$)
-{
-       my ($name, $type, $default, $force) = @_;
-       if(length $name >= 55)
-       {
-               warn "cvar $name is a Dr. honorificabilitudinitatibis causa BRLOGENSHFEGLE";
-               $type = 'cvar_toolong';
-               return;
-       }
-#      $old{$name} = 1
-#              if $force;
-#      $menu{$name} = 1
-#              if $force > 1;
-       if(exists $cvars{$name} and not defined $cvars{name})
-       {
-               # have already warned
-       }
-       elsif(exists $cvars{$name} and $type ne $cvars{$name})
-       {
-               warn "cvar $name used with different types";
-               if($force)
-               {
-                       $defaults{$name} = $default;
-                       $cvars{$name} = $type;
-               }
-               else
-               {
-                       undef $cvars{$name}
-                               unless $old{$name};
-               }
-               return;
-       }
-       elsif(exists $cvars{$name} and exists $defaults{$name} and $default ne $defaults{$name})
-       {
-               warn "cvar $name used with different defaults";
-               if($force)
-               {
-                       $defaults{$name} = $default;
-                       $cvars{$name} = $type;
-               }
-               else
-               {
-                       undef $cvars{$name}
-                               unless $old{$name};
-               }
-       }
-       else
-       {
-               $defaults{$name} = $default;
-               $cvars{$name} = $type;
-       }
-}
-
-for my $f(@files)
-{
-       print STDERR "In file $f\n";
-       open my $fh, "<", $f;
-       while(<$fh>)
-       {
-               chomp;
-               if(/^\/\/#NO AUTOCVARS START/ .. /^\/\/#NO AUTOCVARS END/)
-               {
-                       next;
-               }
-               s/\/\/.*//;
-               if(/^(?:var )?float autocvar_(\w+);$/)
-               {
-                       found $1, 'cvar', 0, 1;
-                       next;
-               }
-               if(/^var float autocvar_(\w+) = (.*);$/)
-               {
-                       found $1, 'cvar', $2, 1;
-                       next;
-               }
-               if(/^(?:var )?vector autocvar_(\w+);$/)
-               {
-                       found $1, 'cvar_vector', "0 0 0", 1;
-                       next;
-               }
-               if(/^var vector autocvar_(\w+) = '(.*)';$/)
-               {
-                       found $1, 'cvar_vector', $2, 1;
-                       next;
-               }
-               if(/^(?:var )?string autocvar_(\w+);$/)
-               {
-                       found $1, 'cvar_string', "", 1;
-                       next;
-               }
-               if(/^var string autocvar_(\w+) = "(.*)";$/)
-               {
-                       found $1, 'cvar_string', $2, 1;
-                       next;
-               }
-               if(/^#define autocvar_(\w+) cvar("\1")$/)
-               {
-                       found $1, 'cvar', 0, 2;
-                       next;
-               }
-               if(/^#define autocvar_(\w+) cvar_or("\1", (.*))$/)
-               {
-                       found $1, 'cvar', $1, 2;
-                       next;
-               }
-               if(/^#define autocvar_(\w+) cvar_string("\1")$/)
-               {
-                       found $1, 'cvar_string', "", 2;
-                       next;
-               }
-               while(/\bcvar\s*\(\s*"(\w+)"\s*\)/g)
-               {
-                       found $1, 'cvar', 0, 0;
-               }
-               while(/\bcvar_string\s*\(\s*"(\w+)"\s*\)/g)
-               {
-                       found $1, 'cvar_string', "", 0;
-               }
-               while(/\bcvar_vector\s*\(\s*"(\w+)"\s*\)/g)
-               {
-                       found $1, 'cvar_vector', "0 0 0", 0;
-               }
-               while(/\bcvar_or\s*\(\s*"(\w+)"\s*,\s*([^\s)]+)\s*\)/g)
-               {
-                       found $1, 'cvar', $2, 0;
-               }
-       }
-}
-
-if($ENV{AUTOCVARING_SVQC})
-{
-       for my $f(<menu/xonotic/*.c>)
-       {
-               print STDERR "In file $f\n";
-               open my $fh, "<", $f;
-               while(<$fh>)
-               {
-                       for(/"([^"]*)"/g)
-                       {
-                               $menu{$1} = 1;
-                       }
-               }
-       }
-
-       for my $f(<../maps/campaign*.txt>)
-       {
-               print STDERR "In file $f\n";
-               open my $fh, "<", $f;
-               while(<$fh>)
-               {
-                       for(/\b(.+?)\b/g)
-                       {
-                               $menu{$1} = 1;
-                       }
-               }
-       }
-}
-
-for my $name(sort keys %cvars)
-{
-       my $type = $cvars{$name};
-       my $menu = $menu{$name};
-       my $default = $defaults{$name};
-       die "wtf" if $name =~ /\0/;
-       if(not defined $type)
-       {
-               print "// cannot declare $name, it is used with different types\n";
-       }
-       elsif($type eq 'cvar_toolong')
-       {
-               print "// cannot declare $name, name is too long\n";
-       }
-       elsif($type eq 'cvar' and not $menu and $default eq "0")
-       {
-               print "float autocvar_$name;\n";
-       }
-       elsif($type eq 'cvar' and not $menu and $default ne "0")
-       {
-               print "var float autocvar_$name = $default;\n";
-       }
-       elsif($type eq 'cvar_vector' and not $menu and $default eq "0 0 0")
-       {
-               print "vector autocvar_$name;\n";
-       }
-       elsif($type eq 'cvar_vector' and not $menu and $default ne "0 0 0")
-       {
-               print "var vector autocvar_$name = '$default';\n";
-       }
-       elsif($type eq 'cvar_string' and not $menu and $default eq "")
-       {
-               print "string autocvar_$name;\n";
-       }
-       elsif($type eq 'cvar_string' and not $menu and $default ne "")
-       {
-               print "var string autocvar_$name = \"$default\";\n";
-       }
-       elsif($type eq 'cvar' and $menu and $default eq "0")
-       {
-               print "#define autocvar_$name cvar(\"$name\")\n";
-       }
-       elsif($type eq 'cvar' and $menu and $default ne "0")
-       {
-               print "#define autocvar_$name cvar_or(\"$name\", \"$default\")\n";
-       }
-       elsif($type eq 'cvar_string' and $menu) # sorry, no cvar_or for these
-       {
-               print "#define autocvar_$name cvar_string(\"$name\")\n";
-       }
-       elsif($type eq 'cvar_vector' and $menu) # sorry, no cvar_or for these
-       {
-               print "#define autocvar_$name cvar_vector(\"$name\")\n";
-       }
-}
-
-for my $f(@files)
-{
-       print STDERR "In file $f\n";
-       open my $fh, "<", $f;
-       my $out = "";
-       while(<$fh>)
-       {
-               chomp;
-               if(/^\/\/#NO AUTOCVARS START/ .. /^\/\/#NO AUTOCVARS END/)
-               {
-                       $out .= "$_\n";
-                       next;
-               }
-               if(/^(?:var )?float autocvar_(.*);$/)
-               {
-                       $out .= "$_\n";
-                       next;
-               }
-               if(/^(?:var )?string autocvar_(.*);$/)
-               {
-                       $out .= "$_\n";
-                       next;
-               }
-               if(/^#define autocvar_(.*) cvar/)
-               {
-                       $out .= "$_\n";
-                       next;
-               }
-               s{\b(cvar|cvar_string|cvar_vector|cvar_or)\s*\(\s*"([^"]+)"\s*(?:,\s*[^\s)]+\s*)?\)}{
-                       my ($type, $name) = ($1, $2);
-                       $type = 'cvar' if $type eq 'cvar_or';
-                       my $realtype = $cvars{$name};
-                       my $r = $&;
-                       if(defined $realtype)
-                       {
-                               #$r = "$realtype(\"$name\")";
-                               $r = "autocvar_$name";
-                               if($type eq 'cvar' && $realtype eq 'cvar_string')
-                               {
-                                       $r = "stof($r)";
-                               }
-                               if($type eq 'cvar_string' && $realtype eq 'cvar')
-                               {
-                                       $r = "ftos($r)";
-                               }
-                       }
-                       $r;
-               }ge;
-               $out .= "$_\n";
-       }
-       close $fh;
-       open $fh, ">", $f;
-       print $fh $out;
-       close $fh;
-}
index c71e8c911ccfa1dde53e7aa85c926437fba453b8..0bf1a835e048d91faf80e32e348d11d7106384b6 100644 (file)
@@ -326,7 +326,7 @@ void M_Mage_Attack_Teleport(entity this, entity targ)
 
        Send_Effect(EFFECT_SPAWN_NEUTRAL, this.origin, '0 0 0', 1);
        Send_Effect(EFFECT_SPAWN_NEUTRAL, newpos, '0 0 0', 1);
-       
+
        setorigin(this, newpos);
 
        vector a = vectoangles(targ.origin - this.origin);
index 408bd6fc853b2aff6411efba26ea27c1bef243e2..f3612554d63e383e16d66bf93642311d8d157055 100644 (file)
@@ -366,7 +366,7 @@ void HUD_ItemsTime()
     FOREACH(Items, Item_ItemsTime_Allow(it) && ItemsTime_time[it.m_id] != -1, LAMBDA(
        id = it.m_id;
        icon = it.m_icon;
-       
+
        :iteration
         float item_time = ItemsTime_time[id];
         if (item_time < -1)
diff --git a/qcsrc/qcc.sh b/qcsrc/qcc.sh
deleted file mode 100755 (executable)
index b3ad199..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-#!/bin/sh
-set -eu
-
-MODE=$1
-IN=$3
-OUT=$2
-
-QCC=${QCC}
-QCCIDENT="-DGMQCC"
-
-case ${MODE} in
-    client) PROG=CSQC
-    ;;
-    menu) PROG=MENUQC
-    ;;
-    server) PROG=SVQC
-    ;;
-esac
-
-CPP="${CPP} -I. ${QCCIDENT} ${QCCDEFS} -D${PROG}"
-${CPP} -MMD -MP -MT ${OUT} -Wall -Wundef -Werror -o ../.tmp/${MODE}.txt ${IN}
-${CPP} -dM 1>../.tmp/${MODE}_macros.txt -H 2>../.tmp/${MODE}_includes.txt ${IN}
-sed 's/^#\(line\)\? \([[:digit:]]\+\) "\(.*\)".*/\n#pragma file(\3)\n#pragma line(\2)/g' ../.tmp/${MODE}.txt > ../.tmp/${MODE}.qc
-cd ${MODE}
-echo $(basename ${QCC}) ${QCCFLAGS} -o ${OUT} ${MODE}.qc
-${QCC} ${QCCFLAGS} -o ${OUT} ../../.tmp/${MODE}.qc
diff --git a/qcsrc/test/compilationunits.sh b/qcsrc/test/compilationunits.sh
deleted file mode 100755 (executable)
index 98ea3c6..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-#!/bin/bash
-set -eu
-cd "$(dirname "$0")"
-cd ..
-
-declare -a NOWARN=(
-    -Wno-field-redeclared
-    -Wno-unused-variable
-    -Wno-implicit-function-pointer
-)
-declare QCC=../../../gmqcc/gmqcc
-
-declare -a QCC_FLAGS=(
-    -std=gmqcc
-    -Wall -Werror
-    -fftepp -fftepp-predefs -Wcpp
-    -futf8
-    -freturn-assignments
-    -frelaxed-switch
-    -Ooverlap-locals
-)
-
-function check() {
-    declare -l base="${1}"
-    declare -la predefs=("-D${2}" "lib/_all.inc" "${base}/_all.qh")
-    find "$base" -type f -name '*.qc' -print0 | sort -z | while read -r -d '' file; do
-        echo "$file"
-        ${QCC} "${QCC_FLAGS[@]}" "${NOWARN[@]}" "${predefs[@]}" "$file" >/dev/null
-    done
-}
-
-check client CSQC
-check server SVQC
-check menu MENUQC
diff --git a/qcsrc/test/headerstyle.sh b/qcsrc/test/headerstyle.sh
deleted file mode 100755 (executable)
index ef17315..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-#!/bin/bash
-set -eu
-cd "$(dirname "$0")"
-cd ..
-
-function startswith() {
-    declare -l file="${1}"
-    declare -l prelude="${2}"
-    declare -l line=$(head -n1 "$file")
-    if [ "$line" != "$prelude" ]; then
-        echo "$prelude" | cat - "$file" > "$file.tmp" && mv "$file.tmp" "$file"
-    fi
-}
-
-function check() {
-    declare -l base="${1}"
-    find "$base" -type f -name '*.qc' -print0 | sort -z | while read -r -d '' file; do
-        echo "$file"
-        declare -l file_h="${file%.qc}.qh"
-        if [ ! -f "$file_h" ]; then echo "#pragma once" > "$file_h"; fi
-
-        include=$(basename "$file")
-        include="${include%.qc}.qh"
-        include="#include \"${include}\""
-        startswith "$file" "$include"
-    done
-    find "$base" -type f -name '*.qh' -print0 | sort -z | while read -r -d '' file; do
-        echo "$file"
-        startswith "$file" "#pragma once"
-    done
-}
-
-check client
-check server
-check menu
diff --git a/qcsrc/tools/autocvarize-update.sh b/qcsrc/tools/autocvarize-update.sh
new file mode 100755 (executable)
index 0000000..31ecc08
--- /dev/null
@@ -0,0 +1,23 @@
+#!/bin/sh
+set -ex
+git checkout divVerent/autocvarizer_test
+trap 'git reset --hard; git checkout divVerent/autocvarizer' EXIT
+trap 'exit 1' INT
+git merge --no-commit -s ours divVerent/autocvarizer
+git read-tree -m -u divVerent/autocvarizer # "theirs"
+find server \( -type f -a \( -name \*.c -o -name \*.qc -o -name \*.h -o -name \*.qh \) \) -print0 | AUTOCVARING_SVQC=1 xargs -0 perl autocvarize.pl > server/autocvars.qh.new
+diff -Nu server/autocvars.qh server/autocvars.qh.new || true
+mv server/autocvars.qh.new server/autocvars.qh
+find client \( -type f -a \( -name \*.c -o -name \*.qc -o -name \*.h -o -name \*.qh \) \) -print0 | xargs -0 perl autocvarize.pl > client/autocvars.qh.new
+diff -Nu client/autocvars.qh client/autocvars.qh.new || true
+mv client/autocvars.qh.new client/autocvars.qh
+if make -C .. FTEQCC=../../../../fteqcc/fteqcc.bin FTEQCCFLAGS=; then
+       echo "Commit? ^C to not"
+       read -r L
+       git add server/autocvars.qh
+       git add client/autocvars.qh
+       git commit -a
+else
+       echo "FAILED. Exit this shell when done examining."
+       sh -i
+fi
diff --git a/qcsrc/tools/autocvarize.pl b/qcsrc/tools/autocvarize.pl
new file mode 100644 (file)
index 0000000..7ac048a
--- /dev/null
@@ -0,0 +1,281 @@
+#!/usr/bin/perl
+# this tool generates JUST the autocvar declarations for cvars
+use strict;
+use warnings;
+
+my @files = @ARGV;
+
+my %cvars = ();
+my %old = ();
+my %menu = ();
+my %defaults = ();
+
+sub found($$$$)
+{
+       my ($name, $type, $default, $force) = @_;
+       if(length $name >= 55)
+       {
+               warn "cvar $name is a Dr. honorificabilitudinitatibis causa BRLOGENSHFEGLE";
+               $type = 'cvar_toolong';
+               return;
+       }
+#      $old{$name} = 1
+#              if $force;
+#      $menu{$name} = 1
+#              if $force > 1;
+       if(exists $cvars{$name} and not defined $cvars{name})
+       {
+               # have already warned
+       }
+       elsif(exists $cvars{$name} and $type ne $cvars{$name})
+       {
+               warn "cvar $name used with different types";
+               if($force)
+               {
+                       $defaults{$name} = $default;
+                       $cvars{$name} = $type;
+               }
+               else
+               {
+                       undef $cvars{$name}
+                               unless $old{$name};
+               }
+               return;
+       }
+       elsif(exists $cvars{$name} and exists $defaults{$name} and $default ne $defaults{$name})
+       {
+               warn "cvar $name used with different defaults";
+               if($force)
+               {
+                       $defaults{$name} = $default;
+                       $cvars{$name} = $type;
+               }
+               else
+               {
+                       undef $cvars{$name}
+                               unless $old{$name};
+               }
+       }
+       else
+       {
+               $defaults{$name} = $default;
+               $cvars{$name} = $type;
+       }
+}
+
+for my $f(@files)
+{
+       print STDERR "In file $f\n";
+       open my $fh, "<", $f;
+       while(<$fh>)
+       {
+               chomp;
+               if(/^\/\/#NO AUTOCVARS START/ .. /^\/\/#NO AUTOCVARS END/)
+               {
+                       next;
+               }
+               s/\/\/.*//;
+               if(/^(?:var )?float autocvar_(\w+);$/)
+               {
+                       found $1, 'cvar', 0, 1;
+                       next;
+               }
+               if(/^var float autocvar_(\w+) = (.*);$/)
+               {
+                       found $1, 'cvar', $2, 1;
+                       next;
+               }
+               if(/^(?:var )?vector autocvar_(\w+);$/)
+               {
+                       found $1, 'cvar_vector', "0 0 0", 1;
+                       next;
+               }
+               if(/^var vector autocvar_(\w+) = '(.*)';$/)
+               {
+                       found $1, 'cvar_vector', $2, 1;
+                       next;
+               }
+               if(/^(?:var )?string autocvar_(\w+);$/)
+               {
+                       found $1, 'cvar_string', "", 1;
+                       next;
+               }
+               if(/^var string autocvar_(\w+) = "(.*)";$/)
+               {
+                       found $1, 'cvar_string', $2, 1;
+                       next;
+               }
+               if(/^#define autocvar_(\w+) cvar("\1")$/)
+               {
+                       found $1, 'cvar', 0, 2;
+                       next;
+               }
+               if(/^#define autocvar_(\w+) cvar_or("\1", (.*))$/)
+               {
+                       found $1, 'cvar', $1, 2;
+                       next;
+               }
+               if(/^#define autocvar_(\w+) cvar_string("\1")$/)
+               {
+                       found $1, 'cvar_string', "", 2;
+                       next;
+               }
+               while(/\bcvar\s*\(\s*"(\w+)"\s*\)/g)
+               {
+                       found $1, 'cvar', 0, 0;
+               }
+               while(/\bcvar_string\s*\(\s*"(\w+)"\s*\)/g)
+               {
+                       found $1, 'cvar_string', "", 0;
+               }
+               while(/\bcvar_vector\s*\(\s*"(\w+)"\s*\)/g)
+               {
+                       found $1, 'cvar_vector', "0 0 0", 0;
+               }
+               while(/\bcvar_or\s*\(\s*"(\w+)"\s*,\s*([^\s)]+)\s*\)/g)
+               {
+                       found $1, 'cvar', $2, 0;
+               }
+       }
+}
+
+if($ENV{AUTOCVARING_SVQC})
+{
+       for my $f(<menu/xonotic/*.c>)
+       {
+               print STDERR "In file $f\n";
+               open my $fh, "<", $f;
+               while(<$fh>)
+               {
+                       for(/"([^"]*)"/g)
+                       {
+                               $menu{$1} = 1;
+                       }
+               }
+       }
+
+       for my $f(<../maps/campaign*.txt>)
+       {
+               print STDERR "In file $f\n";
+               open my $fh, "<", $f;
+               while(<$fh>)
+               {
+                       for(/\b(.+?)\b/g)
+                       {
+                               $menu{$1} = 1;
+                       }
+               }
+       }
+}
+
+for my $name(sort keys %cvars)
+{
+       my $type = $cvars{$name};
+       my $menu = $menu{$name};
+       my $default = $defaults{$name};
+       die "wtf" if $name =~ /\0/;
+       if(not defined $type)
+       {
+               print "// cannot declare $name, it is used with different types\n";
+       }
+       elsif($type eq 'cvar_toolong')
+       {
+               print "// cannot declare $name, name is too long\n";
+       }
+       elsif($type eq 'cvar' and not $menu and $default eq "0")
+       {
+               print "float autocvar_$name;\n";
+       }
+       elsif($type eq 'cvar' and not $menu and $default ne "0")
+       {
+               print "var float autocvar_$name = $default;\n";
+       }
+       elsif($type eq 'cvar_vector' and not $menu and $default eq "0 0 0")
+       {
+               print "vector autocvar_$name;\n";
+       }
+       elsif($type eq 'cvar_vector' and not $menu and $default ne "0 0 0")
+       {
+               print "var vector autocvar_$name = '$default';\n";
+       }
+       elsif($type eq 'cvar_string' and not $menu and $default eq "")
+       {
+               print "string autocvar_$name;\n";
+       }
+       elsif($type eq 'cvar_string' and not $menu and $default ne "")
+       {
+               print "var string autocvar_$name = \"$default\";\n";
+       }
+       elsif($type eq 'cvar' and $menu and $default eq "0")
+       {
+               print "#define autocvar_$name cvar(\"$name\")\n";
+       }
+       elsif($type eq 'cvar' and $menu and $default ne "0")
+       {
+               print "#define autocvar_$name cvar_or(\"$name\", \"$default\")\n";
+       }
+       elsif($type eq 'cvar_string' and $menu) # sorry, no cvar_or for these
+       {
+               print "#define autocvar_$name cvar_string(\"$name\")\n";
+       }
+       elsif($type eq 'cvar_vector' and $menu) # sorry, no cvar_or for these
+       {
+               print "#define autocvar_$name cvar_vector(\"$name\")\n";
+       }
+}
+
+for my $f(@files)
+{
+       print STDERR "In file $f\n";
+       open my $fh, "<", $f;
+       my $out = "";
+       while(<$fh>)
+       {
+               chomp;
+               if(/^\/\/#NO AUTOCVARS START/ .. /^\/\/#NO AUTOCVARS END/)
+               {
+                       $out .= "$_\n";
+                       next;
+               }
+               if(/^(?:var )?float autocvar_(.*);$/)
+               {
+                       $out .= "$_\n";
+                       next;
+               }
+               if(/^(?:var )?string autocvar_(.*);$/)
+               {
+                       $out .= "$_\n";
+                       next;
+               }
+               if(/^#define autocvar_(.*) cvar/)
+               {
+                       $out .= "$_\n";
+                       next;
+               }
+               s{\b(cvar|cvar_string|cvar_vector|cvar_or)\s*\(\s*"([^"]+)"\s*(?:,\s*[^\s)]+\s*)?\)}{
+                       my ($type, $name) = ($1, $2);
+                       $type = 'cvar' if $type eq 'cvar_or';
+                       my $realtype = $cvars{$name};
+                       my $r = $&;
+                       if(defined $realtype)
+                       {
+                               #$r = "$realtype(\"$name\")";
+                               $r = "autocvar_$name";
+                               if($type eq 'cvar' && $realtype eq 'cvar_string')
+                               {
+                                       $r = "stof($r)";
+                               }
+                               if($type eq 'cvar_string' && $realtype eq 'cvar')
+                               {
+                                       $r = "ftos($r)";
+                               }
+                       }
+                       $r;
+               }ge;
+               $out .= "$_\n";
+       }
+       close $fh;
+       open $fh, ">", $f;
+       print $fh $out;
+       close $fh;
+}
diff --git a/qcsrc/tools/compilationunits.sh b/qcsrc/tools/compilationunits.sh
new file mode 100755 (executable)
index 0000000..98ea3c6
--- /dev/null
@@ -0,0 +1,34 @@
+#!/bin/bash
+set -eu
+cd "$(dirname "$0")"
+cd ..
+
+declare -a NOWARN=(
+    -Wno-field-redeclared
+    -Wno-unused-variable
+    -Wno-implicit-function-pointer
+)
+declare QCC=../../../gmqcc/gmqcc
+
+declare -a QCC_FLAGS=(
+    -std=gmqcc
+    -Wall -Werror
+    -fftepp -fftepp-predefs -Wcpp
+    -futf8
+    -freturn-assignments
+    -frelaxed-switch
+    -Ooverlap-locals
+)
+
+function check() {
+    declare -l base="${1}"
+    declare -la predefs=("-D${2}" "lib/_all.inc" "${base}/_all.qh")
+    find "$base" -type f -name '*.qc' -print0 | sort -z | while read -r -d '' file; do
+        echo "$file"
+        ${QCC} "${QCC_FLAGS[@]}" "${NOWARN[@]}" "${predefs[@]}" "$file" >/dev/null
+    done
+}
+
+check client CSQC
+check server SVQC
+check menu MENUQC
diff --git a/qcsrc/tools/headerstyle.sh b/qcsrc/tools/headerstyle.sh
new file mode 100755 (executable)
index 0000000..ef17315
--- /dev/null
@@ -0,0 +1,35 @@
+#!/bin/bash
+set -eu
+cd "$(dirname "$0")"
+cd ..
+
+function startswith() {
+    declare -l file="${1}"
+    declare -l prelude="${2}"
+    declare -l line=$(head -n1 "$file")
+    if [ "$line" != "$prelude" ]; then
+        echo "$prelude" | cat - "$file" > "$file.tmp" && mv "$file.tmp" "$file"
+    fi
+}
+
+function check() {
+    declare -l base="${1}"
+    find "$base" -type f -name '*.qc' -print0 | sort -z | while read -r -d '' file; do
+        echo "$file"
+        declare -l file_h="${file%.qc}.qh"
+        if [ ! -f "$file_h" ]; then echo "#pragma once" > "$file_h"; fi
+
+        include=$(basename "$file")
+        include="${include%.qc}.qh"
+        include="#include \"${include}\""
+        startswith "$file" "$include"
+    done
+    find "$base" -type f -name '*.qh' -print0 | sort -z | while read -r -d '' file; do
+        echo "$file"
+        startswith "$file" "#pragma once"
+    done
+}
+
+check client
+check server
+check menu
diff --git a/qcsrc/tools/qcc.sh b/qcsrc/tools/qcc.sh
new file mode 100755 (executable)
index 0000000..b3ad199
--- /dev/null
@@ -0,0 +1,26 @@
+#!/bin/sh
+set -eu
+
+MODE=$1
+IN=$3
+OUT=$2
+
+QCC=${QCC}
+QCCIDENT="-DGMQCC"
+
+case ${MODE} in
+    client) PROG=CSQC
+    ;;
+    menu) PROG=MENUQC
+    ;;
+    server) PROG=SVQC
+    ;;
+esac
+
+CPP="${CPP} -I. ${QCCIDENT} ${QCCDEFS} -D${PROG}"
+${CPP} -MMD -MP -MT ${OUT} -Wall -Wundef -Werror -o ../.tmp/${MODE}.txt ${IN}
+${CPP} -dM 1>../.tmp/${MODE}_macros.txt -H 2>../.tmp/${MODE}_includes.txt ${IN}
+sed 's/^#\(line\)\? \([[:digit:]]\+\) "\(.*\)".*/\n#pragma file(\3)\n#pragma line(\2)/g' ../.tmp/${MODE}.txt > ../.tmp/${MODE}.qc
+cd ${MODE}
+echo $(basename ${QCC}) ${QCCFLAGS} -o ${OUT} ${MODE}.qc
+${QCC} ${QCCFLAGS} -o ${OUT} ../../.tmp/${MODE}.qc
diff --git a/qcsrc/tools/uncrusticracy.sh b/qcsrc/tools/uncrusticracy.sh
new file mode 100644 (file)
index 0000000..c71b6cd
--- /dev/null
@@ -0,0 +1,173 @@
+FILES=`find client common menu server warpzonelib -name \*.c -o -name \*.h -o -name \*.qc -o -name \*.qh`
+out_raw()
+{
+       printf "%s\n" "$LINE"
+}
+out()
+{
+       printf "%-40s = %-8s # %s\n" "$KEY" "$VAL" "$COMMENT"
+}
+decide()
+{
+       verybestchoice=
+       verybestscore=2147483647
+       bestchoice=
+       bestscore=2147483647
+       secondbestchoice=
+       secondbestscore=2147483647
+       worstscore=0
+       haveignore=false
+       havefalse=false
+       have0=false
+       seen=
+       for choice in "$VAL" "$@"; do
+               case " $seen " in
+                       *" $choice "*)
+                               continue
+                               ;;
+                       *)
+                               seen=$seen" $VAL"
+                               ;;
+               esac
+               if [ x"$choice" = x"force" ]; then
+                       continue
+               fi
+               if [ x"$choice" = x"ignore" ]; then
+                       haveignore=true
+               fi
+               if [ x"$choice" = x"false" ]; then
+                       havefalse=true
+               fi
+               if [ x"$choice" = x"0" ]; then
+                       have0=true
+               fi
+               if [ x"$MODE" = x"initialize" ]; then
+                       if [ x"$choice" = x"ignore" ]; then
+                               score=0
+                       else
+                               score=2147483647
+                       fi
+               else
+                       {
+                               cat uncrustify.cfg
+                               printf "%s = %s\n" "$KEY" "$choice"
+                       } > uncrustify.cfg.test
+                       UNCRUSTIFY_CONFIG=uncrustify.cfg.test sh uncrustify.sh $FILES >/dev/null 2>&1
+                       status=$?
+                       if [ $status -gt 1 ]; then
+                               echo "# ERROR: $KEY = $choice crashes with status $status."
+                               continue
+                       fi
+                       score=0
+                       git diff --numstat > diffstat.tmp
+                       while read -r add del rest; do
+                               if [ x"$add" != x"-" ]; then
+                                       score=$(($score + $add))
+                               fi
+                               if [ x"$del" != x"-" ]; then
+                                       score=$(($score + $del))
+                               fi
+                       done < diffstat.tmp
+                       git reset --hard >/dev/null 2>&1
+               fi
+               echo >&2 "$KEY = $choice: $score"
+               if [ x"$choice" != x"ignore" ]; then
+                       if [ $score -lt $bestscore ]; then
+                               secondbestscore=$bestscore
+                               secondbestchoice=$bestchoice
+                               bestscore=$score
+                               bestchoice=$choice
+                       elif [ $score -lt $secondbestscore ]; then
+                               secondbestscore=$score
+                               secondbestchoice=$choice
+                       fi
+               fi
+               if [ $score -lt $verybestscore ]; then
+                       verybestscore=$score
+                       verybestchoice=$choice
+               fi
+               if [ $score -gt $worstscore ]; then
+                       worstscore=$score
+                       worstchoice=$choice
+               fi
+       done
+       if [ -z "$bestchoice" ]; then
+               echo "# WARNING: No best choice identified"
+       elif [ $verybestscore -ge $worstscore ]; then
+               echo "# WARNING: Code doesn't seem to use this feature - delete from the config?"
+               if $haveignore; then
+                       VAL=ignore
+               elif $havefalse; then
+                       VAL=false
+               elif $have0; then
+                       VAL=0
+               fi
+       elif [ $bestscore -ge $worstscore ]; then
+               echo "# WARNING: Indifferent... please decide manually."
+       elif [ $bestscore -ge $secondbestscore ]; then
+               echo "# WARNING: Best is not unique ($bestchoice $secondbestchoice)"
+       elif [ $bestscore -gt $verybestscore ]; then
+               echo "# NOTE: is $(($bestscore - $verybestscore)) worse than $verybestchoice"
+               VAL=$bestchoice
+       else
+               VAL=$bestchoice
+       fi
+}
+while read -r LINE; do
+       case "$LINE" in
+               "# NOTE: "*)
+                       continue
+                       ;;
+               "# WARNING: "*)
+                       continue
+                       ;;
+               "# ERROR: "*)
+                       continue
+                       ;;
+               "#"*)
+                       out_raw
+                       continue
+                       ;;
+               *"#force"*|*"#ignore"*)
+                       out_raw
+                       continue
+                       ;;
+       esac
+       printf "%s\n" "$LINE" | while read KEY EQ VAL DELIM COMMENT; do
+               if \
+                       [ x"$EQ" != x"=" ] || \
+                       [ x"$DELIM" != x"#" ]; then
+                       out_raw
+                       continue
+               fi
+               case "$COMMENT" in
+                       number)
+                               case "$KEY" in
+                                       indent_columns|*tab*)
+                                               decide 1 2 4 8
+                                               ;;
+                                       *)
+                                               decide 0 1 2 3 indent_columns
+                                               ;;
+                               esac
+                               out
+                               ;;
+                       string)
+                               printf "# WARNING: unsupported %s\n" "$COMMENT"
+                               out_raw
+                               ;;
+                       *[!a-z/_]*)
+                               printf "# ERROR: invalid characters %s\n" "$COMMENT"
+                               out_raw
+                               ;;
+                       */*)
+                               decide `echo "$COMMENT" | tr / ' '`
+                               out
+                               ;;
+                       *)
+                               printf "# ERROR: only once choice %s\n" "$COMMENT"
+                               out_raw
+                               ;;
+               esac
+       done
+done < uncrustify.cfg
diff --git a/qcsrc/tools/uncrustify.sh b/qcsrc/tools/uncrustify.sh
new file mode 100755 (executable)
index 0000000..b36953e
--- /dev/null
@@ -0,0 +1,22 @@
+fix_function_types() {
+       # Uncrustify handles QC function types (example:
+       #  void(void) func;
+       # ) wrong and removes the space between type and variable. Fix this by
+       # a simple sed on ")letter" which should normally not occur.
+       sed -e 's/)\([A-Za-z_]\)/) \1/g' "$@"
+}
+
+if [ -z "$UNCRUSTIFY_CONFIG" ]; then
+       UNCRUSTIFY_CONFIG=`git rev-parse --show-toplevel`/qcsrc/uncrustify.cfg
+fi
+
+case "$#" in
+       0)
+               uncrustify --frag -c "$UNCRUSTIFY_CONFIG" |\
+               fix_function_types
+               ;;
+       *)
+               uncrustify --replace --no-backup -c "$UNCRUSTIFY_CONFIG" "$@" ;\
+               fix_function_types -i "$@"
+               ;;
+esac
diff --git a/qcsrc/tools/whitespace.sh b/qcsrc/tools/whitespace.sh
new file mode 100755 (executable)
index 0000000..5662337
--- /dev/null
@@ -0,0 +1,19 @@
+#!/bin/bash
+set -eu
+cd "$(dirname "$0")"
+cd ..
+
+function check() {
+    declare -l base="${1}"
+    find "$base" -type f -print0 | sort -z | xargs -0 sed -i \
+        `# strip trailing spaces`                            \
+        -e 's/[[:space:]]*$//'                               \
+        `# line feed at EOF for #include to work properly`   \
+        -e '$a\'
+}
+
+check lib
+check common
+check client
+check server
+check menu
diff --git a/qcsrc/uncrusticracy.sh b/qcsrc/uncrusticracy.sh
deleted file mode 100644 (file)
index c71b6cd..0000000
+++ /dev/null
@@ -1,173 +0,0 @@
-FILES=`find client common menu server warpzonelib -name \*.c -o -name \*.h -o -name \*.qc -o -name \*.qh`
-out_raw()
-{
-       printf "%s\n" "$LINE"
-}
-out()
-{
-       printf "%-40s = %-8s # %s\n" "$KEY" "$VAL" "$COMMENT"
-}
-decide()
-{
-       verybestchoice=
-       verybestscore=2147483647
-       bestchoice=
-       bestscore=2147483647
-       secondbestchoice=
-       secondbestscore=2147483647
-       worstscore=0
-       haveignore=false
-       havefalse=false
-       have0=false
-       seen=
-       for choice in "$VAL" "$@"; do
-               case " $seen " in
-                       *" $choice "*)
-                               continue
-                               ;;
-                       *)
-                               seen=$seen" $VAL"
-                               ;;
-               esac
-               if [ x"$choice" = x"force" ]; then
-                       continue
-               fi
-               if [ x"$choice" = x"ignore" ]; then
-                       haveignore=true
-               fi
-               if [ x"$choice" = x"false" ]; then
-                       havefalse=true
-               fi
-               if [ x"$choice" = x"0" ]; then
-                       have0=true
-               fi
-               if [ x"$MODE" = x"initialize" ]; then
-                       if [ x"$choice" = x"ignore" ]; then
-                               score=0
-                       else
-                               score=2147483647
-                       fi
-               else
-                       {
-                               cat uncrustify.cfg
-                               printf "%s = %s\n" "$KEY" "$choice"
-                       } > uncrustify.cfg.test
-                       UNCRUSTIFY_CONFIG=uncrustify.cfg.test sh uncrustify.sh $FILES >/dev/null 2>&1
-                       status=$?
-                       if [ $status -gt 1 ]; then
-                               echo "# ERROR: $KEY = $choice crashes with status $status."
-                               continue
-                       fi
-                       score=0
-                       git diff --numstat > diffstat.tmp
-                       while read -r add del rest; do
-                               if [ x"$add" != x"-" ]; then
-                                       score=$(($score + $add))
-                               fi
-                               if [ x"$del" != x"-" ]; then
-                                       score=$(($score + $del))
-                               fi
-                       done < diffstat.tmp
-                       git reset --hard >/dev/null 2>&1
-               fi
-               echo >&2 "$KEY = $choice: $score"
-               if [ x"$choice" != x"ignore" ]; then
-                       if [ $score -lt $bestscore ]; then
-                               secondbestscore=$bestscore
-                               secondbestchoice=$bestchoice
-                               bestscore=$score
-                               bestchoice=$choice
-                       elif [ $score -lt $secondbestscore ]; then
-                               secondbestscore=$score
-                               secondbestchoice=$choice
-                       fi
-               fi
-               if [ $score -lt $verybestscore ]; then
-                       verybestscore=$score
-                       verybestchoice=$choice
-               fi
-               if [ $score -gt $worstscore ]; then
-                       worstscore=$score
-                       worstchoice=$choice
-               fi
-       done
-       if [ -z "$bestchoice" ]; then
-               echo "# WARNING: No best choice identified"
-       elif [ $verybestscore -ge $worstscore ]; then
-               echo "# WARNING: Code doesn't seem to use this feature - delete from the config?"
-               if $haveignore; then
-                       VAL=ignore
-               elif $havefalse; then
-                       VAL=false
-               elif $have0; then
-                       VAL=0
-               fi
-       elif [ $bestscore -ge $worstscore ]; then
-               echo "# WARNING: Indifferent... please decide manually."
-       elif [ $bestscore -ge $secondbestscore ]; then
-               echo "# WARNING: Best is not unique ($bestchoice $secondbestchoice)"
-       elif [ $bestscore -gt $verybestscore ]; then
-               echo "# NOTE: is $(($bestscore - $verybestscore)) worse than $verybestchoice"
-               VAL=$bestchoice
-       else
-               VAL=$bestchoice
-       fi
-}
-while read -r LINE; do
-       case "$LINE" in
-               "# NOTE: "*)
-                       continue
-                       ;;
-               "# WARNING: "*)
-                       continue
-                       ;;
-               "# ERROR: "*)
-                       continue
-                       ;;
-               "#"*)
-                       out_raw
-                       continue
-                       ;;
-               *"#force"*|*"#ignore"*)
-                       out_raw
-                       continue
-                       ;;
-       esac
-       printf "%s\n" "$LINE" | while read KEY EQ VAL DELIM COMMENT; do
-               if \
-                       [ x"$EQ" != x"=" ] || \
-                       [ x"$DELIM" != x"#" ]; then
-                       out_raw
-                       continue
-               fi
-               case "$COMMENT" in
-                       number)
-                               case "$KEY" in
-                                       indent_columns|*tab*)
-                                               decide 1 2 4 8
-                                               ;;
-                                       *)
-                                               decide 0 1 2 3 indent_columns
-                                               ;;
-                               esac
-                               out
-                               ;;
-                       string)
-                               printf "# WARNING: unsupported %s\n" "$COMMENT"
-                               out_raw
-                               ;;
-                       *[!a-z/_]*)
-                               printf "# ERROR: invalid characters %s\n" "$COMMENT"
-                               out_raw
-                               ;;
-                       */*)
-                               decide `echo "$COMMENT" | tr / ' '`
-                               out
-                               ;;
-                       *)
-                               printf "# ERROR: only once choice %s\n" "$COMMENT"
-                               out_raw
-                               ;;
-               esac
-       done
-done < uncrustify.cfg
diff --git a/qcsrc/uncrustify.sh b/qcsrc/uncrustify.sh
deleted file mode 100755 (executable)
index b36953e..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-fix_function_types() {
-       # Uncrustify handles QC function types (example:
-       #  void(void) func;
-       # ) wrong and removes the space between type and variable. Fix this by
-       # a simple sed on ")letter" which should normally not occur.
-       sed -e 's/)\([A-Za-z_]\)/) \1/g' "$@"
-}
-
-if [ -z "$UNCRUSTIFY_CONFIG" ]; then
-       UNCRUSTIFY_CONFIG=`git rev-parse --show-toplevel`/qcsrc/uncrustify.cfg
-fi
-
-case "$#" in
-       0)
-               uncrustify --frag -c "$UNCRUSTIFY_CONFIG" |\
-               fix_function_types
-               ;;
-       *)
-               uncrustify --replace --no-backup -c "$UNCRUSTIFY_CONFIG" "$@" ;\
-               fix_function_types -i "$@"
-               ;;
-esac
diff --git a/qcsrc/whitespace.sh b/qcsrc/whitespace.sh
deleted file mode 100755 (executable)
index ba16fd7..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-#!/usr/bin/env bash
-cd ${0%[\\/]*}
-find . -name .git -prune -o -type f -print0 |               \
-    xargs -0 sed -i                                         \
-        `# strip trailing spaces`                           \
-        -e 's/[[:space:]]*$//'                              \
-        `# line feed at EOF for #include to work properly`  \
-        -e '$a\'