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()
|
||||
|
@ -169,8 +176,7 @@ void CMapLayers::EnvelopeEval(float TimeOffset, int Env, float *pChannels, void
|
|||
|
||||
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();
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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