author | unc0rr |
Sat, 25 Dec 2010 23:09:54 +0300 | |
branch | 0.9.15 |
changeset 4681 | f2c30204a3fd |
parent 4461 | 2f4f5d649bcd |
child 4748 | ce9b48de1f52 |
permissions | -rw-r--r-- |
4 | 1 |
(* |
1066 | 2 |
* Hedgewars, a free turn based strategy game |
1654 | 3 |
* Copyright (c) 2005, 2007, 2009 Andrey Korotaev <unC0Rr@gmail.com> |
4 | 4 |
* |
183 | 5 |
* This program is free software; you can redistribute it and/or modify |
6 |
* it under the terms of the GNU General Public License as published by |
|
7 |
* the Free Software Foundation; version 2 of the License |
|
4 | 8 |
* |
183 | 9 |
* This program is distributed in the hope that it will be useful, |
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 |
* GNU General Public License for more details. |
|
4 | 13 |
* |
183 | 14 |
* You should have received a copy of the GNU General Public License |
15 |
* along with this program; if not, write to the Free Software |
|
16 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA |
|
4 | 17 |
*) |
18 |
||
2630 | 19 |
{$INCLUDE "options.inc"} |
20 |
||
4 | 21 |
unit uSound; |
22 |
interface |
|
4357
a1fcfc341a52
Introduce unit uTypes in order to remove some cyclic unit dependencies
unC0Rr
parents:
3825
diff
changeset
|
23 |
uses SDLh, uConsts, uTypes; |
4 | 24 |
|
2716
b9ca1bfca24f
complete the replacement of init/free wrappers for every unit
koda
parents:
2674
diff
changeset
|
25 |
var MusicFN: shortstring; |
b9ca1bfca24f
complete the replacement of init/free wrappers for every unit
koda
parents:
2674
diff
changeset
|
26 |
|
3038 | 27 |
procedure initModule; |
28 |
procedure freeModule; |
|
2716
b9ca1bfca24f
complete the replacement of init/free wrappers for every unit
koda
parents:
2674
diff
changeset
|
29 |
|
4 | 30 |
procedure InitSound; |
31 |
procedure ReleaseSound; |
|
32 |
procedure SoundLoad; |
|
2745 | 33 |
procedure PlaySound(snd: TSound); |
3202 | 34 |
procedure PlaySound(snd: TSound; keepPlaying: boolean); |
2745 | 35 |
procedure PlaySound(snd: TSound; voicepack: PVoicepack); |
3201 | 36 |
procedure PlaySound(snd: TSound; voicepack: PVoicepack; keepPlaying: boolean); |
3529 | 37 |
function LoopSound(snd: TSound): LongInt; |
38 |
function LoopSound(snd: TSound; voicepack: PVoicepack): LongInt; |
|
4 | 39 |
procedure PlayMusic; |
1712 | 40 |
procedure PauseMusic; |
41 |
procedure ResumeMusic; |
|
282 | 42 |
procedure StopSound(snd: TSound); |
2745 | 43 |
procedure StopSound(chn: LongInt); |
2515
51d3f4b6293a
revert audio to use SDL_mixer -- also frontend uses it, so it needs sdlmixer sources
koda
parents:
2501
diff
changeset
|
44 |
function ChangeVolume(voldelta: LongInt): LongInt; |
51d3f4b6293a
revert audio to use SDL_mixer -- also frontend uses it, so it needs sdlmixer sources
koda
parents:
2501
diff
changeset
|
45 |
function AskForVoicepack(name: shortstring): Pointer; |
4 | 46 |
|
1097 | 47 |
|
4 | 48 |
implementation |
4461
2f4f5d649bcd
add a simple check to prevent loading sounds when device is muted
koda
parents:
4404
diff
changeset
|
49 |
uses uVariables, uConsole, uUtils, uCommands, uDebug, uMobile; |
564 | 50 |
|
3418 | 51 |
const chanTPU = 32; |
2515
51d3f4b6293a
revert audio to use SDL_mixer -- also frontend uses it, so it needs sdlmixer sources
koda
parents:
2501
diff
changeset
|
52 |
var Volume: LongInt; |
2716
b9ca1bfca24f
complete the replacement of init/free wrappers for every unit
koda
parents:
2674
diff
changeset
|
53 |
lastChan: array [TSound] of LongInt; |
b9ca1bfca24f
complete the replacement of init/free wrappers for every unit
koda
parents:
2674
diff
changeset
|
54 |
voicepacks: array[0..cMaxTeams] of TVoicepack; |
b9ca1bfca24f
complete the replacement of init/free wrappers for every unit
koda
parents:
2674
diff
changeset
|
55 |
defVoicepack: PVoicepack; |
b9ca1bfca24f
complete the replacement of init/free wrappers for every unit
koda
parents:
2674
diff
changeset
|
56 |
Mus: PMixMusic = nil; |
1654 | 57 |
|
2515
51d3f4b6293a
revert audio to use SDL_mixer -- also frontend uses it, so it needs sdlmixer sources
koda
parents:
2501
diff
changeset
|
58 |
function AskForVoicepack(name: shortstring): Pointer; |
1654 | 59 |
var i: Longword; |
60 |
begin |
|
61 |
i:= 0; |
|
3529 | 62 |
while (voicepacks[i].name <> name) and (voicepacks[i].name <> '') do |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
63 |
begin |
3529 | 64 |
inc(i); |
65 |
TryDo(i <= cMaxTeams, 'Engine bug: AskForVoicepack i > cMaxTeams', true) |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
66 |
end; |
1654 | 67 |
|
3529 | 68 |
voicepacks[i].name:= name; |
69 |
AskForVoicepack:= @voicepacks[i] |
|
1654 | 70 |
end; |
4 | 71 |
|
72 |
procedure InitSound; |
|
2647 | 73 |
var i: TSound; |
3825 | 74 |
channels: LongInt; |
4 | 75 |
begin |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
76 |
if not isSoundEnabled then exit; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
77 |
WriteToConsole('Init sound...'); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
78 |
isSoundEnabled:= SDL_InitSubSystem(SDL_INIT_AUDIO) >= 0; |
2671
7e0f88013fe8
smaller patches, one missing Sky-lowres, IMG_Init and Mix_Init (might require newer libraries), updates to SDL bindings, code cleanup, new compile flags
koda
parents:
2647
diff
changeset
|
79 |
|
3825 | 80 |
{$IFDEF IPHONEOS} |
81 |
channels:= 1; |
|
82 |
{$ELSE} |
|
83 |
channels:= 2; |
|
84 |
{$ENDIF} |
|
85 |
||
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
86 |
if isSoundEnabled then |
3825 | 87 |
isSoundEnabled:= Mix_OpenAudio(44100, $8010, channels, 1024) = 0; |
2327 | 88 |
|
3182 | 89 |
{$IFDEF SDL_MIXER_NEWER} |
90 |
WriteToConsole('Init SDL_mixer... '); |
|
91 |
SDLTry(Mix_Init(MIX_INIT_OGG) <> 0, true); |
|
92 |
WriteLnToConsole(msgOK); |
|
93 |
{$ENDIF} |
|
94 |
||
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
95 |
if isSoundEnabled then |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
96 |
WriteLnToConsole(msgOK) |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
97 |
else |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
98 |
WriteLnToConsole(msgFailed); |
2647 | 99 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
100 |
Mix_AllocateChannels(Succ(chanTPU)); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
101 |
if isMusicEnabled then |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
102 |
Mix_VolumeMusic(50); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
103 |
for i:= Low(TSound) to High(TSound) do |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
104 |
lastChan[i]:= -1; |
2671
7e0f88013fe8
smaller patches, one missing Sky-lowres, IMG_Init and Mix_Init (might require newer libraries), updates to SDL bindings, code cleanup, new compile flags
koda
parents:
2647
diff
changeset
|
105 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
106 |
Volume:= 0; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
107 |
ChangeVolume(cInitVolume) |
4 | 108 |
end; |
109 |
||
110 |
procedure ReleaseSound; |
|
2515
51d3f4b6293a
revert audio to use SDL_mixer -- also frontend uses it, so it needs sdlmixer sources
koda
parents:
2501
diff
changeset
|
111 |
var i: TSound; |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
112 |
t: Longword; |
4 | 113 |
begin |
3529 | 114 |
for t:= 0 to cMaxTeams do |
115 |
if voicepacks[t].name <> '' then |
|
116 |
for i:= Low(TSound) to High(TSound) do |
|
117 |
if voicepacks[t].chunks[i] <> nil then |
|
118 |
Mix_FreeChunk(voicepacks[t].chunks[i]); |
|
2515
51d3f4b6293a
revert audio to use SDL_mixer -- also frontend uses it, so it needs sdlmixer sources
koda
parents:
2501
diff
changeset
|
119 |
|
3529 | 120 |
if Mus <> nil then |
121 |
Mix_FreeMusic(Mus); |
|
3182 | 122 |
|
123 |
{$IFDEF SDL_MIXER_NEWER} |
|
3529 | 124 |
// make sure all instances of sdl_mixer are unloaded before continuing |
125 |
while Mix_Init(0) <> 0 do |
|
126 |
Mix_Quit(); |
|
3697 | 127 |
{$ENDIF} |
3182 | 128 |
|
3529 | 129 |
Mix_CloseAudio(); |
4 | 130 |
end; |
131 |
||
132 |
procedure SoundLoad; |
|
133 |
var i: TSound; |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
134 |
t: Longword; |
3667 | 135 |
s:shortstring; |
4 | 136 |
begin |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
137 |
if not isSoundEnabled then exit; |
1656
209cf0e2fc36
Finish voicepacks support in engine (not tested though)
unc0rr
parents:
1654
diff
changeset
|
138 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
139 |
defVoicepack:= AskForVoicepack('Default'); |
3697 | 140 |
|
3529 | 141 |
for t:= 0 to cMaxTeams do |
142 |
if voicepacks[t].name <> '' then |
|
143 |
for i:= Low(TSound) to High(TSound) do |
|
3667 | 144 |
voicepacks[t].chunks[i]:= nil; |
3697 | 145 |
|
3667 | 146 |
for i:= Low(TSound) to High(TSound) do |
147 |
begin |
|
148 |
defVoicepack^.chunks[i]:= nil; |
|
149 |
// preload all the big sound files (>32k) that would otherwise lockup the game |
|
4461
2f4f5d649bcd
add a simple check to prevent loading sounds when device is muted
koda
parents:
4404
diff
changeset
|
150 |
if (i in [sndBeeWater, sndBee, sndCake, sndHellishImpact1, sndHellish, sndHomerun, |
2f4f5d649bcd
add a simple check to prevent loading sounds when device is muted
koda
parents:
4404
diff
changeset
|
151 |
sndMolotov, sndMortar, sndRideOfTheValkyries, sndYoohoo]) |
3667 | 152 |
and (Soundz[i].Path <> ptVoices) and (Soundz[i].FileName <> '') then |
153 |
begin |
|
154 |
s:= Pathz[Soundz[i].Path] + '/' + Soundz[i].FileName; |
|
155 |
WriteToConsole(msgLoading + s + ' '); |
|
156 |
defVoicepack^.chunks[i]:= Mix_LoadWAV_RW(SDL_RWFromFile(Str2PChar(s), 'rb'), 1); |
|
157 |
TryDo(defVoicepack^.chunks[i] <> nil, msgFailed, true); |
|
158 |
WriteLnToConsole(msgOK); |
|
159 |
end; |
|
160 |
end; |
|
3664 | 161 |
|
4 | 162 |
end; |
163 |
||
2745 | 164 |
procedure PlaySound(snd: TSound); |
165 |
begin |
|
3201 | 166 |
PlaySound(snd, nil, false); |
2745 | 167 |
end; |
168 |
||
3202 | 169 |
procedure PlaySound(snd: TSound; keepPlaying: boolean); |
170 |
begin |
|
171 |
PlaySound(snd, nil, keepPlaying); |
|
172 |
end; |
|
173 |
||
2745 | 174 |
procedure PlaySound(snd: TSound; voicepack: PVoicepack); |
4 | 175 |
begin |
3201 | 176 |
PlaySound(snd, voicepack, false); |
177 |
end; |
|
178 |
||
179 |
procedure PlaySound(snd: TSound; voicepack: PVoicepack; keepPlaying: boolean); |
|
3664 | 180 |
var s:shortstring; |
3201 | 181 |
begin |
4461
2f4f5d649bcd
add a simple check to prevent loading sounds when device is muted
koda
parents:
4404
diff
changeset
|
182 |
if (not isSoundEnabled) or fastUntilLag or isDeviceMute() then |
3529 | 183 |
exit; |
3201 | 184 |
|
3529 | 185 |
if keepPlaying and (lastChan[snd] <> -1) and (Mix_Playing(lastChan[snd]) <> 0) then |
186 |
exit; |
|
187 |
||
3664 | 188 |
if (voicepack <> nil) then |
189 |
begin |
|
190 |
if (voicepack^.chunks[snd] = nil) and (Soundz[snd].Path = ptVoices) and (Soundz[snd].FileName <> '') then |
|
191 |
begin |
|
192 |
s:= Pathz[Soundz[snd].Path] + '/' + voicepack^.name + '/' + Soundz[snd].FileName; |
|
193 |
WriteToConsole(msgLoading + s + ' '); |
|
194 |
voicepack^.chunks[snd]:= Mix_LoadWAV_RW(SDL_RWFromFile(Str2PChar(s), 'rb'), 1); |
|
195 |
if voicepack^.chunks[snd] = nil then |
|
196 |
WriteLnToConsole(msgFailed) |
|
197 |
else |
|
198 |
WriteLnToConsole(msgOK) |
|
199 |
end; |
|
3529 | 200 |
lastChan[snd]:= Mix_PlayChannelTimed(-1, voicepack^.chunks[snd], 0, -1) |
3664 | 201 |
end |
3529 | 202 |
else |
3664 | 203 |
begin |
204 |
if (defVoicepack^.chunks[snd] = nil) and (Soundz[snd].Path <> ptVoices) and (Soundz[snd].FileName <> '') then |
|
205 |
begin |
|
206 |
s:= Pathz[Soundz[snd].Path] + '/' + Soundz[snd].FileName; |
|
207 |
WriteToConsole(msgLoading + s + ' '); |
|
208 |
defVoicepack^.chunks[snd]:= Mix_LoadWAV_RW(SDL_RWFromFile(Str2PChar(s), 'rb'), 1); |
|
209 |
TryDo(defVoicepack^.chunks[snd] <> nil, msgFailed, true); |
|
210 |
WriteLnToConsole(msgOK); |
|
211 |
end; |
|
3529 | 212 |
lastChan[snd]:= Mix_PlayChannelTimed(-1, defVoicepack^.chunks[snd], 0, -1) |
3664 | 213 |
end; |
4 | 214 |
end; |
215 |
||
2745 | 216 |
function LoopSound(snd: TSound): LongInt; |
217 |
begin |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
218 |
LoopSound:= LoopSound(snd, nil) |
2745 | 219 |
end; |
220 |
||
221 |
function LoopSound(snd: TSound; voicepack: PVoicepack): LongInt; |
|
3664 | 222 |
var s: shortstring; |
2647 | 223 |
begin |
4461
2f4f5d649bcd
add a simple check to prevent loading sounds when device is muted
koda
parents:
4404
diff
changeset
|
224 |
if (not isSoundEnabled) or fastUntilLag or isDeviceMute() then |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
225 |
begin |
3529 | 226 |
LoopSound:= -1; |
227 |
exit |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
228 |
end; |
2647 | 229 |
|
3664 | 230 |
if (voicepack <> nil) then |
231 |
begin |
|
232 |
if (voicepack^.chunks[snd] = nil) and (Soundz[snd].Path = ptVoices) and (Soundz[snd].FileName <> '') then |
|
233 |
begin |
|
234 |
s:= Pathz[Soundz[snd].Path] + '/' + voicepack^.name + '/' + Soundz[snd].FileName; |
|
235 |
WriteToConsole(msgLoading + s + ' '); |
|
236 |
voicepack^.chunks[snd]:= Mix_LoadWAV_RW(SDL_RWFromFile(Str2PChar(s), 'rb'), 1); |
|
237 |
if voicepack^.chunks[snd] = nil then |
|
238 |
WriteLnToConsole(msgFailed) |
|
239 |
else |
|
240 |
WriteLnToConsole(msgOK) |
|
241 |
end; |
|
3529 | 242 |
LoopSound:= Mix_PlayChannelTimed(-1, voicepack^.chunks[snd], -1, -1) |
3664 | 243 |
end |
3529 | 244 |
else |
3664 | 245 |
begin |
246 |
if (defVoicepack^.chunks[snd] = nil) and (Soundz[snd].Path <> ptVoices) and (Soundz[snd].FileName <> '') then |
|
247 |
begin |
|
248 |
s:= Pathz[Soundz[snd].Path] + '/' + Soundz[snd].FileName; |
|
249 |
WriteToConsole(msgLoading + s + ' '); |
|
250 |
defVoicepack^.chunks[snd]:= Mix_LoadWAV_RW(SDL_RWFromFile(Str2PChar(s), 'rb'), 1); |
|
251 |
TryDo(defVoicepack^.chunks[snd] <> nil, msgFailed, true); |
|
252 |
WriteLnToConsole(msgOK); |
|
253 |
end; |
|
254 |
LoopSound:= Mix_PlayChannelTimed(-1, defVoicepack^.chunks[snd], -1, -1); |
|
255 |
end; |
|
2647 | 256 |
end; |
257 |
||
282 | 258 |
procedure StopSound(snd: TSound); |
4 | 259 |
begin |
3529 | 260 |
if not isSoundEnabled then exit; |
261 |
if (lastChan[snd] <> -1) and (Mix_Playing(lastChan[snd]) <> 0) then |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
262 |
begin |
3529 | 263 |
Mix_HaltChannel(lastChan[snd]); |
264 |
lastChan[snd]:= -1; |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
265 |
end; |
4 | 266 |
end; |
267 |
||
2745 | 268 |
procedure StopSound(chn: LongInt); |
269 |
begin |
|
3529 | 270 |
if not isSoundEnabled then exit; |
271 |
||
272 |
if (chn <> -1) and (Mix_Playing(chn) <> 0) then |
|
273 |
Mix_HaltChannel(chn); |
|
2745 | 274 |
end; |
275 |
||
4 | 276 |
procedure PlayMusic; |
2905 | 277 |
var s: shortstring; |
4 | 278 |
begin |
3529 | 279 |
if (not isSoundEnabled) or (MusicFN = '') or (not isMusicEnabled) then |
280 |
exit; |
|
281 |
||
282 |
s:= PathPrefix + '/Music/' + MusicFN; |
|
283 |
WriteToConsole(msgLoading + s + ' '); |
|
565 | 284 |
|
3529 | 285 |
Mus:= Mix_LoadMUS(Str2PChar(s)); |
286 |
TryDo(Mus <> nil, msgFailed, false); |
|
287 |
WriteLnToConsole(msgOK); |
|
565 | 288 |
|
3529 | 289 |
SDLTry(Mix_FadeInMusic(Mus, -1, 3000) <> -1, false) |
4 | 290 |
end; |
291 |
||
371 | 292 |
function ChangeVolume(voldelta: LongInt): LongInt; |
174 | 293 |
begin |
3529 | 294 |
if not isSoundEnabled then |
295 |
exit(0); |
|
2327 | 296 |
|
3529 | 297 |
inc(Volume, voldelta); |
298 |
if Volume < 0 then Volume:= 0; |
|
299 |
Mix_Volume(-1, Volume); |
|
300 |
Volume:= Mix_Volume(-1, -1); |
|
301 |
if isMusicEnabled then Mix_VolumeMusic(Volume * 4 div 8); |
|
302 |
ChangeVolume:= Volume * 100 div MIX_MAX_VOLUME |
|
174 | 303 |
end; |
304 |
||
1712 | 305 |
procedure PauseMusic; |
306 |
begin |
|
3529 | 307 |
if (MusicFN = '') or (not isMusicEnabled) then |
308 |
exit; |
|
2515
51d3f4b6293a
revert audio to use SDL_mixer -- also frontend uses it, so it needs sdlmixer sources
koda
parents:
2501
diff
changeset
|
309 |
|
3529 | 310 |
Mix_PauseMusic(Mus); |
1712 | 311 |
end; |
312 |
||
313 |
procedure ResumeMusic; |
|
314 |
begin |
|
3529 | 315 |
if (MusicFN = '') or (not isMusicEnabled) then |
316 |
exit; |
|
2515
51d3f4b6293a
revert audio to use SDL_mixer -- also frontend uses it, so it needs sdlmixer sources
koda
parents:
2501
diff
changeset
|
317 |
|
3529 | 318 |
Mix_ResumeMusic(Mus); |
1712 | 319 |
end; |
320 |
||
4398
36d7e4b6ca81
Move some command handlers out of uCommands into more appropriate places, thus removing some dependencies. Ideally uCommands shouldn't depend on anything (except for uTypes and uConsts probably)
unc0rr
parents:
4377
diff
changeset
|
321 |
procedure chVoicepack(var s: shortstring); |
36d7e4b6ca81
Move some command handlers out of uCommands into more appropriate places, thus removing some dependencies. Ideally uCommands shouldn't depend on anything (except for uTypes and uConsts probably)
unc0rr
parents:
4377
diff
changeset
|
322 |
begin |
36d7e4b6ca81
Move some command handlers out of uCommands into more appropriate places, thus removing some dependencies. Ideally uCommands shouldn't depend on anything (except for uTypes and uConsts probably)
unc0rr
parents:
4377
diff
changeset
|
323 |
if CurrentTeam = nil then OutError(errmsgIncorrectUse + ' "/voicepack"', true); |
36d7e4b6ca81
Move some command handlers out of uCommands into more appropriate places, thus removing some dependencies. Ideally uCommands shouldn't depend on anything (except for uTypes and uConsts probably)
unc0rr
parents:
4377
diff
changeset
|
324 |
if s[1]='"' then Delete(s, 1, 1); |
36d7e4b6ca81
Move some command handlers out of uCommands into more appropriate places, thus removing some dependencies. Ideally uCommands shouldn't depend on anything (except for uTypes and uConsts probably)
unc0rr
parents:
4377
diff
changeset
|
325 |
if s[byte(s[0])]='"' then Delete(s, byte(s[0]), 1); |
36d7e4b6ca81
Move some command handlers out of uCommands into more appropriate places, thus removing some dependencies. Ideally uCommands shouldn't depend on anything (except for uTypes and uConsts probably)
unc0rr
parents:
4377
diff
changeset
|
326 |
CurrentTeam^.voicepack:= AskForVoicepack(s) |
36d7e4b6ca81
Move some command handlers out of uCommands into more appropriate places, thus removing some dependencies. Ideally uCommands shouldn't depend on anything (except for uTypes and uConsts probably)
unc0rr
parents:
4377
diff
changeset
|
327 |
end; |
36d7e4b6ca81
Move some command handlers out of uCommands into more appropriate places, thus removing some dependencies. Ideally uCommands shouldn't depend on anything (except for uTypes and uConsts probably)
unc0rr
parents:
4377
diff
changeset
|
328 |
|
3038 | 329 |
procedure initModule; |
2716
b9ca1bfca24f
complete the replacement of init/free wrappers for every unit
koda
parents:
2674
diff
changeset
|
330 |
begin |
4398
36d7e4b6ca81
Move some command handlers out of uCommands into more appropriate places, thus removing some dependencies. Ideally uCommands shouldn't depend on anything (except for uTypes and uConsts probably)
unc0rr
parents:
4377
diff
changeset
|
331 |
RegisterVariable('voicepack', vtCommand, @chVoicepack, false); |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
332 |
MusicFN:=''; |
2716
b9ca1bfca24f
complete the replacement of init/free wrappers for every unit
koda
parents:
2674
diff
changeset
|
333 |
end; |
b9ca1bfca24f
complete the replacement of init/free wrappers for every unit
koda
parents:
2674
diff
changeset
|
334 |
|
3038 | 335 |
procedure freeModule; |
2716
b9ca1bfca24f
complete the replacement of init/free wrappers for every unit
koda
parents:
2674
diff
changeset
|
336 |
begin |
3615 | 337 |
if isSoundEnabled then |
338 |
ReleaseSound(); |
|
2716
b9ca1bfca24f
complete the replacement of init/free wrappers for every unit
koda
parents:
2674
diff
changeset
|
339 |
end; |
b9ca1bfca24f
complete the replacement of init/free wrappers for every unit
koda
parents:
2674
diff
changeset
|
340 |
|
2515
51d3f4b6293a
revert audio to use SDL_mixer -- also frontend uses it, so it needs sdlmixer sources
koda
parents:
2501
diff
changeset
|
341 |
end. |
2192
4763a778c033
- Fix quickplay sound bug triggered by two faults: ttsmj's (passing voicepack with empty name in team config) and koda's (he changed fallback to default scheme condition)
unc0rr
parents:
2191
diff
changeset
|
342 |