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