Main Page | Class Hierarchy | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals

cl_net_chan.c File Reference

#include "../game/q_shared.h"
#include "../qcommon/qcommon.h"
#include "client.h"

Include dependency graph for cl_net_chan.c:

Include dependency graph

Go to the source code of this file.

Functions

void CL_Netchan_Decode (msg_t *msg)
void CL_Netchan_Encode (msg_t *msg)
qboolean CL_Netchan_Process (netchan_t *chan, msg_t *msg)
void CL_Netchan_Transmit (netchan_t *chan, msg_t *msg)
void CL_Netchan_TransmitNextFragment (netchan_t *chan)

Variables

int newsize = 0
int oldsize


Function Documentation

void CL_Netchan_Decode msg_t msg  )  [static]
 

Definition at line 92 of file cl_net_chan.c.

References msg_t::bit, byte, clientConnection_t::challenge, clc, msg_t::cursize, msg_t::data, i, LittleLong(), MAX_RELIABLE_COMMANDS, MSG_ReadLong(), msg_t::oob, msg_t::readcount, clientConnection_t::reliableCommands, and string().

Referenced by CL_Netchan_Process().

00092                                             {
00093     long reliableAcknowledge, i, index;
00094     byte key, *string;
00095         int srdc, sbit, soob;
00096 
00097         srdc = msg->readcount;
00098         sbit = msg->bit;
00099         soob = msg->oob;
00100         
00101         msg->oob = 0;
00102         
00103     reliableAcknowledge = MSG_ReadLong(msg);
00104 
00105         msg->oob = soob;
00106         msg->bit = sbit;
00107         msg->readcount = srdc;
00108 
00109     string = clc.reliableCommands[ reliableAcknowledge & (MAX_RELIABLE_COMMANDS-1) ];
00110     index = 0;
00111     // xor the client challenge with the netchan sequence number (need something that changes every message)
00112     key = clc.challenge ^ LittleLong( *(unsigned *)msg->data );
00113     for (i = msg->readcount + CL_DECODE_START; i < msg->cursize; i++) {
00114         // modify the key with the last sent and with this message acknowledged client command
00115         if (!string[index])
00116             index = 0;
00117         if (string[index] > 127 || string[index] == '%') {
00118             key ^= '.' << (i & 1);
00119         }
00120         else {
00121             key ^= string[index] << (i & 1);
00122         }
00123         index++;
00124         // decode the data with this key
00125         *(msg->data + i) = *(msg->data + i) ^ key;
00126     }
00127 }

Here is the call graph for this function:

void CL_Netchan_Encode msg_t msg  )  [static]
 

Definition at line 38 of file cl_net_chan.c.

References msg_t::bit, byte, clientConnection_t::challenge, clc, msg_t::cursize, msg_t::data, i, MAX_RELIABLE_COMMANDS, MSG_ReadLong(), msg_t::oob, msg_t::readcount, clientConnection_t::serverCommands, and string().

Referenced by CL_Netchan_Transmit().

00038                                             {
00039     int serverId, messageAcknowledge, reliableAcknowledge;
00040     int i, index, srdc, sbit, soob;
00041     byte key, *string;
00042 
00043     if ( msg->cursize <= CL_ENCODE_START ) {
00044         return;
00045     }
00046 
00047         srdc = msg->readcount;
00048         sbit = msg->bit;
00049         soob = msg->oob;
00050         
00051         msg->bit = 0;
00052         msg->readcount = 0;
00053         msg->oob = 0;
00054         
00055         serverId = MSG_ReadLong(msg);
00056     messageAcknowledge = MSG_ReadLong(msg);
00057     reliableAcknowledge = MSG_ReadLong(msg);
00058 
00059         msg->oob = soob;
00060         msg->bit = sbit;
00061         msg->readcount = srdc;
00062         
00063     string = (byte *)clc.serverCommands[ reliableAcknowledge & (MAX_RELIABLE_COMMANDS-1) ];
00064     index = 0;
00065     //
00066     key = clc.challenge ^ serverId ^ messageAcknowledge;
00067     for (i = CL_ENCODE_START; i < msg->cursize; i++) {
00068         // modify the key with the last received now acknowledged server command
00069         if (!string[index])
00070             index = 0;
00071         if (string[index] > 127 || string[index] == '%') {
00072             key ^= '.' << (i & 1);
00073         }
00074         else {
00075             key ^= string[index] << (i & 1);
00076         }
00077         index++;
00078         // encode the data with this key
00079         *(msg->data + i) = (*(msg->data + i)) ^ key;
00080     }
00081 }

Here is the call graph for this function:

qboolean CL_Netchan_Process netchan_t chan,
msg_t msg
 

Definition at line 158 of file cl_net_chan.c.

References CL_Netchan_Decode(), msg_t::cursize, Netchan_Process(), newsize, and qboolean.

Referenced by CL_PacketEvent().

00158                                                            {
00159     int ret;
00160 
00161     ret = Netchan_Process( chan, msg );
00162     if (!ret)
00163         return qfalse;
00164     CL_Netchan_Decode( msg );
00165     newsize += msg->cursize;
00166     return qtrue;
00167 }

Here is the call graph for this function:

void CL_Netchan_Transmit netchan_t chan,
msg_t msg
 

Definition at line 143 of file cl_net_chan.c.

References CL_Netchan_Encode(), clc_EOF, msg_t::cursize, msg_t::data, MSG_WriteByte(), and Netchan_Transmit().

Referenced by CL_WritePacket().

00143                                                         {
00144     MSG_WriteByte( msg, clc_EOF );
00145 
00146     CL_Netchan_Encode( msg );
00147     Netchan_Transmit( chan, msg->cursize, msg->data );
00148 }

Here is the call graph for this function:

void CL_Netchan_TransmitNextFragment netchan_t chan  ) 
 

Definition at line 134 of file cl_net_chan.c.

References Netchan_TransmitNextFragment().

Referenced by CL_WritePacket().

00134                                                         {
00135     Netchan_TransmitNextFragment( chan );
00136 }

Here is the call graph for this function:


Variable Documentation

int newsize = 0
 

Definition at line 151 of file cl_net_chan.c.

Referenced by CL_Netchan_Process(), idStr::EnsureAlloced(), and idList::SetGranularity().

int oldsize
 

Definition at line 40 of file msg.c.

Referenced by MSG_WriteBits(), MSG_WriteDeltaEntity(), MSG_WriteDeltaPlayerstate(), and MSG_WriteDeltaUsercmdKey().


Generated on Thu Aug 25 13:27:10 2005 for Quake III Arena by  doxygen 1.3.9.1