]> git.xonotic.org Git - xonotic/xonotic.git/blobdiff - misc/tools/cached-converter.sh
make tuba bots turn a little while playing
[xonotic/xonotic.git] / misc / tools / cached-converter.sh
index 8ce189c47bbbf295ba40fb88de008c1e70153c18..aa4089c1273e42f1db5efa84ac899883a72bf2b1 100755 (executable)
@@ -66,14 +66,44 @@ use_magnet_to_acquire_checksum_faster()
        if [ -n "$magnet" ]; then
                magnet=${magnet#* }
                magnet=${magnet%% *}
-               sum=$sum$magnet
+               echo "$magnet"
        else
-               sum=$sum`git hash-object "$1"`
+               git hash-object "$1"
        fi
 }
 
 lastinfiles=
 lastinfileshash=
+acquire_checksum()
+{
+       if [ x"$1/../$2" = x"$lastinfiles" ]; then
+               _a_s=$lastinfileshash
+       else
+               _a_e=false
+               for _a_f in "$1" "$2"; do
+                       case "$_a_f" in
+                               */background_l2.tga|*/background_ingame_l2.tga)
+                                       _a_e=true
+                                       ;;
+                       esac
+               done
+               if [ -n "$git_src_repo" ] && ! $_a_e; then
+                       _a_s=`use_magnet_to_acquire_checksum_faster "${1#./}"`
+                       if [ -n "$2" ]; then
+                               _a_s=$_a_s`use_magnet_to_acquire_checksum_faster "${2#./}"`
+                       fi
+               else
+                       _a_s=`git hash-object "$1"`
+                       if [ -n "$2" ]; then
+                               _a_s=$_a_s`git hash-object "$2"`
+                       fi
+               fi
+               lastinfileshash=$_a_s
+               lastinfiles="$1/../$2"
+       fi
+       echo "$_a_s"
+}
+
 cached()
 {
        flag=$1; shift
@@ -91,31 +121,7 @@ cached()
        fi
        options=`echo "$*" | git hash-object --stdin`
        selfprofile convert_findchecksum
-       if [ x"$infile1/../$infile2" = x"$lastinfiles" ]; then
-               sum=$lastinfileshash
-       else
-               evil=false
-               for infile in "$infile1" "$infile2"; do
-                       case "$infile" in
-                               */background_l2.tga|*/background_ingame_l2.tga)
-                                       evil=true
-                                       ;;
-                       esac
-               done
-               if [ -n "$git_src_repo" ] && ! $evil; then
-                       sum=
-                       use_magnet_to_acquire_checksum_faster "${infile1#./}"
-                       if [ -n "$infile2" ]; then
-                               use_magnet_to_acquire_checksum_faster "${infile2#./}"
-                       fi
-               else
-                       sum=`git hash-object "$infile1"`
-                       if [ -n "$infile2" ]; then
-                               sum=$sum`git hash-object "$infile2"`
-                       fi
-               fi
-               lastinfileshash=$sum
-       fi
+       sum=`acquire_checksum "$infile1" "$infile2"`
        selfprofile convert_makecachedir
        mkdir -p "$CACHEDIR/$method-$options"
        name1="$CACHEDIR/$method-$options/$sum-1.${outfile1##*.}"