# HG changeset patch # User nemo # Date 1360103292 18000 # Node ID 7681d14b9f0191eda821a9b744f0a093430321ee # Parent 01ddeb241c21c2d88aaad1f0647662041afd0a44 Trying to prevent audio mute from endlessly spamming. Untested. diff -r 01ddeb241c21 -r 7681d14b9f01 hedgewars/uGame.pas --- a/hedgewars/uGame.pas Sat Feb 02 14:33:35 2013 +0100 +++ b/hedgewars/uGame.pas Tue Feb 05 17:28:12 2013 -0500 @@ -26,12 +26,13 @@ //////////////////// implementation //////////////////// -uses uInputHandler, uTeams, uIO, uAI, uGears, uSound, +uses uInputHandler, uTeams, uIO, uAI, uGears, uSound, uLocale, uCaptions, uVisualGears, uTypes, uVariables, uCommands, uConsts {$IFDEF USE_TOUCH_INTERFACE}, uTouch{$ENDIF}; procedure DoGameTick(Lag: LongInt); -var i: LongInt; +var i,j : LongInt; + s: shortstring; begin if isPaused then exit; @@ -61,6 +62,23 @@ else if cOnlyStats then Lag:= High(LongInt) end; +inc(SoundTimerTicks, Lag); +if SoundTimerTicks >= 50 then + begin + SoundTimerTicks:= 0; + if cVolumeDelta <> 0 then + begin + j:= Volume; + i:= ChangeVolume(cVolumeDelta); + if isAudioMuted and (j<>i) then + AddCaption(trmsg[sidMute], cWhiteColor, capgrpVolume) + else if not isAudioMuted then + begin + str(i, s); + AddCaption(Format(trmsg[sidVolume], s), cWhiteColor, capgrpVolume) + end + end; + end; PlayNextVoice; i:= 1; while (GameState <> gsExit) and (i <= Lag) do diff -r 01ddeb241c21 -r 7681d14b9f01 hedgewars/uSound.pas --- a/hedgewars/uSound.pas Sat Feb 02 14:33:35 2013 +0100 +++ b/hedgewars/uSound.pas Tue Feb 05 17:28:12 2013 -0500 @@ -105,12 +105,13 @@ function AskForVoicepack(name: shortstring): Pointer; +var Volume: LongInt; + SoundTimerTicks: Longword; implementation uses uVariables, uConsole, uCommands, uDebug, uPhysFSLayer; const chanTPU = 32; -var Volume: LongInt; - cInitVolume: LongInt; +var cInitVolume: LongInt; previousVolume: LongInt; // cached volume value lastChan: array [TSound] of LongInt; voicepacks: array[0..cMaxTeams] of TVoicepack; @@ -712,6 +713,7 @@ isAudioMuted:= false; isSEBackup:= isSoundEnabled; Volume:= 0; + SoundTimerTicks:= 0; defVoicepack:= AskForVoicepack('Default'); for i:= Low(TSound) to High(TSound) do diff -r 01ddeb241c21 -r 7681d14b9f01 hedgewars/uWorld.pas --- a/hedgewars/uWorld.pas Sat Feb 02 14:33:35 2013 +0100 +++ b/hedgewars/uWorld.pas Tue Feb 05 17:28:12 2013 -0500 @@ -74,7 +74,6 @@ timeTexture: PTexture; FPS: Longword; CountTicks: Longword; - SoundTimerTicks: Longword; prevPoint, prevTargetPoint: TPoint; amSel: TAmmoType = amNothing; missionTex: PTexture; @@ -1514,22 +1513,8 @@ if fpsTexture <> nil then DrawTexture((cScreenWidth shr 1) - 60 - offsetY, offsetX, fpsTexture); end; - - // lag warning (?) - inc(SoundTimerTicks, Lag); end; -if SoundTimerTicks >= 50 then -begin - SoundTimerTicks:= 0; - if cVolumeDelta <> 0 then - begin - str(ChangeVolume(cVolumeDelta), s); - AddCaption(Format(trmsg[sidVolume], s), cWhiteColor, capgrpVolume); - end; - if isAudioMuted then - AddCaption(trmsg[sidMute], cWhiteColor, capgrpVolume) -end; if GameState = gsConfirm then DrawTextureCentered(0, (cScreenHeight shr 1), ConfirmTexture);