Merge pull request #8186 from ChillerDragon/pr_optimize_demo_snap

Remove demo snap buffer and mem copy
This commit is contained in:
Dennis Felsing 2024-04-04 05:39:17 +00:00 committed by GitHub
commit c20baa5035
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 5 additions and 7 deletions

View file

@ -11,6 +11,7 @@
#include <game/generated/protocol.h>
#include <engine/friends.h>
#include <engine/shared/snapshot.h>
#include <functional>
struct SWarning;
@ -346,7 +347,7 @@ public:
virtual CNetObjHandler *GetNetObjHandler() = 0;
};
void SnapshotRemoveExtraProjectileInfo(unsigned char *pData);
void SnapshotRemoveExtraProjectileInfo(CSnapshot *pSnap);
extern IGameClient *CreateGameClient();
#endif

View file

@ -1821,9 +1821,7 @@ void CClient::ProcessServerPacket(CNetChunk *pPacket, int Conn, bool 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
unsigned char aExtraInfoRemoved[CSnapshot::MAX_SIZE];
mem_copy(aExtraInfoRemoved, pTmpBuffer3, SnapSize);
SnapshotRemoveExtraProjectileInfo(aExtraInfoRemoved);
SnapshotRemoveExtraProjectileInfo(pTmpBuffer3);
// add snapshot to demo
for(auto &DemoRecorder : m_aDemoRecorder)
@ -1831,7 +1829,7 @@ void CClient::ProcessServerPacket(CNetChunk *pPacket, int Conn, bool Dummy)
if(DemoRecorder.IsRecording())
{
// write snapshot
DemoRecorder.RecordSnapshot(GameTick, aExtraInfoRemoved, SnapSize);
DemoRecorder.RecordSnapshot(GameTick, pTmpBuffer3, SnapSize);
}
}
}

View file

@ -104,9 +104,8 @@ CProjectileData ExtractProjectileInfoDDNet(const CNetObj_DDNetProjectile *pProj)
return Result;
}
void SnapshotRemoveExtraProjectileInfo(unsigned char *pData)
void SnapshotRemoveExtraProjectileInfo(CSnapshot *pSnap)
{
CSnapshot *pSnap = (CSnapshot *)pData;
for(int Index = 0; Index < pSnap->NumItems(); Index++)
{
const CSnapshotItem *pItem = pSnap->GetItem(Index);