Fixed some NQ protocol related endian problems.

git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@1176 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
Mark Olsen 2005-07-29 22:26:43 +00:00
parent fdec86754c
commit 3113fcad9e
4 changed files with 11 additions and 8 deletions

View File

@ -579,7 +579,7 @@ void CL_CheckForResend (void)
Con_TPrintf (TLC_CONNECTINGTO, cls.servername);
MSG_WriteLong(&sb, BigLong(NETFLAG_CTL | (strlen(NET_GAMENAME_NQ)+7)));
MSG_WriteLong(&sb, LongSwap(NETFLAG_CTL | (strlen(NET_GAMENAME_NQ)+7)));
MSG_WriteByte(&sb, CCREQ_CONNECT);
MSG_WriteString(&sb, NET_GAMENAME_NQ);
MSG_WriteByte(&sb, NET_PROTOCOL_VERSION);
@ -1970,7 +1970,7 @@ void CLNQ_ConnectionlessPacket(void)
int length;
MSG_BeginReading ();
length = BigLong(MSG_ReadLong ());
length = LongSwap(MSG_ReadLong ());
if (!(length & NETFLAG_CTL))
return; //not an nq control packet.
length &= NETFLAG_LENGTH_MASK;

View File

@ -109,6 +109,9 @@ extern int (*LittleLong) (int l);
extern float (*BigFloat) (float l);
extern float (*LittleFloat) (float l);
short ShortSwap (short l);
int LongSwap (int l);
//============================================================================
struct usercmd_s;

View File

@ -238,14 +238,14 @@ qboolean NQNetChan_Process(netchan_t *chan)
MSG_BeginReading ();
header = BigLong(MSG_ReadLong());
header = LongSwap(MSG_ReadLong());
if (net_message.cursize != (header & NETFLAG_LENGTH_MASK))
return false; //size was wrong, couldn't have been ours.
if (header & NETFLAG_CTL)
return false; //huh?
sequence = BigLong(MSG_ReadLong());
sequence = LongSwap(MSG_ReadLong());
if (header & NETFLAG_ACK)
{
@ -364,7 +364,7 @@ void Netchan_Transmit (netchan_t *chan, int length, qbyte *data, int rate)
if (i>0)
{
MSG_WriteLong(&send, 0);
MSG_WriteLong(&send, BigLong(chan->reliable_sequence));
MSG_WriteLong(&send, LongSwap(chan->reliable_sequence));
if (i > MAX_NQDATAGRAM)
i = MAX_NQDATAGRAM;
@ -392,7 +392,7 @@ void Netchan_Transmit (netchan_t *chan, int length, qbyte *data, int rate)
if (length)
{
MSG_WriteLong(&send, 0);
MSG_WriteLong(&send, BigLong(chan->outgoing_unreliable));
MSG_WriteLong(&send, LongSwap(chan->outgoing_unreliable));
chan->outgoing_unreliable++;
SZ_Write (&send, data, length);

View File

@ -1164,7 +1164,7 @@ void SV_AcceptMessage(int protocol)
SZ_Clear(&sb);
MSG_WriteLong(&sb, 0);
MSG_WriteByte(&sb, CCREP_ACCEPT);
MSG_WriteLong(&sb, BigShort(net_local_sv_ipadr.port));
MSG_WriteLong(&sb, ShortSwap(net_local_sv_ipadr.port));
*(int*)sb.data = BigLong(NETFLAG_CTL|sb.cursize);
NET_SendPacket(NS_SERVER, sb.cursize, sb.data, net_from);
return;
@ -2081,7 +2081,7 @@ void SVNQ_ConnectionlessPacket(void)
return; //no, start using dp7 instead.
MSG_BeginReading();
header = BigLong(MSG_ReadLong());
header = LongSwap(MSG_ReadLong());
if (!(header & NETFLAG_CTL))
return; //no idea what it is.