Migrate to 0.6.5 flags

This commit is contained in:
Learath 2020-04-13 12:27:30 +03:00
parent e36dc36b15
commit e9ba23b53a
2 changed files with 15 additions and 9 deletions

View file

@ -157,7 +157,7 @@ void CNetBase::SendPacket(NETSOCKET Socket, NETADDR *pAddr, CNetPacketConstruct
if(FinalSize >= 0)
{
FinalSize += NET_PACKETHEADERSIZE;
aBuffer[0] = ((pPacket->m_Flags<<4)&0xf0)|((pPacket->m_Ack>>8)&0xf);
aBuffer[0] = ((pPacket->m_Flags<<2)&0xfc)|((pPacket->m_Ack>>8)&0x3);
aBuffer[1] = pPacket->m_Ack&0xff;
aBuffer[2] = pPacket->m_NumChunks;
net_udp_send(Socket, pAddr, aBuffer, FinalSize);
@ -195,8 +195,8 @@ int CNetBase::UnpackPacket(unsigned char *pBuffer, int Size, CNetPacketConstruct
}
// read the packet
pPacket->m_Flags = pBuffer[0]>>4;
pPacket->m_Ack = ((pBuffer[0]&0xf)<<8) | pBuffer[1];
pPacket->m_Flags = pBuffer[0]>>2;
pPacket->m_Ack = ((pBuffer[0]&0x3)<<8) | pBuffer[1];
pPacket->m_NumChunks = pBuffer[2];
pPacket->m_DataSize = Size - NET_PACKETHEADERSIZE;

View file

@ -14,7 +14,11 @@
CURRENT:
packet header: 3 bytes
unsigned char flags_ack; // 4bit flags, 4bit ack
unsigned char flags_ack; // 6bit flags, 2bit ack
0.6: ORNCaaAA
0.6.5: ORNCTUAA
0.7: --NORCAA
unsigned char ack; // 8 bit ack
unsigned char num_chunks; // 8 bit chunks
@ -64,12 +68,14 @@ enum
NET_CONNSTATE_ONLINE=3,
NET_CONNSTATE_ERROR=4,
NET_PACKETFLAG_CONTROL=1,
NET_PACKETFLAG_CONNLESS=2,
NET_PACKETFLAG_RESEND=4,
NET_PACKETFLAG_COMPRESSION=8,
NET_PACKETFLAG_UNUSED=1<<0,
NET_PACKETFLAG_TOKEN=1<<1,
NET_PACKETFLAG_CONTROL=1<<2,
NET_PACKETFLAG_CONNLESS=1<<3,
NET_PACKETFLAG_RESEND=1<<4,
NET_PACKETFLAG_COMPRESSION=1<<5,
// NOT SENT VIA THE NETWORK DIRECTLY:
NET_PACKETFLAG_EXTENDED=16,
NET_PACKETFLAG_EXTENDED=1<<6,
NET_CHUNKFLAG_VITAL=1,
NET_CHUNKFLAG_RESEND=2,