$(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
+++ /dev/null
-#!/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
+++ /dev/null
-#!/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;
-}
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);
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)
+++ /dev/null
-#!/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
+++ /dev/null
-#!/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
+++ /dev/null
-#!/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
--- /dev/null
+#!/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
--- /dev/null
+#!/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;
+}
--- /dev/null
+#!/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
--- /dev/null
+#!/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
--- /dev/null
+#!/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
--- /dev/null
+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
--- /dev/null
+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
--- /dev/null
+#!/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
+++ /dev/null
-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
+++ /dev/null
-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
+++ /dev/null
-#!/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\'