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

Method OnMessage

src/game/client/components/statboard.cpp:51–123  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

49}
50
51void CStatboard::OnMessage(int MsgType, void *pRawMsg)
52{
53 if(GameClient()->m_SuppressEvents)
54 return;
55
56 if(MsgType == NETMSGTYPE_SV_KILLMSG)
57 {
58 CNetMsg_Sv_KillMsg *pMsg = (CNetMsg_Sv_KillMsg *)pRawMsg;
59 CGameClient::CClientStats *pStats = GameClient()->m_aStats;
60
61 pStats[pMsg->m_Victim].m_Deaths++;
62 pStats[pMsg->m_Victim].m_CurrentSpree = 0;
63 if(pMsg->m_Weapon >= 0)
64 pStats[pMsg->m_Victim].m_aDeathsFrom[pMsg->m_Weapon]++;
65 if(pMsg->m_Victim != pMsg->m_Killer)
66 {
67 pStats[pMsg->m_Killer].m_Frags++;
68 pStats[pMsg->m_Killer].m_CurrentSpree++;
69
70 if(pStats[pMsg->m_Killer].m_CurrentSpree > pStats[pMsg->m_Killer].m_BestSpree)
71 pStats[pMsg->m_Killer].m_BestSpree = pStats[pMsg->m_Killer].m_CurrentSpree;
72 if(pMsg->m_Weapon >= 0)
73 pStats[pMsg->m_Killer].m_aFragsWith[pMsg->m_Weapon]++;
74 }
75 else
76 pStats[pMsg->m_Victim].m_Suicides++;
77 }
78 else if(MsgType == NETMSGTYPE_SV_KILLMSGTEAM)
79 {
80 CNetMsg_Sv_KillMsgTeam *pMsg = (CNetMsg_Sv_KillMsgTeam *)pRawMsg;
81 CGameClient::CClientStats *pStats = GameClient()->m_aStats;
82
83 for(int i = 0; i < MAX_CLIENTS; i++)
84 {
85 if(GameClient()->m_Teams.Team(i) == pMsg->m_Team)
86 {
87 pStats[i].m_Deaths++;
88 pStats[i].m_Suicides++;
89 }
90 }
91 }
92 else if(MsgType == NETMSGTYPE_SV_CHAT)
93 {
94 CNetMsg_Sv_Chat *pMsg = (CNetMsg_Sv_Chat *)pRawMsg;
95 if(pMsg->m_ClientId < 0)
96 {
97 const char *p, *t;
98 const char *pLookFor = "flag was captured by '";
99 if((p = str_find(pMsg->m_pMessage, pLookFor)))
100 {
101 char aName[MAX_NAME_LENGTH];
102 p += str_length(pLookFor);
103 t = str_rchr(p, '\'');
104
105 if(t <= p)
106 return;
107 str_truncate(aName, sizeof(aName), p, t - p);
108

Callers

nothing calls this directly

Calls 7

str_findFunction · 0.85
str_lengthFunction · 0.85
str_rchrFunction · 0.85
str_truncateFunction · 0.85
str_compFunction · 0.85
TeamMethod · 0.45
IsActiveMethod · 0.45

Tested by

no test coverage detected