MCPcopy Create free account
hub / github.com/ddnet/ddnet / DoTick

Method DoTick

src/engine/shared/demo.cpp:654–795  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

652}
653
654void CDemoPlayer::DoTick()
655{
656 // update ticks
657 m_Info.m_PreviousTick = m_Info.m_Info.m_CurrentTick;
658 m_Info.m_Info.m_CurrentTick = m_Info.m_NextTick;
659 int ChunkTick = m_Info.m_Info.m_CurrentTick;
660
661 UpdateTimes();
662
663 bool GotSnapshot = false;
664 while(true)
665 {
666 int ChunkType, ChunkSize;
667 const EReadChunkHeaderResult Result = ReadChunkHeader(&ChunkType, &ChunkSize, &ChunkTick);
668 if(Result == CHUNKHEADER_EOF)
669 {
670 if(m_Info.m_PreviousTick == -1)
671 {
672 Stop("Empty demo");
673 }
674 else
675 {
676 Pause();
677 // Stop rendering when reaching end of file
678#if defined(CONF_VIDEORECORDER)
679 if(m_UseVideo && IVideo::Current())
680 Stop();
681#endif
682 }
683 break;
684 }
685 else if(Result == CHUNKHEADER_ERROR)
686 {
687 Stop("Error reading chunk header");
688 break;
689 }
690
691 // read the chunk
692 int DataSize = 0;
693 if(ChunkSize)
694 {
695 if(io_read(m_File, m_aCompressedSnapshotData, ChunkSize) != (unsigned)ChunkSize)
696 {
697 Stop("Error reading chunk data");
698 break;
699 }
700
701 DataSize = CNetBase::Decompress(m_aCompressedSnapshotData, ChunkSize, m_aDecompressedSnapshotData, sizeof(m_aDecompressedSnapshotData));
702 if(DataSize < 0)
703 {
704 Stop("Error during network decompression");
705 break;
706 }
707
708 DataSize = CVariableInt::Decompress(m_aDecompressedSnapshotData, DataSize, m_aChunkData, sizeof(m_aChunkData));
709 if(DataSize < 0)
710 {
711 Stop("Error during intpack decompression");

Callers

nothing calls this directly

Calls 8

io_readFunction · 0.85
str_formatFunction · 0.85
mem_copyFunction · 0.85
UnpackDeltaMethod · 0.80
PrintMethod · 0.45
IsValidMethod · 0.45
OnDemoPlayerSnapshotMethod · 0.45
OnDemoPlayerMessageMethod · 0.45

Tested by

no test coverage detected