Print chat/broadcast times in demo_extract_chat tool

This makes it easier to find the times of specific chat messages and broadcasts in demos.
This commit is contained in:
Robert Müller 2024-08-11 18:18:14 +02:00
parent dd9e013c8a
commit 17f13b9f97

View file

@ -151,6 +151,10 @@ public:
if(!pRawMsg) if(!pRawMsg)
return; 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) if(Msg == NETMSGTYPE_SV_CHAT)
{ {
CNetMsg_Sv_Chat *pMsg = (CNetMsg_Sv_Chat *)pRawMsg; CNetMsg_Sv_Chat *pMsg = (CNetMsg_Sv_Chat *)pRawMsg;
@ -162,16 +166,16 @@ public:
if(pMsg->m_ClientId < 0) if(pMsg->m_ClientId < 0)
{ {
printf("%s: *** %s\n", Prefix, pMsg->m_pMessage); printf("[%s] %s: *** %s\n", aTime, Prefix, pMsg->m_pMessage);
return; return;
} }
if(pMsg->m_Team == TEAM_WHISPER_SEND) 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) 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 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) else if(Msg == NETMSGTYPE_SV_BROADCAST)
{ {
@ -181,7 +185,7 @@ public:
{ {
if(aBroadcast[0] != '\0') if(aBroadcast[0] != '\0')
{ {
printf("broadcast: %s\n", aBroadcast); printf("[%s] broadcast: %s\n", aTime, aBroadcast);
} }
} }
} }