Merge pull request #8007 from heinrich5991/pr_ddnet_vital_ping

Respond to pings sent as vital messages with vital pongs
This commit is contained in:
Robert Müller 2024-02-26 12:22:46 +00:00 committed by GitHub
commit 2258cbca57
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 8 additions and 4 deletions

View file

@ -1509,7 +1509,8 @@ void CClient::ProcessServerPacket(CNetChunk *pPacket, int Conn, bool Dummy)
else if(Msg == NETMSG_PING)
{
CMsgPacker MsgP(NETMSG_PING_REPLY, true);
SendMsg(Conn, &MsgP, MSGFLAG_FLUSH);
int Vital = (pPacket->m_Flags & NET_CHUNKFLAG_VITAL) != 0 ? MSGFLAG_VITAL : 0;
SendMsg(Conn, &MsgP, MSGFLAG_FLUSH | Vital);
}
else if(Msg == NETMSG_PINGEX)
{
@ -1520,7 +1521,8 @@ void CClient::ProcessServerPacket(CNetChunk *pPacket, int Conn, bool Dummy)
}
CMsgPacker MsgP(NETMSG_PONGEX, true);
MsgP.AddRaw(pID, sizeof(*pID));
SendMsg(Conn, &MsgP, MSGFLAG_FLUSH);
int Vital = (pPacket->m_Flags & NET_CHUNKFLAG_VITAL) != 0 ? MSGFLAG_VITAL : 0;
SendMsg(Conn, &MsgP, MSGFLAG_FLUSH | Vital);
}
else if(Conn == CONN_MAIN && Msg == NETMSG_PONGEX)
{

View file

@ -1817,7 +1817,8 @@ void CServer::ProcessClientPacket(CNetChunk *pPacket)
else if(Msg == NETMSG_PING)
{
CMsgPacker Msgp(NETMSG_PING_REPLY, true);
SendMsg(&Msgp, MSGFLAG_FLUSH, ClientID);
int Vital = (pPacket->m_Flags & NET_CHUNKFLAG_VITAL) != 0 ? MSGFLAG_VITAL : 0;
SendMsg(&Msgp, MSGFLAG_FLUSH | Vital, ClientID);
}
else if(Msg == NETMSG_PINGEX)
{
@ -1828,7 +1829,8 @@ void CServer::ProcessClientPacket(CNetChunk *pPacket)
}
CMsgPacker Msgp(NETMSG_PONGEX, true);
Msgp.AddRaw(pID, sizeof(*pID));
SendMsg(&Msgp, MSGFLAG_FLUSH, ClientID);
int Vital = (pPacket->m_Flags & NET_CHUNKFLAG_VITAL) != 0 ? MSGFLAG_VITAL : 0;
SendMsg(&Msgp, MSGFLAG_FLUSH | Vital, ClientID);
}
else
{