mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 01:58:19 +00:00
Fix client crash on team kill message with invalid team
The client crashes when a team kill message specifies a team for which no client can be found. This can easily happen when the server sends an unknown team on purpose. It may also happen sporadically during normal gameplay, assuming a team is dissolved or the last team member leaves at the same time as the kill message is received. The crash is fixed by not rendering any tee for these kill messages. The kill message text is always set depending on the team number in the team kill message, regardless of whether the team exists. Closes #6533.
This commit is contained in:
parent
0a37aa5c01
commit
be68c5ad7a
|
@ -112,7 +112,7 @@ void CKillMessages::OnMessage(int MsgType, void *pRawMsg)
|
|||
CNetMsg_Sv_KillMsgTeam *pMsg = (CNetMsg_Sv_KillMsgTeam *)pRawMsg;
|
||||
|
||||
// unpack messages
|
||||
CKillMsg Kill;
|
||||
CKillMsg Kill{};
|
||||
Kill.m_aVictimName[0] = '\0';
|
||||
Kill.m_aKillerName[0] = '\0';
|
||||
|
||||
|
@ -132,7 +132,7 @@ void CKillMessages::OnMessage(int MsgType, void *pRawMsg)
|
|||
if(Kill.m_TeamSize > MAX_KILLMSG_TEAM_MEMBERS)
|
||||
Kill.m_TeamSize = MAX_KILLMSG_TEAM_MEMBERS;
|
||||
|
||||
Kill.m_VictimID = vStrongWeakSorted[0].first;
|
||||
Kill.m_VictimID = vStrongWeakSorted.empty() ? -1 : vStrongWeakSorted[0].first;
|
||||
if(Kill.m_VictimID >= 0 && Kill.m_VictimID < MAX_CLIENTS)
|
||||
{
|
||||
Kill.m_VictimTeam = m_pClient->m_aClients[Kill.m_VictimID].m_Team;
|
||||
|
@ -141,9 +141,8 @@ void CKillMessages::OnMessage(int MsgType, void *pRawMsg)
|
|||
|
||||
for(int i = 1; i < Kill.m_TeamSize; i++)
|
||||
Kill.m_VictimRenderInfo[i] = m_pClient->m_aClients[vStrongWeakSorted[i].first].m_RenderInfo;
|
||||
|
||||
str_format(Kill.m_aVictimName, sizeof(Kill.m_aVictimName), Localize("Team %d"), Kill.m_VictimDDTeam);
|
||||
}
|
||||
str_format(Kill.m_aVictimName, sizeof(Kill.m_aVictimName), Localize("Team %d"), pMsg->m_Team);
|
||||
|
||||
Kill.m_KillerID = Kill.m_VictimID;
|
||||
|
||||
|
|
Loading…
Reference in a new issue