]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/tools/headerstyle.sh
Optimize vehicle impact code by only calling vlen() if damage would be taken
[xonotic/xonotic-data.pk3dir.git] / qcsrc / tools / headerstyle.sh
index b638927bf4a50441d0adef391b4f48101337cef6..795a32e6ddc7d8a302f755a322dca99bc308aa2a 100755 (executable)
@@ -1,8 +1,10 @@
-#!/bin/bash
+#!/usr/bin/env bash
 set -eu
-cd "$(dirname "$0")"
+cd ${0%/*}
 cd ..
 
+VERBOSE=${VERBOSE:-1}
+
 function startswith() {
     declare -l file="${1}"
     declare -l prelude="${2}"
@@ -15,9 +17,9 @@ function startswith() {
 function check() {
     declare -l base="${1}"
     find "$base" -type f -name '*.qc' -print0 | sort -z | while read -r -d '' file; do
-        echo "$file"
+        [ "$VERBOSE" != "0" ] && echo "$file"
         declare -l file_h="${file%.qc}.qh"
-        if [ ! -f "$file_h" ]; then echo "#pragma once" > "$file_h"; fi
+        if [[ ! -f "$file_h" ]]; then echo "#pragma once" > "$file_h"; fi
 
         include=$(basename "$file")
         include="${include%.qc}.qh"
@@ -25,7 +27,7 @@ function check() {
         startswith "$file" "$include"
     done
     find "$base" -type f -name '*.qh' -a \! -name '_mod.qh' -print0 | sort -z | while read -r -d '' file; do
-        echo "$file"
+        [ "$VERBOSE" != "0" ] && echo "$file"
         startswith "$file" "#pragma once"
     done
 }
@@ -33,3 +35,4 @@ function check() {
 check client
 check server
 check menu
+check common