Merge pull request #1964 from trml/pr_optimize_evolve

Optimize character evolve
This commit is contained in:
Dennis Felsing 2019-11-10 19:25:23 +01:00 committed by GitHub
commit 727fa3dbba
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 0 deletions

View file

@ -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();
} }

View file

@ -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();