Skip to content

Commit

Permalink
Print chat/broadcast times in demo_extract_chat tool
Browse files Browse the repository at this point in the history
This makes it easier to find the times of specific chat messages and broadcasts in demos.
  • Loading branch information
Robyt3 committed Aug 14, 2024
1 parent dd9e013 commit 17f13b9
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/tools/demo_extract_chat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,10 @@ class CDemoPlayerMessageListener : public CDemoPlayer::IListener
if(!pRawMsg)
return;

const IDemoPlayer::CInfo &Info = m_pDemoPlayer->Info()->m_Info;
char aTime[20];
str_time((int64_t)(Info.m_CurrentTick - Info.m_FirstTick) / SERVER_TICK_SPEED * 100, TIME_HOURS, aTime, sizeof(aTime));

if(Msg == NETMSGTYPE_SV_CHAT)
{
CNetMsg_Sv_Chat *pMsg = (CNetMsg_Sv_Chat *)pRawMsg;
Expand All @@ -162,16 +166,16 @@ class CDemoPlayerMessageListener : public CDemoPlayer::IListener

if(pMsg->m_ClientId < 0)
{
printf("%s: *** %s\n", Prefix, pMsg->m_pMessage);
printf("[%s] %s: *** %s\n", aTime, Prefix, pMsg->m_pMessage);
return;
}

if(pMsg->m_Team == TEAM_WHISPER_SEND)
printf("%s: -> %s: %s\n", Prefix, m_pClientSnapshotHandler->m_aClients[pMsg->m_ClientId].m_aName, pMsg->m_pMessage);
printf("[%s] %s: -> %s: %s\n", aTime, Prefix, m_pClientSnapshotHandler->m_aClients[pMsg->m_ClientId].m_aName, pMsg->m_pMessage);
else if(pMsg->m_Team == TEAM_WHISPER_RECV)
printf("%s: <- %s: %s\n", Prefix, m_pClientSnapshotHandler->m_aClients[pMsg->m_ClientId].m_aName, pMsg->m_pMessage);
printf("[%s] %s: <- %s: %s\n", aTime, Prefix, m_pClientSnapshotHandler->m_aClients[pMsg->m_ClientId].m_aName, pMsg->m_pMessage);
else
printf("%s: %s: %s\n", Prefix, m_pClientSnapshotHandler->m_aClients[pMsg->m_ClientId].m_aName, pMsg->m_pMessage);
printf("[%s] %s: %s: %s\n", aTime, Prefix, m_pClientSnapshotHandler->m_aClients[pMsg->m_ClientId].m_aName, pMsg->m_pMessage);
}
else if(Msg == NETMSGTYPE_SV_BROADCAST)
{
Expand All @@ -181,7 +185,7 @@ class CDemoPlayerMessageListener : public CDemoPlayer::IListener
{
if(aBroadcast[0] != '\0')
{
printf("broadcast: %s\n", aBroadcast);
printf("[%s] broadcast: %s\n", aTime, aBroadcast);
}
}
}
Expand Down

0 comments on commit 17f13b9

Please sign in to comment.