mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-19 22:48:18 +00:00
added support for receiving connless packets over a connection
Conflicts: src/engine/shared/network_client.cpp
This commit is contained in:
parent
1c15f404b2
commit
a92a2f5bdd
|
@ -80,7 +80,15 @@ int CNetClient::Recv(CNetChunk *pChunk, TOKEN *pResponseToken, int *pVersion)
|
||||||
if(net_addr_comp(m_Connection.PeerAddress(), &Addr) == 0)
|
if(net_addr_comp(m_Connection.PeerAddress(), &Addr) == 0)
|
||||||
{
|
{
|
||||||
if(m_Connection.State() != NET_CONNSTATE_OFFLINE && m_Connection.State() != NET_CONNSTATE_ERROR && m_Connection.Feed(&m_RecvUnpacker.m_Data, &Addr))
|
if(m_Connection.State() != NET_CONNSTATE_OFFLINE && m_Connection.State() != NET_CONNSTATE_ERROR && m_Connection.Feed(&m_RecvUnpacker.m_Data, &Addr))
|
||||||
m_RecvUnpacker.Start(&Addr, &m_Connection, 0);
|
if(!(m_RecvUnpacker.m_Data.m_Flags&NET_PACKETFLAG_CONNLESS))
|
||||||
|
m_RecvUnpacker.Start(&Addr, &m_Connection, 0);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
pChunk->m_ClientID = 0; // the server
|
||||||
|
pChunk->m_DataSize = m_RecvUnpacker.m_Data.m_DataSize;
|
||||||
|
pChunk->m_pData = m_RecvUnpacker.m_Data.m_aChunkData;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if(m_RecvUnpacker.m_Data.m_Flags&NET_PACKETFLAG_CONNLESS)
|
else if(m_RecvUnpacker.m_Data.m_Flags&NET_PACKETFLAG_CONNLESS)
|
||||||
{
|
{
|
||||||
|
|
|
@ -245,6 +245,9 @@ int CNetConnection::Feed(CNetPacketConstruct *pPacket, NETADDR *pAddr)
|
||||||
|
|
||||||
int64 Now = time_get();
|
int64 Now = time_get();
|
||||||
|
|
||||||
|
if(pPacket->m_Version != NET_PACKETVERSION)
|
||||||
|
return 0;
|
||||||
|
|
||||||
if(pPacket->m_Token == NET_TOKEN_NONE || pPacket->m_Token != m_Token)
|
if(pPacket->m_Token == NET_TOKEN_NONE || pPacket->m_Token != m_Token)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
@ -252,6 +255,9 @@ int CNetConnection::Feed(CNetPacketConstruct *pPacket, NETADDR *pAddr)
|
||||||
if(pPacket->m_Flags&NET_PACKETFLAG_RESEND)
|
if(pPacket->m_Flags&NET_PACKETFLAG_RESEND)
|
||||||
Resend();
|
Resend();
|
||||||
|
|
||||||
|
if(pPacket->m_Flags&NET_PACKETFLAG_CONNLESS)
|
||||||
|
return 1;
|
||||||
|
|
||||||
//
|
//
|
||||||
if(pPacket->m_Flags&NET_PACKETFLAG_CONTROL)
|
if(pPacket->m_Flags&NET_PACKETFLAG_CONTROL)
|
||||||
{
|
{
|
||||||
|
|
|
@ -122,7 +122,15 @@ int CNetServer::Recv(CNetChunk *pChunk, TOKEN *pResponseToken, int *pVersion)
|
||||||
if(m_aSlots[i].m_Connection.Feed(&m_RecvUnpacker.m_Data, &Addr))
|
if(m_aSlots[i].m_Connection.Feed(&m_RecvUnpacker.m_Data, &Addr))
|
||||||
{
|
{
|
||||||
if(m_RecvUnpacker.m_Data.m_DataSize)
|
if(m_RecvUnpacker.m_Data.m_DataSize)
|
||||||
m_RecvUnpacker.Start(&Addr, &m_aSlots[i].m_Connection, i);
|
if(!(m_RecvUnpacker.m_Data.m_Flags&NET_PACKETFLAG_CONNLESS))
|
||||||
|
m_RecvUnpacker.Start(&Addr, &m_aSlots[i].m_Connection, i);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
pChunk->m_ClientID = i;
|
||||||
|
pChunk->m_DataSize = m_RecvUnpacker.m_Data.m_DataSize;
|
||||||
|
pChunk->m_pData = m_RecvUnpacker.m_Data.m_aChunkData;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue