diff options
| author | oy <Tom_Adams@web.de> | 2012-01-06 19:47:49 +0100 |
|---|---|---|
| committer | oy <Tom_Adams@web.de> | 2012-01-06 19:47:49 +0100 |
| commit | f3ebfae18e409e48b6553019788fbf4818f40eee (patch) | |
| tree | 9705ec4b0501a21d9311746c3fc251d750ecfa05 /src | |
| parent | b592d7a591f32ecdc2c91a79b76c58f77a2b5fee (diff) | |
| download | zcatch-f3ebfae18e409e48b6553019788fbf4818f40eee.tar.gz zcatch-f3ebfae18e409e48b6553019788fbf4818f40eee.zip | |
drop multiple chat sounds that are played within 300ms. Closes #440
Diffstat (limited to 'src')
| -rw-r--r-- | src/game/client/components/chat.cpp | 28 | ||||
| -rw-r--r-- | src/game/client/components/chat.h | 6 |
2 files changed, 31 insertions, 3 deletions
diff --git a/src/game/client/components/chat.cpp b/src/game/client/components/chat.cpp index a89d2b7e..591dccc6 100644 --- a/src/game/client/components/chat.cpp +++ b/src/game/client/components/chat.cpp @@ -41,6 +41,9 @@ void CChat::OnReset() m_PlaceholderOffset = 0; m_PlaceholderLength = 0; m_pHistoryEntry = 0x0; + + for(int i = 0; i < CHAT_NUM; ++i) + m_aLastSoundPlayed[i] = -1; } void CChat::OnRelease() @@ -322,12 +325,31 @@ void CChat::AddLine(int ClientID, int Team, const char *pLine) } // play sound + int64 Now = time_get(); if(ClientID == -1) - m_pClient->m_pSounds->Play(CSounds::CHN_GUI, SOUND_CHAT_SERVER, 0); + { + if(Now-m_aLastSoundPlayed[CHAT_SERVER] >= time_freq()*3/10) + { + m_pClient->m_pSounds->Play(CSounds::CHN_GUI, SOUND_CHAT_SERVER, 0); + m_aLastSoundPlayed[CHAT_SERVER] = Now; + } + } else if(Highlighted) - m_pClient->m_pSounds->Play(CSounds::CHN_GUI, SOUND_CHAT_HIGHLIGHT, 0); + { + if(Now-m_aLastSoundPlayed[CHAT_HIGHLIGHT] >= time_freq()*3/10) + { + m_pClient->m_pSounds->Play(CSounds::CHN_GUI, SOUND_CHAT_HIGHLIGHT, 0); + m_aLastSoundPlayed[CHAT_HIGHLIGHT] = Now; + } + } else - m_pClient->m_pSounds->Play(CSounds::CHN_GUI, SOUND_CHAT_CLIENT, 0); + { + if(Now-m_aLastSoundPlayed[CHAT_CLIENT] >= time_freq()*3/10) + { + m_pClient->m_pSounds->Play(CSounds::CHN_GUI, SOUND_CHAT_CLIENT, 0); + m_aLastSoundPlayed[CHAT_CLIENT] = Now; + } + } } void CChat::OnRender() diff --git a/src/game/client/components/chat.h b/src/game/client/components/chat.h index 60e18387..f007f314 100644 --- a/src/game/client/components/chat.h +++ b/src/game/client/components/chat.h @@ -36,6 +36,11 @@ class CChat : public CComponent MODE_NONE=0, MODE_ALL, MODE_TEAM, + + CHAT_SERVER=0, + CHAT_HIGHLIGHT, + CHAT_CLIENT, + CHAT_NUM, }; int m_Mode; @@ -49,6 +54,7 @@ class CChat : public CComponent int m_PlaceholderLength; char *m_pHistoryEntry; TStaticRingBuffer<char, 64*1024, CRingBufferBase::FLAG_RECYCLE> m_History; + int64 m_aLastSoundPlayed[CHAT_NUM]; static void ConSay(IConsole::IResult *pResult, void *pUserData); static void ConSayTeam(IConsole::IResult *pResult, void *pUserData); |