Fix close messages not being shown when connecting

Previously, close messages were entirely ignored during the connection
process, this meant that ban messages weren't shown to players. Instead,
they'd see the standard "no answer from server yet" message.

Fixes #5792.
This commit is contained in:
heinrich5991 2022-09-03 20:25:22 +02:00
parent 2346f221e1
commit 5028423a0a

View file

@ -308,7 +308,20 @@ int CNetConnection::Feed(CNetPacketConstruct *pPacket, NETADDR *pAddr, SECURITY_
if(CtrlMsg == NET_CTRLMSG_CLOSE)
{
if(net_addr_comp(&m_PeerAddr, pAddr) == 0)
bool IsPeer;
if(m_State != NET_CONNSTATE_CONNECT)
{
IsPeer = m_PeerAddr == *pAddr;
}
else
{
IsPeer = false;
for(int i = 0; i < m_NumConnectAddrs; i++)
{
IsPeer = IsPeer || m_aConnectAddrs[i] == *pAddr;
}
}
if(IsPeer)
{
m_State = NET_CONNSTATE_ERROR;
m_RemoteClosed = 1;