mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 10:08:18 +00:00
Improve sound replay
This commit is contained in:
parent
dd35d2be84
commit
2e30e96ba5
|
@ -41,8 +41,13 @@ void CMapSounds::OnMapLoad()
|
|||
if(!pSources)
|
||||
continue;
|
||||
|
||||
for(int i = 0; i < pSoundLayer->m_NumSources; i++)
|
||||
m_SourceQueue.add(&pSources[i]);
|
||||
for(int i = 0; i < pSoundLayer->m_NumSources; i++) {
|
||||
// dont add sources which are too much delayed
|
||||
// TODO: use duration of the source sample
|
||||
if(pSources[i].m_Loop || (Client()->LocalTime()-pSources[i].m_TimeDelay) < 2.0f)
|
||||
m_SourceQueue.add(&pSources[i]);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -64,11 +69,19 @@ void CMapSounds::OnRender()
|
|||
continue;
|
||||
}
|
||||
|
||||
if(pSource->m_TimeDelay*1000.0f <= Client()->LocalTime())
|
||||
if(pSource->m_TimeDelay <= Client()->LocalTime())
|
||||
{
|
||||
m_pClient->m_pSounds->PlaySampleAt(CSounds::CHN_AMBIENT, 1, 1.0f, vec2(fx2f(pSource->m_Position.x), fx2f(pSource->m_Position.y)), ISound::FLAG_LOOP);
|
||||
{
|
||||
int Flags = 0;
|
||||
if(pSource->m_Loop) Flags |= ISound::FLAG_LOOP;
|
||||
|
||||
if(pSource->m_Global)
|
||||
m_pClient->m_pSounds->PlaySample(CSounds::CHN_AMBIENT, 1, 1.0f, Flags);
|
||||
else
|
||||
m_pClient->m_pSounds->PlaySampleAt(CSounds::CHN_AMBIENT, 1, 1.0f, vec2(fx2f(pSource->m_Position.x), fx2f(pSource->m_Position.y)), Flags);
|
||||
}
|
||||
|
||||
m_SourceQueue.remove(pSource);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -333,7 +333,7 @@ struct CSoundSource
|
|||
CPoint m_Position;
|
||||
int m_Global;
|
||||
int m_Loop;
|
||||
int m_TimeDelay; // in ms
|
||||
int m_TimeDelay; // in s
|
||||
};
|
||||
|
||||
struct CMapItemLayerSounds
|
||||
|
|
Loading…
Reference in a new issue