mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-19 06:28:19 +00:00
Remove demo snap buffer and mem copy
Adding the snap to the demo is the last usage of `pTmpBuffer3` all prior usages of it copy the data if needed. So we can edit it in place. No need to copy it into a new buffer.
This commit is contained in:
parent
a9b254b0e2
commit
c5fb857893
|
@ -11,6 +11,7 @@
|
||||||
#include <game/generated/protocol.h>
|
#include <game/generated/protocol.h>
|
||||||
|
|
||||||
#include <engine/friends.h>
|
#include <engine/friends.h>
|
||||||
|
#include <engine/shared/snapshot.h>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
|
|
||||||
struct SWarning;
|
struct SWarning;
|
||||||
|
@ -346,7 +347,7 @@ public:
|
||||||
virtual CNetObjHandler *GetNetObjHandler() = 0;
|
virtual CNetObjHandler *GetNetObjHandler() = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
void SnapshotRemoveExtraProjectileInfo(unsigned char *pData);
|
void SnapshotRemoveExtraProjectileInfo(CSnapshot *pSnap);
|
||||||
|
|
||||||
extern IGameClient *CreateGameClient();
|
extern IGameClient *CreateGameClient();
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1821,9 +1821,7 @@ void CClient::ProcessServerPacket(CNetChunk *pPacket, int Conn, bool Dummy)
|
||||||
if(!Dummy)
|
if(!Dummy)
|
||||||
{
|
{
|
||||||
// for antiping: if the projectile netobjects from the server contains extra data, this is removed and the original content restored before recording demo
|
// 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];
|
SnapshotRemoveExtraProjectileInfo(pTmpBuffer3);
|
||||||
mem_copy(aExtraInfoRemoved, pTmpBuffer3, SnapSize);
|
|
||||||
SnapshotRemoveExtraProjectileInfo(aExtraInfoRemoved);
|
|
||||||
|
|
||||||
// add snapshot to demo
|
// add snapshot to demo
|
||||||
for(auto &DemoRecorder : m_aDemoRecorder)
|
for(auto &DemoRecorder : m_aDemoRecorder)
|
||||||
|
@ -1831,7 +1829,7 @@ void CClient::ProcessServerPacket(CNetChunk *pPacket, int Conn, bool Dummy)
|
||||||
if(DemoRecorder.IsRecording())
|
if(DemoRecorder.IsRecording())
|
||||||
{
|
{
|
||||||
// write snapshot
|
// write snapshot
|
||||||
DemoRecorder.RecordSnapshot(GameTick, aExtraInfoRemoved, SnapSize);
|
DemoRecorder.RecordSnapshot(GameTick, pTmpBuffer3, SnapSize);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -104,9 +104,8 @@ CProjectileData ExtractProjectileInfoDDNet(const CNetObj_DDNetProjectile *pProj)
|
||||||
return Result;
|
return Result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SnapshotRemoveExtraProjectileInfo(unsigned char *pData)
|
void SnapshotRemoveExtraProjectileInfo(CSnapshot *pSnap)
|
||||||
{
|
{
|
||||||
CSnapshot *pSnap = (CSnapshot *)pData;
|
|
||||||
for(int Index = 0; Index < pSnap->NumItems(); Index++)
|
for(int Index = 0; Index < pSnap->NumItems(); Index++)
|
||||||
{
|
{
|
||||||
const CSnapshotItem *pItem = pSnap->GetItem(Index);
|
const CSnapshotItem *pItem = pSnap->GetItem(Index);
|
||||||
|
|
Loading…
Reference in a new issue