From ba73bc70ad2e0cad719cffc6875e4199e8b7223c Mon Sep 17 00:00:00 2001 From: otta8634 Date: Sat, 1 Mar 2025 19:09:08 +0800 Subject: [PATCH] Update check-cvars.sh to only disallow changing extra settings in custom balance files Now custom balance files like balance-overkill.cfg don't have to change every single cvar balance-xonotic.cfg does, so that the same defaults don't need to repeated for every single balance file. The only requirement now is that balance-overkill.cfg can't set any cvars which aren't also set in balance-xonotic.cfg. This doesn't apply to the hud cfg files, since they're compared against _hud_descriptions.cfg, which doesn't set defaults, so they must do it themselves. Changes weren't made to the cfg files in question yet. --- check-cvars.sh | 59 ++++++++++++++++++++++++++++++++------------------ 1 file changed, 38 insertions(+), 21 deletions(-) diff --git a/check-cvars.sh b/check-cvars.sh index 387d93720..a14ad2056 100755 --- a/check-cvars.sh +++ b/check-cvars.sh @@ -4,36 +4,53 @@ errord=false check_files() { - countw=`awk ''"$3"' { print $2; }' "$1" | sort -u | tr -d '\r' | git hash-object --stdin | cut -c 1-32` - for b in $2; do - if [ "$b" = "balance-testing.cfg" ] || [ "$b" = "balance-testingxpm.cfg" ]; then + for b in $2 + do + if [ "$b" = "balance-testing.cfg" ] || [ "$b" = "balance-testingxpm.cfg" ] + then continue fi - countb=`awk ''"$3"' { print $2; }' "$b" | sort -u | tr -d '\r' | git hash-object --stdin | cut -c 1-32` - if [ "$countw" != "$countb" ]; then - echo "Mismatch between $1 and $b. Aborting." - echo "Differences are:" - echo "< missing in $b" - echo "> must get removed from $b" - A=`mktemp || echo a.tmp` - B=`mktemp || echo b.tmp` - awk ''"$3"' { print $2; }' "$1" | sort -u | tr -d '\r' > "$A" - awk ''"$3"' { print $2; }' "$b" | sort -u | tr -d '\r' > "$B" - diff "$A" "$B" | grep '^[<>]' | sort - rm -f "$A" "$B" + A=`mktemp || echo a.tmp` + B=`mktemp || echo b.tmp` + awk ''"$3"' { print $2; }' "$1" | sort -u | tr -d '\r' > "$A" + awk ''"$3"' { print $2; }' "$b" | sort -u | tr -d '\r' > "$B" + extra="" + if $4 + then + extra="$(diff "$A" "$B" | grep '^>' | sort)" + # only extract cvars that are in $b but not $1 + # $b is allowed to override $1, but not change anything else + else + extra="$(diff "$A" "$B" | grep '^[<>]' | sort)" + fi + if [ "$extra" != "" ] + then + echo "Cvar mismatch between $1 and $b. Aborting." + if $4 + then + echo "The following are missing from $1, so must be either added to $1 or more likely removed from $b:" + else + echo "Differences are:" + echo "< missing in $b" + echo "> must be removed from $b" + fi + echo "$extra" errord=true fi + rm -f "$A" "$B" done } -check_files "balance-xonotic.cfg" "balance-*.cfg" "/^seta? g_/" -check_files "bal-wep-xonotic.cfg" "bal-wep-*.cfg" "/^seta? g_/" -check_files "_hud_descriptions.cfg" "hud_*.cfg" "/^seta? hud_/" +check_files "balance-xonotic.cfg" "balance-*.cfg" "/^seta? +g_/" true +check_files "bal-wep-xonotic.cfg" "bal-wep-*.cfg" "/^seta? +g_/" true +check_files "_hud_descriptions.cfg" "hud_*.cfg" "/^seta? +hud_/" false -if $errord; then - if [ "$CMAKE" != "" ]; then - exit 1 +if $errord +then + if [ "$CMAKE" != "" ] + then + exit 1 fi echo "Please wait for 30 seconds, so you have had enough time to read this..." sleep 30 -- 2.39.5