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 <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

View file

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

View file

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