Less blurry crosshair ring
[voretournament/voretournament.git] / data / check-sounds.sh
1 #!/bin/sh\r
2 \r
3 allidentifiers=`grep "^         _VOICEMSG" qcsrc/server/defs.qh | sed "s/.*(//; s/).*//;"`\r
4 \r
5 allsounds=`find sound -name .svn -prune -o \( -name \*.ogg -o -name \*.wav \) -print`\r
6 for S in $allsounds; do\r
7         SND=${S#sound/}\r
8         SND=${SND%.*}\r
9         if [ -f "sound/$SND.ogg" ] && [ -f "sound/$SND.wav" ]; then\r
10                 echo "$SND exists twice"\r
11         fi\r
12         case "$SND" in\r
13                 player/*/*)\r
14                         # verified by .sounds file check\r
15                         ;;\r
16                 ambient/*)\r
17                         # maps can use them always\r
18                         ;;\r
19                 weather/*)\r
20                         # maps can use them always\r
21                         ;;\r
22                 cdtracks/*)\r
23                         # maps can use them always\r
24                         ;;\r
25                 misc/footstep*)\r
26                         ;;\r
27                 misc/metalfootstep*)\r
28                         ;;\r
29                 misc/hitground*)\r
30                         ;;\r
31                 misc/metalhitground*)\r
32                         ;;\r
33                 misc/talk*) # engine\r
34                         ;;\r
35                 *)\r
36                         if ! grep -Er '"'$SND'\.(ogg|wav)"' qcsrc/server >/dev/null; then\r
37                                 echo "$S ($SND) is unused by the code"\r
38                         fi\r
39                         ;;\r
40         esac\r
41 done\r
42 \r
43 LF="\r
44 "\r
45 allsounds="$LF`find sound/player -mindepth 2 -name .svn -prune -o \( -name \*.ogg -o -name \*.wav \) -print`$LF"\r
46 remainingsounds=$allsounds\r
47 psoundfile()\r
48 {\r
49         snd=$1\r
50         pat="$LF$snd$LF"\r
51         case "$allsounds" in\r
52                 *$pat*)\r
53                         case "$remainingsounds" in\r
54                                 *$pat*)\r
55                                         remainingsounds=${remainingsounds%%$pat*}$LF${remainingsounds#*$pat}\r
56                                         ;;\r
57                         esac\r
58                         return 0\r
59                         ;;\r
60                 *)\r
61                         return 1\r
62                         ;;\r
63         esac\r
64 }\r
65 psoundtry()\r
66 {\r
67         s=$1\r
68         psoundfile "$s.ogg" || psoundfile "$s.wav"\r
69 }\r
70 psound()\r
71 {\r
72         s=$1\r
73         if psoundtry "$s"; then\r
74                 :\r
75         else\r
76                 echo "$S references nonexisting sound $s"\r
77         fi\r
78 }\r
79 \r
80 for S in models/player/*.sounds sound/player/default.sounds; do\r
81         if [ "$S" = "sound/player/default.sounds" ] || [ -f "${S#.sounds}" ]; then\r
82                 {\r
83                         identifiers_seen=\r
84                         while read -r TITLE SOUND COUNT; do\r
85                                 case "$TITLE" in\r
86                                         //TAG*)\r
87                                                 ;;\r
88                                         //*)\r
89                                                 identifiers_seen="$identifiers_seen ${TITLE#//}"\r
90                                                 for X in $allidentifiers; do\r
91                                                         if [ "$X" = "${TITLE#//}" ]; then\r
92                                                                 good=true\r
93                                                         fi\r
94                                                 done\r
95                                                 if $good; then\r
96                                                         good=false\r
97                                                         case "$COUNT" in\r
98                                                                 0)\r
99                                                                         if psoundtry "$SOUND"; then\r
100                                                                                 good=false\r
101                                                                         fi\r
102                                                                         ;;\r
103                                                                 *)\r
104                                                                         for i in `seq 1 $COUNT`; do\r
105                                                                                 if psoundtry "$SOUND$i"; then\r
106                                                                                         good=true\r
107                                                                                 fi\r
108                                                                         done\r
109                                                                         ;;\r
110                                                         esac\r
111                                                         if $good; then\r
112                                                                 echo "$S references existing sound $SOUND but commented out"\r
113                                                         else\r
114                                                                 echo "$S does not have a sound for ${TITLE#//} yet"\r
115                                                         fi\r
116                                                 fi\r
117                                                 ;;\r
118                                         *)\r
119                                                 identifiers_seen="$identifiers_seen $TITLE"\r
120                                                 case "$COUNT" in\r
121                                                         0)\r
122                                                                 psound "$SOUND"\r
123                                                                 ;;\r
124                                                         *)\r
125                                                                 for i in `seq 1 $COUNT`; do\r
126                                                                         psound "$SOUND$i"\r
127                                                                 done\r
128                                                                 ;;\r
129                                                 esac\r
130 \r
131                                                 ;;\r
132                                 esac\r
133                         done\r
134                         missing=`\r
135                                 {\r
136                                         for X in $identifiers_seen; do\r
137                                                 echo "$X"\r
138                                                 echo "$X"\r
139                                         done\r
140                                         for X in $allidentifiers; do\r
141                                                 echo "$X"\r
142                                         done\r
143                                 } | sort | uniq -u\r
144                         `\r
145                         invalid=`\r
146                                 {\r
147                                         for X in $identifiers_seen; do\r
148                                                 echo "$X"\r
149                                         done\r
150                                         for X in $allidentifiers; do\r
151                                                 echo "$X"\r
152                                                 echo "$X"\r
153                                         done\r
154                                 } | sort | uniq -u\r
155                         `\r
156                         [ -z "$invalid" ] || echo "$S specifies invalid sound identifiers `echo $invalid`"\r
157                         [ -z "$missing" ] || echo "$S lacks sound identifiers `echo $missing`"\r
158                 } < "$S"\r
159         else\r
160                 echo "$S exists for nonexisting player model"\r
161         fi\r
162 done\r
163 for S in $remainingsounds; do\r
164         echo "$S is not used by any player model"\r
165 done\r
166 \r
167 # tag check\r
168 for S in models/player/*.sounds; do echo -n `head -n 1 "$S"`"  "; md5sum "$S"; done | sort\r