14 echo "$1" | sed 's/\.\(tga\|jpg\|png\)$//'
23 # $3 = shader | map | animmap | editorimage | sky
28 [ -f "../$2.tga" ] || \
29 [ -f "../$2.jpg" ] || \
30 [ -f "../$2.png" ]; then
33 if [ "$3" = "shader" ]; then
36 echo "(EE) shader $1 uses non-existing texture $2"
39 textures_used="$textures_used$LF$2"
41 if [ -n "$allowed_prefixes" ]; then
43 for p in $allowed_prefixes; do
53 for p in $forbidden_prefixes; do
61 echo "(EE) shader $1 is not allowed in this shader file (allowed: $allowed_prefixes, forbidden: $forbidden_prefixes)"
65 ## RULE: skyboxes must lie in env/
71 echo "(EE) texture $2 of shader $1 is out of place, $3 textures must be in env/"
75 ## RULE: non-skyboxes must not lie in env/
79 echo "(EE) texture $2 of shader $1 is out of place, $3 textures must not be in env/"
87 # verify shader -> texture name
89 ## RULE: textures/FOOx/BAR-BAZ must use textures/FOOx/*/*, recommended textures/FOOx/BAR/BAZ
93 suf="`echo "$suf" | sed 's,-,/,g'`"
98 echo "(EE) texture $2 of shader $1 is out of place, recommended file name is $pre/$suf"
102 ## RULE: textures/FOOx/BAR must use textures/FOOx/*/*, recommended textures/FOOx/base/BAR
110 echo "(EE) texture $2 of shader $1 is out of place, recommended file name is $pre/base/$suf"
114 ## RULE: textures/map_FOO[_/]* must use textures/map_FOO[_/]*
120 "$pre"/map_$map[/_]*)
123 # protect one map's textures from the evil of other maps :P
124 echo "(EE) texture $2 of shader $1 is out of place, recommended file name is $pre/map_$map/*"
127 # using outside stuff is permitted
131 ## RULE: textures/common/FOO must use textures/common/FOO or textures/common/*/*
139 echo "(EE) texture $2 of shader $1 is out of place, recommended file name is $1 or textures/common/*/*"
143 ## RULE: textures/FOO/* must use textures/FOO/*, for FOO in decals, liquids_water, liquids_slime, liquids_lava, warpzone
144 textures/decals/*|textures/liquids_water/*|textures/liquids_slime/*|textures/liquids_lava/*|textures/warpzone/*)
148 # I _suppose_ this is fine, as tZork committed this pack
151 echo "(EE) texture $2 of shader $1 is out of place, recommended file name is $1"
155 ## 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
157 sky=${1#textures/skies/}
160 textures/skies/$sky|textures/skies/$sky[_]*)
161 # typical place for preview image
164 # typical place for skybox
167 echo "(EE) texture $2 of shader $1 is out of place, recommended file name is $1"
171 ## RULE: models/* must use models/*
177 echo "(EE) texture $2 of shader $1 is out of place, recommended file name is $1 or models/*"
182 echo "(EE) no shader name pattern for $1"
190 while read L A1 Aother; do
197 use_texture "$parsing_shader" "`normalize "$A1"`" map
203 use_texture "$parsing_shader" "`normalize "$X"`" animmap
217 use_texture "$parsing_shader" "$parsing_shader" shader
218 while read L A1 Aother; do
221 use_texture "$parsing_shader" "`normalize "$A1"`" editorimage
224 use_texture "$parsing_shader" "${A1}_lf" sky
225 use_texture "$parsing_shader" "${A1}_rt" sky
226 use_texture "$parsing_shader" "${A1}_up" sky
227 use_texture "$parsing_shader" "${A1}_dn" sky
228 use_texture "$parsing_shader" "${A1}_ft" sky
229 use_texture "$parsing_shader" "${A1}_bk" sky
246 ## RULE: map_FOO.shader may define tetxures/map_FOO_* and textures/map_FOO/*
248 allowed_prefixes="textures/map_`echo "$1" | cut -d _ -f 2`_ textures/map_`echo "$1" | cut -d _ -f 2`/"
251 ## RULE: skies_FOO.shader may define tetxures/skies/FOO and textures/skies/FOO_*
253 allowed_prefixes="textures/skies/`echo "$1" | cut -d _ -f 2`: textures/skies/`echo "$1" | cut -d _ -f 2`_"
256 ## RULE: model_*.shader may define models/*
258 allowed_prefixes="models/"
261 ## RULE: any other FOO.shader may define textures/FOO/*
263 allowed_prefixes="textures/$1/"
264 forbidden_prefixes="textures/skies/ textures/map_ models/"
270 parsing_shader="`normalize "$L"`"
271 if [ x"$L" != x"$parsing_shader" ]; then
272 echo "(WW) normalized shader name $L to $parsing_shader"
286 sed 's,//.*,,g; s,\r, ,g; s,\t, ,g; s, *, ,g; s, $,,; s,^ ,,; /^$/ d'
290 t=`mktemp || echo ".temp"`
291 for X in *.shader; do
292 strip_comments < "$X" > "$t"
293 parse_shaderfile "${X%.shader}" < "$t"
297 textures_avail=`( cd ..; find textures/ -type f -not -name '*_norm.*' -not -name '*_glow.*' -not -name '*_gloss.*' -not -name '*_reflect.*' -not -name '*.xcf' ) | while IFS= read -r T; do normalize "$T"; done | sort -u`
298 textures_used=`echo "${textures_used#$LF}" | sort -u`
300 echo "$textures_used$LF$textures_used$LF$textures_avail" | sort | uniq -u | while IFS= read -r L; do
307 echo "(EE) texture $L is not referenced by any shader"
313 while IFS= read -r STATUS TEXT; do