MCPcopy Create free account
hub / github.com/Warzone2100/warzone2100 / dumpLocalDebugSyncLog

Function dumpLocalDebugSyncLog

lib/netplay/sync_debug.cpp:681–707  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

679}
680
681static size_t dumpLocalDebugSyncLog(unsigned logIndex)
682{
683 if (debugSyncTmpBuf.size() < targetDebugSyncTmpBufSize)
684 {
685 debugSyncTmpBuf.clear();
686 debugSyncTmpBuf.resize(targetDebugSyncTmpBufSize);
687 }
688 const size_t bufSizeLimit = debugSyncTmpBuf.size();
689 size_t bufIndex = 0;
690 auto enforceLimit = [&bufIndex, &bufSizeLimit]() {
691 if (bufIndex > bufSizeLimit)
692 {
693 bufIndex = bufSizeLimit;
694 // grow buffer slightly for next debug sync log send (up to max)
695 targetDebugSyncTmpBufSize = std::min<size_t>(targetDebugSyncTmpBufSize + 500000, kMaxDebugSyncBufferSize);
696 }
697 };
698 // Dump our version, and also erase it, so we only dump it at most once.
699 bufIndex += snprintf((char*)debugSyncTmpBuf.data() + bufIndex, bufSizeLimit - bufIndex, "===== BEGIN gameTime=%u, %zu entries, CRC 0x%08X =====\n", syncDebugLog[logIndex].getGameTime(), syncDebugLog[logIndex].getNumEntries(), syncDebugLog[logIndex].getCrc());
700 enforceLimit(); // snprintf will not overflow debugSyncTmpBuf, but returns as much as it would have printed if possible.
701 bufIndex += syncDebugLog[logIndex].snprint((char*)debugSyncTmpBuf.data() + bufIndex, bufSizeLimit - bufIndex);
702 enforceLimit(); // snprintf will not overflow debugSyncTmpBuf, but returns as much as it would have printed if possible.
703 bufIndex += snprintf((char*)debugSyncTmpBuf.data() + bufIndex, bufSizeLimit - bufIndex, "===== END gameTime=%u, %zu entries, CRC 0x%08X =====\n", syncDebugLog[logIndex].getGameTime(), syncDebugLog[logIndex].getNumEntries(), syncDebugLog[logIndex].getCrc());
704 enforceLimit(); // snprintf will not overflow debugSyncTmpBuf, but returns as much as it would have printed if possible.
705
706 return bufIndex;
707}
708
709static size_t dumpLocalDebugSyncLogByTime(uint32_t time)
710{

Callers 2

checkDebugSyncFunction · 0.85

Calls 8

getGameTimeMethod · 0.80
getNumEntriesMethod · 0.80
getCrcMethod · 0.80
sizeMethod · 0.45
clearMethod · 0.45
resizeMethod · 0.45
dataMethod · 0.45
snprintMethod · 0.45

Tested by

no test coverage detected