mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 01:58:19 +00:00
Merge pull request #1964 from trml/pr_optimize_evolve
Optimize character evolve
This commit is contained in:
commit
727fa3dbba
|
@ -1214,10 +1214,26 @@ void CGameClient::OnNewSnapshot()
|
||||||
m_Snap.m_aCharacters[Item.m_ID].m_Active = true;
|
m_Snap.m_aCharacters[Item.m_ID].m_Active = true;
|
||||||
m_Snap.m_aCharacters[Item.m_ID].m_Prev = *((const CNetObj_Character *)pOld);
|
m_Snap.m_aCharacters[Item.m_ID].m_Prev = *((const CNetObj_Character *)pOld);
|
||||||
|
|
||||||
|
// reuse the result from the previous evolve if the snapped character didn't change since the previous snapshot
|
||||||
|
if(m_aClients[Item.m_ID].m_Evolved.m_Tick == Client()->PrevGameTick())
|
||||||
|
{
|
||||||
|
if(mem_comp(&m_Snap.m_aCharacters[Item.m_ID].m_Prev, &m_aClients[Item.m_ID].m_Snapped, sizeof(CNetObj_Character)) == 0)
|
||||||
|
m_Snap.m_aCharacters[Item.m_ID].m_Prev = m_aClients[Item.m_ID].m_Evolved;
|
||||||
|
if(mem_comp(&m_Snap.m_aCharacters[Item.m_ID].m_Cur, &m_aClients[Item.m_ID].m_Snapped, sizeof(CNetObj_Character)) == 0)
|
||||||
|
m_Snap.m_aCharacters[Item.m_ID].m_Cur = m_aClients[Item.m_ID].m_Evolved;
|
||||||
|
}
|
||||||
|
|
||||||
if(m_Snap.m_aCharacters[Item.m_ID].m_Prev.m_Tick)
|
if(m_Snap.m_aCharacters[Item.m_ID].m_Prev.m_Tick)
|
||||||
Evolve(&m_Snap.m_aCharacters[Item.m_ID].m_Prev, Client()->PrevGameTick());
|
Evolve(&m_Snap.m_aCharacters[Item.m_ID].m_Prev, Client()->PrevGameTick());
|
||||||
if(m_Snap.m_aCharacters[Item.m_ID].m_Cur.m_Tick)
|
if(m_Snap.m_aCharacters[Item.m_ID].m_Cur.m_Tick)
|
||||||
Evolve(&m_Snap.m_aCharacters[Item.m_ID].m_Cur, Client()->GameTick());
|
Evolve(&m_Snap.m_aCharacters[Item.m_ID].m_Cur, Client()->GameTick());
|
||||||
|
|
||||||
|
m_aClients[Item.m_ID].m_Snapped = *((const CNetObj_Character *)pData);
|
||||||
|
m_aClients[Item.m_ID].m_Evolved = m_Snap.m_aCharacters[Item.m_ID].m_Cur;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_aClients[Item.m_ID].m_Evolved.m_Tick = -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(Item.m_Type == NETOBJTYPE_DDNETCHARACTER)
|
else if(Item.m_Type == NETOBJTYPE_DDNETCHARACTER)
|
||||||
|
@ -1798,6 +1814,8 @@ void CGameClient::CClientData::Reset()
|
||||||
m_FreezeEnd = 0;
|
m_FreezeEnd = 0;
|
||||||
m_DeepFrozen = false;
|
m_DeepFrozen = false;
|
||||||
|
|
||||||
|
m_Evolved.m_Tick = -1;
|
||||||
|
|
||||||
UpdateRenderInfo();
|
UpdateRenderInfo();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -310,6 +310,9 @@ public:
|
||||||
bool m_Paused;
|
bool m_Paused;
|
||||||
bool m_Spec;
|
bool m_Spec;
|
||||||
|
|
||||||
|
CNetObj_Character m_Snapped;
|
||||||
|
CNetObj_Character m_Evolved;
|
||||||
|
|
||||||
void UpdateRenderInfo();
|
void UpdateRenderInfo();
|
||||||
void Reset();
|
void Reset();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue