]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - check-sounds.sh
Merge remote branch 'origin/morphed/hpitems'
[xonotic/xonotic-data.pk3dir.git] / 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                                                 for X in $allidentifiers; do
91                                                         if [ "$X" = "${TITLE#//}" ]; then
92                                                                 good=true
93                                                         fi
94                                                 done
95                                                 if $good; then
96                                                         good=false
97                                                         case "$COUNT" in
98                                                                 0)
99                                                                         if psoundtry "$SOUND"; then
100                                                                                 good=false
101                                                                         fi
102                                                                         ;;
103                                                                 *)
104                                                                         for i in `seq 1 $COUNT`; do
105                                                                                 if psoundtry "$SOUND$i"; then
106                                                                                         good=true
107                                                                                 fi
108                                                                         done
109                                                                         ;;
110                                                         esac
111                                                         if $good; then
112                                                                 echo "$S references existing sound $SOUND but commented out"
113                                                         else
114                                                                 echo "$S does not have a sound for ${TITLE#//} yet"
115                                                         fi
116                                                 fi
117                                                 ;;
118                                         *)
119                                                 identifiers_seen="$identifiers_seen $TITLE"
120                                                 case "$COUNT" in
121                                                         0)
122                                                                 psound "$SOUND"
123                                                                 ;;
124                                                         *)
125                                                                 for i in `seq 1 $COUNT`; do
126                                                                         psound "$SOUND$i"
127                                                                 done
128                                                                 ;;
129                                                 esac
130
131                                                 ;;
132                                 esac
133                         done
134                         missing=`
135                                 {
136                                         for X in $identifiers_seen; do
137                                                 echo "$X"
138                                                 echo "$X"
139                                         done
140                                         for X in $allidentifiers; do
141                                                 echo "$X"
142                                         done
143                                 } | sort | uniq -u
144                         `
145                         invalid=`
146                                 {
147                                         for X in $identifiers_seen; do
148                                                 echo "$X"
149                                         done
150                                         for X in $allidentifiers; do
151                                                 echo "$X"
152                                                 echo "$X"
153                                         done
154                                 } | sort | uniq -u
155                         `
156                         [ -z "$invalid" ] || echo "$S specifies invalid sound identifiers `echo $invalid`"
157                         [ -z "$missing" ] || echo "$S lacks sound identifiers `echo $missing`"
158                 } < "$S"
159         else
160                 echo "$S exists for nonexisting player model"
161         fi
162 done
163 for S in $remainingsounds; do
164         echo "$S is not used by any player model"
165 done
166
167 # tag check
168 for S in models/player/*.sounds; do echo -n `head -n 1 "$S"`"  "; md5sum "$S"; done | sort