mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 10:08:18 +00:00
convert projectiles back to default format before recording demos
This commit is contained in:
parent
03bc769c09
commit
9752334e75
|
@ -1839,13 +1839,22 @@ void CClient::ProcessServerPacket(CNetChunk *pPacket)
|
|||
// add new
|
||||
m_SnapshotStorage[g_Config.m_ClDummy].Add(GameTick, time_get(), SnapSize, pTmpBuffer3, 1);
|
||||
|
||||
// for antiping: if the projectile netobjects from the server contains extra data, this is removed and the original content restored before recording demo
|
||||
unsigned char aExtraInfoRemoved[CSnapshot::MAX_SIZE];
|
||||
mem_copy(aExtraInfoRemoved, pTmpBuffer3, SnapSize);
|
||||
CServerInfo Info;
|
||||
GetServerInfo(&Info);
|
||||
bool IsDDNet = str_find_nocase(Info.m_aGameType, "ddracenetw") || str_find_nocase(Info.m_aGameType, "ddnet");
|
||||
if(IsDDNet)
|
||||
SnapshotRemoveExtraInfo(aExtraInfoRemoved);
|
||||
|
||||
// add snapshot to demo
|
||||
for(int i = 0; i < RECORDER_MAX; i++)
|
||||
{
|
||||
if(m_DemoRecorder[i].IsRecording())
|
||||
{
|
||||
// write snapshot
|
||||
m_DemoRecorder[i].RecordSnapshot(GameTick, pTmpBuffer3, SnapSize);
|
||||
m_DemoRecorder[i].RecordSnapshot(GameTick, aExtraInfoRemoved, SnapSize);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -767,3 +767,26 @@ void ExtractExtraInfo(const CNetObj_Projectile *pProj, int *Owner, bool *Explosi
|
|||
if(Freeze)
|
||||
*Freeze = (Data>>13) & 1;
|
||||
}
|
||||
|
||||
void SnapshotRemoveExtraInfo(unsigned char *pData)
|
||||
{
|
||||
CSnapshot *pSnap = (CSnapshot*) pData;
|
||||
for(int Index = 0; Index < pSnap->NumItems(); Index++)
|
||||
{
|
||||
CSnapshotItem *pItem = pSnap->GetItem(Index);
|
||||
if(pItem->Type() == NETOBJTYPE_PROJECTILE)
|
||||
{
|
||||
CNetObj_Projectile* pProj = (CNetObj_Projectile*) ((void*)pItem->Data());
|
||||
if(UseExtraInfo(pProj))
|
||||
{
|
||||
vec2 Pos;
|
||||
vec2 Vel;
|
||||
ExtractInfo(pProj, &Pos, &Vel, 1);
|
||||
pProj->m_X = Pos.x;
|
||||
pProj->m_Y = Pos.y;
|
||||
pProj->m_VelX = (int)(Vel.x*100.0f);
|
||||
pProj->m_VelY = (int)(Vel.y*100.0f);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -301,5 +301,6 @@ inline CInputCount CountInput(int Prev, int Cur)
|
|||
bool UseExtraInfo(const CNetObj_Projectile *pProj);
|
||||
void ExtractInfo(const CNetObj_Projectile *pProj, vec2 *StartPos, vec2 *StartVel, bool IsDDNet);
|
||||
void ExtractExtraInfo(const CNetObj_Projectile *pProj, int *Owner, bool *Explosive, int *Bouncing, bool *Freeze);
|
||||
void SnapshotRemoveExtraInfo(unsigned char *pData);
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue