diff -r 803b277e4894 -r 3f21a9dc93d0 hedgewars/uSound.pas --- a/hedgewars/uSound.pas Sat Mar 06 10:54:24 2010 +0000 +++ b/hedgewars/uSound.pas Sat Mar 06 10:59:20 2010 +0000 @@ -23,10 +23,10 @@ uses SDLh, uConsts; type PVoicepack = ^TVoicepack; - TVoicepack = record - name: shortstring; - chunks: array [TSound] of PMixChunk; - end; + TVoicepack = record + name: shortstring; + chunks: array [TSound] of PMixChunk; + end; var MusicFN: shortstring; @@ -64,10 +64,10 @@ begin i:= 0; while (voicepacks[i].name <> name) and (voicepacks[i].name <> '') do - begin - inc(i); - TryDo(i <= cMaxTeams, 'Engine bug: AskForVoicepack i > cMaxTeams', true) - end; + begin + inc(i); + TryDo(i <= cMaxTeams, 'Engine bug: AskForVoicepack i > cMaxTeams', true) + end; voicepacks[i].name:= name; AskForVoicepack:= @voicepacks[i] @@ -76,37 +76,37 @@ procedure InitSound; var i: TSound; begin - if not isSoundEnabled then exit; - WriteToConsole('Init sound...'); - isSoundEnabled:= SDL_InitSubSystem(SDL_INIT_AUDIO) >= 0; + if not isSoundEnabled then exit; + WriteToConsole('Init sound...'); + isSoundEnabled:= SDL_InitSubSystem(SDL_INIT_AUDIO) >= 0; - if isSoundEnabled then - isSoundEnabled:= Mix_OpenAudio(44100, $8010, 2, 1024) = 0; + if isSoundEnabled then + isSoundEnabled:= Mix_OpenAudio(44100, $8010, 2, 1024) = 0; - if isSoundEnabled then - WriteLnToConsole(msgOK) - else - WriteLnToConsole(msgFailed); + if isSoundEnabled then + WriteLnToConsole(msgOK) + else + WriteLnToConsole(msgFailed); - Mix_AllocateChannels(Succ(chanTPU)); - if isMusicEnabled then - Mix_VolumeMusic(50); - for i:= Low(TSound) to High(TSound) do - lastChan[i]:= -1; + Mix_AllocateChannels(Succ(chanTPU)); + if isMusicEnabled then + Mix_VolumeMusic(50); + for i:= Low(TSound) to High(TSound) do + lastChan[i]:= -1; - Volume:= 0; - ChangeVolume(cInitVolume) + Volume:= 0; + ChangeVolume(cInitVolume) end; procedure ReleaseSound; var i: TSound; - t: Longword; + t: Longword; begin for t:= 0 to cMaxTeams do - if voicepacks[t].name <> '' then - for i:= Low(TSound) to High(TSound) do - if voicepacks[t].chunks[i] <> nil then - Mix_FreeChunk(voicepacks[t].chunks[i]); + if voicepacks[t].name <> '' then + for i:= Low(TSound) to High(TSound) do + if voicepacks[t].chunks[i] <> nil then + Mix_FreeChunk(voicepacks[t].chunks[i]); Mix_FreeMusic(Mus); Mix_CloseAudio(); @@ -114,50 +114,50 @@ procedure SoundLoad; var i: TSound; - s: shortstring; - t: Longword; + s: shortstring; + t: Longword; begin - if not isSoundEnabled then exit; + if not isSoundEnabled then exit; {$IFDEF SDL_MIXER_NEWER} - WriteToConsole('Init SDL_mixer... '); - SDLTry(Mix_Init(MIX_INIT_OGG) <> 0, true); - WriteLnToConsole(msgOK); + WriteToConsole('Init SDL_mixer... '); + SDLTry(Mix_Init(MIX_INIT_OGG) <> 0, true); + WriteLnToConsole(msgOK); {$ENDIF} - defVoicepack:= AskForVoicepack('Default'); + defVoicepack:= AskForVoicepack('Default'); for i:= Low(TSound) to High(TSound) do - if (Soundz[i].Path <> ptVoices) and (Soundz[i].FileName <> '') then - begin - s:= Pathz[Soundz[i].Path] + '/' + Soundz[i].FileName; - WriteToConsole(msgLoading + s + ' '); - defVoicepack^.chunks[i]:= Mix_LoadWAV_RW(SDL_RWFromFile(Str2PChar(s), 'rb'), 1); - TryDo(defVoicepack^.chunks[i] <> nil, msgFailed, true); - WriteLnToConsole(msgOK); - end; + if (Soundz[i].Path <> ptVoices) and (Soundz[i].FileName <> '') then + begin + s:= Pathz[Soundz[i].Path] + '/' + Soundz[i].FileName; + WriteToConsole(msgLoading + s + ' '); + defVoicepack^.chunks[i]:= Mix_LoadWAV_RW(SDL_RWFromFile(Str2PChar(s), 'rb'), 1); + TryDo(defVoicepack^.chunks[i] <> nil, msgFailed, true); + WriteLnToConsole(msgOK); + end; for t:= 0 to cMaxTeams do - if voicepacks[t].name <> '' then - for i:= Low(TSound) to High(TSound) do - if (Soundz[i].Path = ptVoices) and (Soundz[i].FileName <> '') then - begin - s:= Pathz[Soundz[i].Path] + '/' + voicepacks[t].name + '/' + Soundz[i].FileName; - WriteToConsole(msgLoading + s + ' '); - voicepacks[t].chunks[i]:= Mix_LoadWAV_RW(SDL_RWFromFile(Str2PChar(s), 'rb'), 1); - if voicepacks[t].chunks[i] = nil then - WriteLnToConsole(msgFailed) - else - WriteLnToConsole(msgOK) - end; + if voicepacks[t].name <> '' then + for i:= Low(TSound) to High(TSound) do + if (Soundz[i].Path = ptVoices) and (Soundz[i].FileName <> '') then + begin + s:= Pathz[Soundz[i].Path] + '/' + voicepacks[t].name + '/' + Soundz[i].FileName; + WriteToConsole(msgLoading + s + ' '); + voicepacks[t].chunks[i]:= Mix_LoadWAV_RW(SDL_RWFromFile(Str2PChar(s), 'rb'), 1); + if voicepacks[t].chunks[i] = nil then + WriteLnToConsole(msgFailed) + else + WriteLnToConsole(msgOK) + end; {$IFDEF SDL_MIXER_NEWER} - Mix_Quit(); -{$ENDIF} + Mix_Quit(); +{$ENDIF} end; procedure PlaySound(snd: TSound); begin - PlaySound(snd, nil); + PlaySound(snd, nil); end; procedure PlaySound(snd: TSound; voicepack: PVoicepack); @@ -165,38 +165,38 @@ if (not isSoundEnabled) or fastUntilLag then exit; if (voicepack <> nil) and (voicepack^.chunks[snd] <> nil) then - lastChan[snd]:= Mix_PlayChannelTimed(-1, voicepack^.chunks[snd], 0, -1) + lastChan[snd]:= Mix_PlayChannelTimed(-1, voicepack^.chunks[snd], 0, -1) else - lastChan[snd]:= Mix_PlayChannelTimed(-1, defVoicepack^.chunks[snd], 0, -1) + lastChan[snd]:= Mix_PlayChannelTimed(-1, defVoicepack^.chunks[snd], 0, -1) end; function LoopSound(snd: TSound): LongInt; begin - LoopSound:= LoopSound(snd, nil) + LoopSound:= LoopSound(snd, nil) end; function LoopSound(snd: TSound; voicepack: PVoicepack): LongInt; begin if (not isSoundEnabled) or fastUntilLag then - begin - LoopSound:= -1; - exit - end; + begin + LoopSound:= -1; + exit + end; if (voicepack <> nil) and (voicepack^.chunks[snd] <> nil) then - LoopSound:= Mix_PlayChannelTimed(-1, voicepack^.chunks[snd], -1, -1) + LoopSound:= Mix_PlayChannelTimed(-1, voicepack^.chunks[snd], -1, -1) else - LoopSound:= Mix_PlayChannelTimed(-1, defVoicepack^.chunks[snd], -1, -1) + LoopSound:= Mix_PlayChannelTimed(-1, defVoicepack^.chunks[snd], -1, -1) end; procedure StopSound(snd: TSound); begin if not isSoundEnabled then exit; if (lastChan[snd] <> -1) and (Mix_Playing(lastChan[snd]) <> 0) then - begin - Mix_HaltChannel(lastChan[snd]); - lastChan[snd]:= -1; - end; + begin + Mix_HaltChannel(lastChan[snd]); + lastChan[snd]:= -1; + end; end; procedure StopSound(chn: LongInt); @@ -209,8 +209,8 @@ var s: shortstring; begin if (not isSoundEnabled) - or (MusicFN = '') - or (not isMusicEnabled) then exit; + or (MusicFN = '') + or (not isMusicEnabled) then exit; s:= PathPrefix + '/Music/' + MusicFN; WriteToConsole(msgLoading + s + ' '); @@ -225,7 +225,7 @@ function ChangeVolume(voldelta: LongInt): LongInt; begin if not isSoundEnabled then - exit(0); + exit(0); inc(Volume, voldelta); if Volume < 0 then Volume:= 0; @@ -251,7 +251,7 @@ procedure init_uSound; begin - MusicFN:=''; + MusicFN:=''; end; procedure free_uSound;