mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-19 22:48:18 +00:00
Fixed non-synchronized envelope time not being reset
This commit is contained in:
parent
d9dff698c6
commit
805206e3ac
|
@ -28,6 +28,13 @@ CMapLayers::CMapLayers(int t)
|
|||
m_EnvelopeUpdate = false;
|
||||
m_pMenuMap = 0;
|
||||
m_pMenuLayers = 0;
|
||||
m_OnlineStartTime = 0;
|
||||
}
|
||||
|
||||
void CMapLayers::OnStateChange(int NewState, int OldState)
|
||||
{
|
||||
if(NewState == IClient::STATE_ONLINE)
|
||||
m_OnlineStartTime = Client()->LocalTime(); // reset time for non-scynchronized envelopes
|
||||
}
|
||||
|
||||
void CMapLayers::LoadBackgroundMap()
|
||||
|
@ -89,7 +96,7 @@ void CMapLayers::LoadEnvPoints(const CLayers *pLayers, array<CEnvPoint>& lEnvPoi
|
|||
pLayers->Map()->GetType(MAPITEMTYPE_ENVELOPE, &Start, &Num);
|
||||
if(!Num)
|
||||
return;
|
||||
|
||||
|
||||
|
||||
for(int env = 0; env < Num; env++)
|
||||
{
|
||||
|
@ -167,14 +174,13 @@ void CMapLayers::EnvelopeEval(float TimeOffset, int Env, float *pChannels, void
|
|||
if(Env >= Num)
|
||||
return;
|
||||
|
||||
CMapItemEnvelope *pItem = (CMapItemEnvelope *)pLayers->Map()->GetItem(Start+Env, 0, 0);
|
||||
CMapItemEnvelope *pItem = (CMapItemEnvelope *)pLayers->Map()->GetItem(Start+Env, 0, 0);
|
||||
|
||||
static float s_Time = 0.0f;
|
||||
static float s_LastLocalTime = pThis->Client()->LocalTime();
|
||||
float Time = 0.0f;
|
||||
if(pThis->Client()->State() == IClient::STATE_DEMOPLAYBACK)
|
||||
{
|
||||
const IDemoPlayer::CInfo *pInfo = pThis->DemoPlayer()->BaseInfo();
|
||||
|
||||
|
||||
if(!pInfo->m_Paused || pThis->m_EnvelopeUpdate)
|
||||
{
|
||||
if(pThis->m_CurrentLocalTick != pInfo->m_CurrentTick)
|
||||
|
@ -183,12 +189,12 @@ void CMapLayers::EnvelopeEval(float TimeOffset, int Env, float *pChannels, void
|
|||
pThis->m_CurrentLocalTick = pInfo->m_CurrentTick;
|
||||
}
|
||||
|
||||
s_Time = mix(pThis->m_LastLocalTick / (float)pThis->Client()->GameTickSpeed(),
|
||||
Time = mix(pThis->m_LastLocalTick / (float)pThis->Client()->GameTickSpeed(),
|
||||
pThis->m_CurrentLocalTick / (float)pThis->Client()->GameTickSpeed(),
|
||||
pThis->Client()->IntraGameTick());
|
||||
}
|
||||
|
||||
pThis->RenderTools()->RenderEvalEnvelope(pPoints + pItem->m_StartPoint, pItem->m_NumPoints, 4, s_Time+TimeOffset, pChannels);
|
||||
pThis->RenderTools()->RenderEvalEnvelope(pPoints + pItem->m_StartPoint, pItem->m_NumPoints, 4, Time+TimeOffset, pChannels);
|
||||
}
|
||||
else if(pThis->Client()->State() != IClient::STATE_OFFLINE)
|
||||
{
|
||||
|
@ -196,20 +202,20 @@ void CMapLayers::EnvelopeEval(float TimeOffset, int Env, float *pChannels, void
|
|||
{
|
||||
if(pItem->m_Version < 2 || pItem->m_Synchronized)
|
||||
{
|
||||
s_Time = mix((pThis->Client()->PrevGameTick()-pThis->m_pClient->m_Snap.m_pGameData->m_GameStartTick) / (float)pThis->Client()->GameTickSpeed(),
|
||||
Time = mix((pThis->Client()->PrevGameTick()-pThis->m_pClient->m_Snap.m_pGameData->m_GameStartTick) / (float)pThis->Client()->GameTickSpeed(),
|
||||
(pThis->Client()->GameTick()-pThis->m_pClient->m_Snap.m_pGameData->m_GameStartTick) / (float)pThis->Client()->GameTickSpeed(),
|
||||
pThis->Client()->IntraGameTick());
|
||||
}
|
||||
else
|
||||
s_Time += pThis->Client()->LocalTime()-s_LastLocalTime;
|
||||
Time = pThis->Client()->LocalTime()-pThis->m_OnlineStartTime;
|
||||
}
|
||||
pThis->RenderTools()->RenderEvalEnvelope(pPoints + pItem->m_StartPoint, pItem->m_NumPoints, 4, s_Time+TimeOffset, pChannels);
|
||||
s_LastLocalTime = pThis->Client()->LocalTime();
|
||||
|
||||
pThis->RenderTools()->RenderEvalEnvelope(pPoints + pItem->m_StartPoint, pItem->m_NumPoints, 4, Time+TimeOffset, pChannels);
|
||||
}
|
||||
else
|
||||
{
|
||||
s_Time = pThis->Client()->LocalTime();
|
||||
pThis->RenderTools()->RenderEvalEnvelope(pPoints + pItem->m_StartPoint, pItem->m_NumPoints, 4, s_Time+TimeOffset, pChannels);
|
||||
Time = pThis->Client()->LocalTime();
|
||||
pThis->RenderTools()->RenderEvalEnvelope(pPoints + pItem->m_StartPoint, pItem->m_NumPoints, 4, Time+TimeOffset, pChannels);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -248,7 +254,7 @@ void CMapLayers::OnRender()
|
|||
float y0 = (pGroup->m_ClipY - Points[1]) / (Points[3]-Points[1]);
|
||||
float x1 = ((pGroup->m_ClipX+pGroup->m_ClipW) - Points[0]) / (Points[2]-Points[0]);
|
||||
float y1 = ((pGroup->m_ClipY+pGroup->m_ClipH) - Points[1]) / (Points[3]-Points[1]);
|
||||
|
||||
|
||||
if(x1 < 0.0f || x0 > 1.0f || y1 < 0.0f || y0 > 1.0f)
|
||||
continue;
|
||||
|
||||
|
|
|
@ -13,6 +13,7 @@ class CMapLayers : public CComponent
|
|||
int m_Type;
|
||||
int m_CurrentLocalTick;
|
||||
int m_LastLocalTick;
|
||||
float m_OnlineStartTime;
|
||||
bool m_EnvelopeUpdate;
|
||||
|
||||
array<CEnvPoint> m_lEnvPoints;
|
||||
|
@ -31,6 +32,7 @@ public:
|
|||
};
|
||||
|
||||
CMapLayers(int Type);
|
||||
virtual void OnStateChange(int NewState, int OldState);
|
||||
virtual void OnInit();
|
||||
virtual void OnRender();
|
||||
virtual void OnMapLoad();
|
||||
|
|
Loading…
Reference in a new issue