added support for receiving connless packets over a connection

Conflicts:
	src/engine/shared/network_client.cpp
This commit is contained in:
heinrich5991 2012-04-15 15:43:42 +02:00 committed by oy
parent 1c15f404b2
commit a92a2f5bdd
3 changed files with 24 additions and 2 deletions

View file

@ -80,7 +80,15 @@ int CNetClient::Recv(CNetChunk *pChunk, TOKEN *pResponseToken, int *pVersion)
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))
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)
{

View file

@ -245,6 +245,9 @@ int CNetConnection::Feed(CNetPacketConstruct *pPacket, NETADDR *pAddr)
int64 Now = time_get();
if(pPacket->m_Version != NET_PACKETVERSION)
return 0;
if(pPacket->m_Token == NET_TOKEN_NONE || pPacket->m_Token != m_Token)
return 0;
@ -252,6 +255,9 @@ int CNetConnection::Feed(CNetPacketConstruct *pPacket, NETADDR *pAddr)
if(pPacket->m_Flags&NET_PACKETFLAG_RESEND)
Resend();
if(pPacket->m_Flags&NET_PACKETFLAG_CONNLESS)
return 1;
//
if(pPacket->m_Flags&NET_PACKETFLAG_CONTROL)
{

View file

@ -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_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;
}