From ad070fe277420bed8ab55dbfdff103d1c9e983b7 Mon Sep 17 00:00:00 2001 From: heinrich5991 Date: Tue, 9 Oct 2012 17:01:14 +0200 Subject: [PATCH] fixed connless packets sending --- src/engine/shared/network.cpp | 4 ++-- src/engine/shared/network_server.cpp | 7 +++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/engine/shared/network.cpp b/src/engine/shared/network.cpp index 9f42b2676..7116aa308 100644 --- a/src/engine/shared/network.cpp +++ b/src/engine/shared/network.cpp @@ -105,8 +105,8 @@ void CNetBase::SendPacketConnless(NETSOCKET Socket, const NETADDR *pAddr, TOKEN aBuffer[10] = (ResponseToken>>8)&0xff; aBuffer[11] = (ResponseToken)&0xff; - mem_copy(&aBuffer[15], pData, DataSize); - net_udp_send(Socket, pAddr, aBuffer, 15+DataSize); + mem_copy(&aBuffer[NET_PACKETHEADERSIZE_CONNLESS], pData, DataSize); + net_udp_send(Socket, pAddr, aBuffer, NET_PACKETHEADERSIZE_CONNLESS+DataSize); } void CNetBase::SendPacket(NETSOCKET Socket, const NETADDR *pAddr, CNetPacketConstruct *pPacket) diff --git a/src/engine/shared/network_server.cpp b/src/engine/shared/network_server.cpp index 0b9aca0ef..adaac156e 100644 --- a/src/engine/shared/network_server.cpp +++ b/src/engine/shared/network_server.cpp @@ -155,11 +155,11 @@ int CNetServer::Recv(CNetChunk *pChunk, TOKEN *pResponseToken) } int Accept = m_TokenManager.ProcessMessage(&Addr, &m_RecvUnpacker.m_Data, true); - if(!Accept) - continue; if(m_RecvUnpacker.m_Data.m_Flags&NET_PACKETFLAG_CONTROL) { + if(!Accept) + continue; if(m_RecvUnpacker.m_Data.m_aChunkData[0] == NET_CTRLMSG_CONNECT) { bool Found = false; @@ -229,6 +229,9 @@ int CNetServer::Recv(CNetChunk *pChunk, TOKEN *pResponseToken) } else { + if(!Accept) + continue; + // TODO: check size here if(m_RecvUnpacker.m_Data.m_Flags&NET_PACKETFLAG_CONTROL && m_RecvUnpacker.m_Data.m_aChunkData[0] == NET_CTRLMSG_CONNECT) {