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