+ 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
+ case "$1" in
+ ## RULE: textures/FOOx/BAR-BAZ must use textures/FOOx/*/*, recommended textures/FOOx/BAR/BAZ
+ textures/*x/*-*)
+ pre=${1%%x/*}x
+ suf=${1#*x/}
+ suf="`echo "$suf" | sed 's,-,/,g'`"
+ case "$2" in
+ "$pre"/*/*)
+ ;;
+ *)
+ err "texture $2 of shader $1 is out of place, recommended file name is $pre/$suf"
+ ;;
+ esac
+ ;;
+ ## RULE: textures/FOOx/BAR must use textures/FOOx/*/*, recommended textures/FOOx/base/BAR
+ textures/*x/*)
+ pre=${1%%x/*}x
+ suf=${1#*x/}
+ case "$2" in
+ "$pre"/*/*)
+ ;;
+ *)
+ err "texture $2 of shader $1 is out of place, recommended file name is $pre/base/$suf"
+ ;;
+ esac
+ ;;
+ ## RULE: textures/map_FOO[_/]* must use textures/map_FOO[_/]*
+ textures/map_*/*|models/map_*/*)
+ pre=${1%%/map_*}
+ suf=${1#*/map_}
+ map=${suf%%[_/]*}
+ case "$2" in
+ textures/map_$map[/_]*)
+ ;;
+ models/map_$map[/_]*)
+ ;;
+ textures/map_*|models/map_*)
+ # protect one map's textures from the evil of other maps :P
+ err "texture $2 of shader $1 is out of place, recommended file name is $pre/map_$map/*"
+ ;;
+ *)
+ # using outside stuff is permitted
+ ;;
+ esac
+ ;;
+ ## RULE: textures/common/FOO must use textures/common/FOO or textures/common/*/*
+ textures/common/*)
+ case "$2" in
+ "$1")
+ ;;
+ textures/common/*/*)
+ ;;
+ *)
+ err "texture $2 of shader $1 is out of place, recommended file name is $1 or textures/common/*/*"
+ ;;
+ esac
+ ;;
+ ## RULE: textures/FOO/* must use textures/FOO/*, for FOO in decals, liquids_water, liquids_slime, liquids_lava, alphamod, solarpanel
+ textures/decals/*|textures/liquids_*/*|textures/effects_*/*|textures/screens/*|textures/logos/*|textures/alphamod/*|textures/solarpanel/*)
+ pre=`echo "$1" | cut -d / -f 1-2`
+ case "$2" in
+ "$pre"/*)
+ # I _suppose_ this is fine, as tZork committed this pack
+ ;;
+ *)
+ err "texture $2 of shader $1 is out of place, recommended file name is $1"
+ ;;
+ esac
+ ;;
+ ## RULE: textures/skies/FOO or textures/skies/FOO_BAR must use textures/skies/FOO respective textures/skies/FOO_BAR as preview image, and env/FOO[_/]* as skybox
+ textures/skies/*)
+ sky=${1#textures/skies/}
+ sky=${sky%%_*}
+ case "$2" in
+ textures/skies/$sky|textures/skies/$sky[_]*)
+ # typical place for preview image
+ ;;
+ env/$sky[/_]*)
+ # typical place for skybox
+ ;;
+ *)
+ err "texture $2 of shader $1 is out of place, recommended file name is $1"
+ ;;
+ esac
+ ;;
+ ## RULE: models/* must use models/*
+ models/*)
+ case "$2" in
+ models/*)
+ ;;
+ *)
+ err "texture $2 of shader $1 is out of place, recommended file name is $1 or models/*"
+ ;;
+ esac
+ ;;
+ *)
+ err "no shader name pattern for $1"
+ ;;
+ esac