+ if [ x"$3" = x"map" ]; then
+ lasttex=$2
+ if [ -n "$AUDIT_ALPHACHANNELS" ] && [ x"$offsetmapping_match8" != x"firststagedone" ]; then
+ if [ -f "../${2}_norm.tga" ] || [ -f "../${2}_norm.png" ] || [ -f "../${2}_norm.jpg" ]; then
+ case "$offsetmapping_match8" in
+ '') # no dpoffsetmapping keyword
+ getstats "../${2}_norm.tga" || getstats "../${2}_norm.png" || getstats "../${2}_norm.jpg"
+ if [ "$min" -eq "$max" ]; then
+ warn "$1 uses broken normalmap ${2}_norm.tga (add dpoffsetmapping none)"
+ else
+ err "$1 uses ${2}_norm.tga but lacks median (add dpoffsetmapping - 1 match8 $median)"
+ fi
+ ;;
+ none) # offsetmapping turned off explicitly
+ ;;
+ default) # offsetmapping keyword without bias
+ getstats "../${2}_norm.tga"
+ if [ "$min" -eq "$max" ]; then
+ warn "$1 uses broken normalmap ${2}_norm.tga, maybe use dpoffsetmapping none?"
+ else
+ err "$1 uses ${2}_norm.tga but lacks median (add to dpoffsetmapping: match8 $median)"
+ fi
+ ;;
+ *) # offsetmapping keyword with bias
+ ;;
+ esac
+ else
+ if [ -n "$offsetmapping_match8" ]; then
+ warn "$1 specifies offsetmapping, but texture $2 does not have a normalmap"
+ fi
+ fi
+ fi
+ fi
+
+ if [ -n "$allowed_prefixes" ]; then
+ ok=false
+ for p in $allowed_prefixes; do
+ case "$1:" in
+ "$p"*)
+ ok=true
+ ;;
+ esac
+ done
+ else
+ ok=true
+ fi
+ for p in $forbidden_prefixes; do
+ case "$1:" in
+ "$p"*)
+ ok=false
+ ;;
+ esac
+ done
+ if ! $ok; then
+ err "$1 is not allowed in this shader file (allowed: $allowed_prefixes, forbidden: $forbidden_prefixes)"
+ fi
+
+ case "$3" in
+ ## RULE: skyboxes must lie in env/
+ sky)
+ case "$2" in
+ env/*)
+ ;;
+ *)
+ err "texture $2 of shader $1 is out of place, $3 textures must be in env/"
+ ;;
+ esac
+ ;;
+ ## RULE: non-skyboxes must not lie in env/
+ *)
+ case "$2" in
+ env/*)
+ err "texture $2 of shader $1 is out of place, $3 textures must not be in env/"
+ ;;
+ *)
+ ;;
+ esac
+ ;;
+ esac
+
+ # verify shader -> texture name