DarkPlaces
Game engine based on the Quake 1 engine by id Software, developed by LadyHavoc
 
com_msg.c File Reference
#include "quakedef.h"
+ Include dependency graph for com_msg.c:

Go to the source code of this file.

Functions

float BuffBigFloat (const unsigned char *buffer)
 Extract a big endian 32bit float from the given buffer.
 
int BuffBigLong (const unsigned char *buffer)
 Extract a big endian 32bit int from the given buffer.
 
short BuffBigShort (const unsigned char *buffer)
 Extract a big endian 16bit short from the given buffer.
 
float BuffLittleFloat (const unsigned char *buffer)
 Extract a little endian 32bit float from the given buffer.
 
int BuffLittleLong (const unsigned char *buffer)
 Extract a little endian 32bit int from the given buffer.
 
short BuffLittleShort (const unsigned char *buffer)
 Extract a little endian 16bit short from the given buffer.
 
void MSG_BeginReading (sizebuf_t *sb)
 
void MSG_InitReadBuffer (sizebuf_t *buf, unsigned char *data, int size)
 
float MSG_ReadAngle (sizebuf_t *sb, protocolversion_t protocol)
 
float MSG_ReadAngle16i (sizebuf_t *sb)
 
float MSG_ReadAngle32f (sizebuf_t *sb)
 
float MSG_ReadAngle8i (sizebuf_t *sb)
 
float MSG_ReadBigFloat (sizebuf_t *sb)
 
int MSG_ReadBigLong (sizebuf_t *sb)
 
int MSG_ReadBigShort (sizebuf_t *sb)
 
size_t MSG_ReadBytes (sizebuf_t *sb, size_t numbytes, unsigned char *out)
 
float MSG_ReadCoord (sizebuf_t *sb, protocolversion_t protocol)
 
float MSG_ReadCoord13i (sizebuf_t *sb)
 
float MSG_ReadCoord16i (sizebuf_t *sb)
 
float MSG_ReadCoord32f (sizebuf_t *sb)
 
float MSG_ReadLittleFloat (sizebuf_t *sb)
 
int MSG_ReadLittleLong (sizebuf_t *sb)
 
int MSG_ReadLittleShort (sizebuf_t *sb)
 
char * MSG_ReadString (sizebuf_t *sb, char *string, size_t maxstring)
 
size_t MSG_ReadString_len (sizebuf_t *sb, char *string, size_t maxstring)
 Same as MSG_ReadString except it returns the number of bytes written to *string excluding the \0 terminator.
 
void MSG_ReadVector (sizebuf_t *sb, vec3_t v, protocolversion_t protocol)
 
void MSG_WriteAngle (sizebuf_t *sb, float f, protocolversion_t protocol)
 
void MSG_WriteAngle16i (sizebuf_t *sb, float f)
 
void MSG_WriteAngle32f (sizebuf_t *sb, float f)
 
void MSG_WriteAngle8i (sizebuf_t *sb, float f)
 
void MSG_WriteByte (sizebuf_t *sb, int c)
 
void MSG_WriteChar (sizebuf_t *sb, int c)
 
void MSG_WriteCoord (sizebuf_t *sb, float f, protocolversion_t protocol)
 
void MSG_WriteCoord13i (sizebuf_t *sb, float f)
 
void MSG_WriteCoord16i (sizebuf_t *sb, float f)
 
void MSG_WriteCoord32f (sizebuf_t *sb, float f)
 
void MSG_WriteFloat (sizebuf_t *sb, float f)
 
void MSG_WriteLong (sizebuf_t *sb, int c)
 
void MSG_WriteShort (sizebuf_t *sb, int c)
 
void MSG_WriteString (sizebuf_t *sb, const char *s)
 
void MSG_WriteUnterminatedString (sizebuf_t *sb, const char *s)
 
void MSG_WriteVector (sizebuf_t *sb, const vec3_t v, protocolversion_t protocol)
 
void StoreBigLong (unsigned char *buffer, unsigned int i)
 Encode a big endian 32bit int to the given buffer.
 
void StoreBigShort (unsigned char *buffer, unsigned short i)
 Encode a big endian 16bit int to the given buffer.
 
void StoreLittleLong (unsigned char *buffer, unsigned int i)
 Encode a little endian 32bit int to the given buffer.
 
void StoreLittleShort (unsigned char *buffer, unsigned short i)
 Encode a little endian 16bit int to the given buffer.
 

Function Documentation

◆ BuffBigFloat()

float BuffBigFloat ( const unsigned char * buffer)

Extract a big endian 32bit float from the given buffer.

Definition at line 37 of file com_msg.c.

38{
39 union
40 {
41 float f;
42 unsigned int i;
43 }
44 u;
45 u.i = ((unsigned)buffer[0] << 24) | (buffer[1] << 16) | (buffer[2] << 8) | buffer[3];
46 return u.f;
47}
GLuint buffer
Definition glquake.h:630
int i
float f

References buffer, f, and i.

◆ BuffBigLong()

int BuffBigLong ( const unsigned char * buffer)

Extract a big endian 32bit int from the given buffer.

Definition at line 49 of file com_msg.c.

50{
51 return ((unsigned)buffer[0] << 24) | (buffer[1] << 16) | (buffer[2] << 8) | buffer[3];
52}

References buffer.

Referenced by Crypto_DecryptPacket(), Crypto_EncryptPacket(), NetConn_ClientParsePacket(), NetConn_ReceivedMessage(), NetConn_ServerParsePacket(), PK3_BuildFileList(), PK3_GetEndOfCentralDir(), and PK3_GetTrueFileOffset().

◆ BuffBigShort()

short BuffBigShort ( const unsigned char * buffer)

Extract a big endian 16bit short from the given buffer.

Definition at line 54 of file com_msg.c.

55{
56 return (buffer[0] << 8) | buffer[1];
57}

References buffer.

◆ BuffLittleFloat()

float BuffLittleFloat ( const unsigned char * buffer)

Extract a little endian 32bit float from the given buffer.

Definition at line 59 of file com_msg.c.

60{
61 union
62 {
63 float f;
64 unsigned int i;
65 }
66 u;
67 u.i = ((unsigned)buffer[3] << 24) | (buffer[2] << 16) | (buffer[1] << 8) | buffer[0];
68 return u.f;
69}

References buffer, f, and i.

◆ BuffLittleLong()

int BuffLittleLong ( const unsigned char * buffer)

Extract a little endian 32bit int from the given buffer.

Definition at line 71 of file com_msg.c.

72{
73 return ((unsigned)buffer[3] << 24) | (buffer[2] << 16) | (buffer[1] << 8) | buffer[0];
74}

References buffer.

Referenced by Crypto_ClientParsePacket(), GetLittleLong(), GetMapList(), Mod_Q1BSP_LoadFaces(), PK3_BuildFileList(), and R_LoadTextureDDSFile().

◆ BuffLittleShort()

short BuffLittleShort ( const unsigned char * buffer)

Extract a little endian 16bit short from the given buffer.

Definition at line 76 of file com_msg.c.

77{
78 return (buffer[1] << 8) | buffer[0];
79}

References buffer.

Referenced by GetLittleShort(), Mod_Q1BSP_LoadFaces(), Mod_VBSP_LoadFaces(), PK3_BuildFileList(), and PK3_GetTrueFileOffset().

◆ MSG_BeginReading()

void MSG_BeginReading ( sizebuf_t * sb)

◆ MSG_InitReadBuffer()

void MSG_InitReadBuffer ( sizebuf_t * buf,
unsigned char * data,
int size )

Definition at line 249 of file com_msg.c.

250{
251 memset(buf, 0, sizeof(*buf));
252 buf->data = data;
253 buf->maxsize = buf->cursize = size;
255}
void MSG_BeginReading(sizebuf_t *sb)
Definition com_msg.c:257
vector size
GLsizeiptr const GLvoid * data
Definition glquake.h:639
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition glquake.h:657

References buf, data, MSG_BeginReading(), and size.

Referenced by Mod_Q1BSP_Load(), Mod_Q1BSP_LoadTextures(), Mod_Q2BSP_Load(), Mod_VBSP_Load(), and W_GetTextureBGRA().

◆ MSG_ReadAngle()

float MSG_ReadAngle ( sizebuf_t * sb,
protocolversion_t protocol )

Definition at line 424 of file com_msg.c.

425{
426 if (protocol == PROTOCOL_QUAKE || protocol == PROTOCOL_QUAKEDP || protocol == PROTOCOL_NEHAHRAMOVIE || protocol == PROTOCOL_NEHAHRABJP || protocol == PROTOCOL_NEHAHRABJP2 || protocol == PROTOCOL_NEHAHRABJP3 || protocol == PROTOCOL_DARKPLACES1 || protocol == PROTOCOL_DARKPLACES2 || protocol == PROTOCOL_DARKPLACES3 || protocol == PROTOCOL_DARKPLACES4 || protocol == PROTOCOL_QUAKEWORLD)
427 return MSG_ReadAngle8i (sb);
428 else
429 return MSG_ReadAngle16i (sb);
430}
float MSG_ReadAngle8i(sizebuf_t *sb)
Definition com_msg.c:409
float MSG_ReadAngle16i(sizebuf_t *sb)
Definition com_msg.c:414
@ PROTOCOL_DARKPLACES2
various changes
Definition common.h:140
@ PROTOCOL_DARKPLACES4
various changes
Definition common.h:138
@ PROTOCOL_NEHAHRABJP2
same as NEHAHRABJP but with 16bit soundindex
Definition common.h:147
@ PROTOCOL_DARKPLACES3
uses EntityFrame4 entity snapshot encoder/decoder which is broken, this attempted to do partial snaps...
Definition common.h:139
@ PROTOCOL_NEHAHRABJP
same as QUAKEDP but with 16bit modelindex
Definition common.h:146
@ PROTOCOL_QUAKEDP
darkplaces extended quake protocol (used by TomazQuake and others), backwards compatible as long as n...
Definition common.h:142
@ PROTOCOL_QUAKE
quake (aka netquake/normalquake/nq) protocol
Definition common.h:144
@ PROTOCOL_NEHAHRABJP3
same as NEHAHRABJP2 but with some changes
Definition common.h:148
@ PROTOCOL_NEHAHRAMOVIE
Nehahra movie protocol, a big nasty hack dating back to early days of the Quake Standards Group (but ...
Definition common.h:143
@ PROTOCOL_QUAKEWORLD
quakeworld protocol
Definition common.h:145
@ PROTOCOL_DARKPLACES1
uses EntityFrame entity snapshot encoder/decoder which is a QuakeWorld-like entity snapshot delta com...
Definition common.h:141

References MSG_ReadAngle16i(), MSG_ReadAngle8i(), PROTOCOL_DARKPLACES1, PROTOCOL_DARKPLACES2, PROTOCOL_DARKPLACES3, PROTOCOL_DARKPLACES4, PROTOCOL_NEHAHRABJP, PROTOCOL_NEHAHRABJP2, PROTOCOL_NEHAHRABJP3, PROTOCOL_NEHAHRAMOVIE, PROTOCOL_QUAKE, PROTOCOL_QUAKEDP, and PROTOCOL_QUAKEWORLD.

Referenced by CL_ParseBaseline(), CL_ParseServerMessage(), EntityFrameQuake_ReadEntity(), and VM_CL_ReadAngle().

◆ MSG_ReadAngle16i()

float MSG_ReadAngle16i ( sizebuf_t * sb)

Definition at line 414 of file com_msg.c.

415{
416 return (signed short)MSG_ReadShort (sb) * (360.0/65536.0);
417}
#define MSG_ReadShort
Definition common.h:191

References MSG_ReadShort.

Referenced by CL_ParseClientdata(), EntityState5_ReadUpdate(), EntityState_ReadFields(), EntityStateQW_ReadPlayerUpdate(), MSG_ReadAngle(), and SV_ReadClientMove().

◆ MSG_ReadAngle32f()

float MSG_ReadAngle32f ( sizebuf_t * sb)

Definition at line 419 of file com_msg.c.

420{
421 return MSG_ReadFloat (sb);
422}
#define MSG_ReadFloat
Definition common.h:193

References MSG_ReadFloat.

Referenced by SV_ReadClientMove().

◆ MSG_ReadAngle8i()

float MSG_ReadAngle8i ( sizebuf_t * sb)

Definition at line 409 of file com_msg.c.

410{
411 return (signed char) MSG_ReadByte (sb) * (360.0/256.0);
412}
#define MSG_ReadByte(sb)
Definition common.h:188

References MSG_ReadByte.

Referenced by EntityState5_ReadUpdate(), EntityState_ReadFields(), EntityStateQW_ReadEntityUpdate(), MSG_ReadAngle(), and SV_ReadClientMove().

◆ MSG_ReadBigFloat()

float MSG_ReadBigFloat ( sizebuf_t * sb)

Definition at line 324 of file com_msg.c.

325{
326 union
327 {
328 float f;
329 int l;
330 } dat;
331 if (sb->readcount+4 > sb->cursize)
332 {
333 sb->badread = true;
334 return -1;
335 }
336 sb->readcount += 4;
337 dat.l = ((unsigned)sb->data[sb->readcount-4]<<24) | (sb->data[sb->readcount-3]<<16) | (sb->data[sb->readcount-2]<<8) | sb->data[sb->readcount-1];
338 return dat.f;
339}
unsigned char * data
Definition common.h:52
int cursize
Definition common.h:54

References sizebuf_t::badread, sizebuf_t::cursize, sizebuf_t::data, f, and sizebuf_t::readcount.

◆ MSG_ReadBigLong()

int MSG_ReadBigLong ( sizebuf_t * sb)

Definition at line 296 of file com_msg.c.

297{
298 if (sb->readcount+4 > sb->cursize)
299 {
300 sb->badread = true;
301 return -1;
302 }
303 sb->readcount += 4;
304 return ((unsigned)sb->data[sb->readcount-4]<<24) + (sb->data[sb->readcount-3]<<16) + (sb->data[sb->readcount-2]<<8) + sb->data[sb->readcount-1];
305}

References sizebuf_t::badread, sizebuf_t::cursize, sizebuf_t::data, and sizebuf_t::readcount.

◆ MSG_ReadBigShort()

int MSG_ReadBigShort ( sizebuf_t * sb)

Definition at line 274 of file com_msg.c.

275{
276 if (sb->readcount+2 > sb->cursize)
277 {
278 sb->badread = true;
279 return -1;
280 }
281 sb->readcount += 2;
282 return (short)((sb->data[sb->readcount-2]<<8) + sb->data[sb->readcount-1]);
283}

References sizebuf_t::badread, sizebuf_t::cursize, sizebuf_t::data, and sizebuf_t::readcount.

◆ MSG_ReadBytes()

size_t MSG_ReadBytes ( sizebuf_t * sb,
size_t numbytes,
unsigned char * out )

Definition at line 364 of file com_msg.c.

365{
366 size_t l = 0;
367
368 // when numbytes have been read sb->readcount won't be advanced any further
369 while (l < numbytes && !sb->badread)
370 out[l++] = MSG_ReadByte_opt(sb);
371 return l;
372}
#define MSG_ReadByte_opt(sb)
Same as MSG_ReadByte but with no need to copy twice (first to int to check for -1) so each byte can b...
Definition common.h:190

References MSG_ReadByte_opt.

Referenced by CL_ParseDownload(), Mod_Q1BSP_LoadEntities(), Mod_Q1BSP_LoadVisibility(), Mod_Q2BSP_LoadLighting(), Mod_Q2BSP_LoadTexinfo(), Mod_VBSP_LoadEntities(), QW_CL_ParseDownload(), VM_CL_ReadPicture(), and W_ConvertWAD3TextureBGRA().

◆ MSG_ReadCoord()

float MSG_ReadCoord ( sizebuf_t * sb,
protocolversion_t protocol )

Definition at line 389 of file com_msg.c.

390{
391 if (protocol == PROTOCOL_QUAKE || protocol == PROTOCOL_QUAKEDP || protocol == PROTOCOL_NEHAHRAMOVIE || protocol == PROTOCOL_NEHAHRABJP || protocol == PROTOCOL_NEHAHRABJP2 || protocol == PROTOCOL_NEHAHRABJP3 || protocol == PROTOCOL_QUAKEWORLD)
392 return MSG_ReadCoord13i(sb);
393 else if (protocol == PROTOCOL_DARKPLACES1)
394 return MSG_ReadCoord32f(sb);
395 else if (protocol == PROTOCOL_DARKPLACES2 || protocol == PROTOCOL_DARKPLACES3 || protocol == PROTOCOL_DARKPLACES4)
396 return MSG_ReadCoord16i(sb);
397 else
398 return MSG_ReadCoord32f(sb);
399}
float MSG_ReadCoord32f(sizebuf_t *sb)
Definition com_msg.c:384
float MSG_ReadCoord13i(sizebuf_t *sb)
Definition com_msg.c:374
float MSG_ReadCoord16i(sizebuf_t *sb)
Definition com_msg.c:379

References MSG_ReadCoord13i(), MSG_ReadCoord16i(), MSG_ReadCoord32f(), PROTOCOL_DARKPLACES1, PROTOCOL_DARKPLACES2, PROTOCOL_DARKPLACES3, PROTOCOL_DARKPLACES4, PROTOCOL_NEHAHRABJP, PROTOCOL_NEHAHRABJP2, PROTOCOL_NEHAHRABJP3, PROTOCOL_NEHAHRAMOVIE, PROTOCOL_QUAKE, PROTOCOL_QUAKEDP, and PROTOCOL_QUAKEWORLD.

Referenced by CL_ParseBaseline(), CL_ParseServerMessage(), CL_ParseTempEntity(), EntityFrameQuake_ReadEntity(), MSG_ReadVector(), and VM_CL_ReadCoord().

◆ MSG_ReadCoord13i()

float MSG_ReadCoord13i ( sizebuf_t * sb)

Definition at line 374 of file com_msg.c.

375{
376 return MSG_ReadLittleShort(sb) * (1.0/8.0);
377}
int MSG_ReadLittleShort(sizebuf_t *sb)
Definition com_msg.c:263

References MSG_ReadLittleShort().

Referenced by EntityState5_ReadUpdate(), EntityStateQW_ReadEntityUpdate(), and MSG_ReadCoord().

◆ MSG_ReadCoord16i()

float MSG_ReadCoord16i ( sizebuf_t * sb)

Definition at line 379 of file com_msg.c.

380{
381 return (signed short) MSG_ReadLittleShort(sb);
382}

References MSG_ReadLittleShort().

Referenced by CL_ParseClientdata(), EntityState_ReadFields(), MSG_ReadCoord(), and SV_ReadClientMove().

◆ MSG_ReadCoord32f()

float MSG_ReadCoord32f ( sizebuf_t * sb)

Definition at line 384 of file com_msg.c.

385{
386 return MSG_ReadLittleFloat(sb);
387}
float MSG_ReadLittleFloat(sizebuf_t *sb)
Definition com_msg.c:307

References MSG_ReadLittleFloat().

Referenced by CL_ParseClientdata(), EntityState5_ReadUpdate(), EntityState_ReadFields(), and MSG_ReadCoord().

◆ MSG_ReadLittleFloat()

float MSG_ReadLittleFloat ( sizebuf_t * sb)

Definition at line 307 of file com_msg.c.

308{
309 union
310 {
311 float f;
312 int l;
313 } dat;
314 if (sb->readcount+4 > sb->cursize)
315 {
316 sb->badread = true;
317 return -1;
318 }
319 sb->readcount += 4;
320 dat.l = sb->data[sb->readcount-4] | (sb->data[sb->readcount-3]<<8) | (sb->data[sb->readcount-2]<<16) | ((unsigned)sb->data[sb->readcount-1]<<24);
321 return dat.f;
322}

References sizebuf_t::badread, sizebuf_t::cursize, sizebuf_t::data, f, and sizebuf_t::readcount.

Referenced by Mod_BSP_LoadSubmodels(), Mod_Q1BSP_LoadLeafs(), Mod_Q1BSP_LoadNodes(), Mod_Q1BSP_LoadPlanes(), Mod_Q1BSP_LoadTexinfo(), Mod_Q1BSP_LoadVertexes(), Mod_Q2BSP_LoadTexinfo(), Mod_VBSP_LoadPlanes(), Mod_VBSP_LoadTexinfo(), Mod_VBSP_LoadVertexes(), and MSG_ReadCoord32f().

◆ MSG_ReadLittleLong()

◆ MSG_ReadLittleShort()

◆ MSG_ReadString()

char * MSG_ReadString ( sizebuf_t * sb,
char * string,
size_t maxstring )

Definition at line 341 of file com_msg.c.

342{
343 size_t l = 0;
344
345 // read string into sbfer, but only store as many characters as will fit
346 // if dest buffer is full sb->readcount will still be advanced to end of message string
347 while ((string[l] = MSG_ReadByte_opt(sb)) != '\0')
348 if (l < maxstring)
349 ++l;
350 return string;
351}
GLsizei const GLchar ** string
Definition glquake.h:728

References MSG_ReadByte_opt, and string.

Referenced by CL_ParseServerInfo(), CL_ParseServerMessage(), CL_ParseTempEntity(), NetConn_ClientParsePacket(), NetConn_ServerParsePacket(), QW_CL_ParseModelList(), QW_CL_ParseSoundList(), QW_CL_ServerInfo(), QW_CL_SetInfo(), QW_CL_UpdateUserInfo(), SHOWLMP_decodehide(), SHOWLMP_decodeshow(), and SV_ReadClientMessage().

◆ MSG_ReadString_len()

size_t MSG_ReadString_len ( sizebuf_t * sb,
char * string,
size_t maxstring )

Same as MSG_ReadString except it returns the number of bytes written to *string excluding the \0 terminator.

Definition at line 352 of file com_msg.c.

353{
354 size_t l = 0;
355
356 // read string into sbfer, but only store as many characters as will fit
357 // if dest buffer is full sb->readcount will still be advanced to end of message string
358 while ((string[l] = MSG_ReadByte_opt(sb)) != '\0')
359 if (l < maxstring)
360 ++l;
361 return l;
362}

References MSG_ReadByte_opt.

Referenced by CL_ParseServerMessage(), SV_ReadClientMessage(), VM_CL_ReadPicture(), and VM_CL_ReadString().

◆ MSG_ReadVector()

void MSG_ReadVector ( sizebuf_t * sb,
vec3_t v,
protocolversion_t protocol )

Definition at line 401 of file com_msg.c.

402{
403 v[0] = MSG_ReadCoord(sb, protocol);
404 v[1] = MSG_ReadCoord(sb, protocol);
405 v[2] = MSG_ReadCoord(sb, protocol);
406}
float MSG_ReadCoord(sizebuf_t *sb, protocolversion_t protocol)
Definition com_msg.c:389
const GLdouble * v
Definition glquake.h:762

References MSG_ReadCoord(), and v.

Referenced by CL_ParseBeam(), CL_ParseEffect(), CL_ParseEffect2(), CL_ParseParticleEffect(), CL_ParsePointParticles(), CL_ParsePointParticles1(), CL_ParseServerMessage(), CL_ParseStartSoundPacket(), CL_ParseStaticSound(), CL_ParseTempEntity(), CL_ParseTrailParticles(), EntityStateQW_ReadPlayerUpdate(), and V_ParseDamage().

◆ MSG_WriteAngle()

◆ MSG_WriteAngle16i()

void MSG_WriteAngle16i ( sizebuf_t * sb,
float f )

Definition at line 227 of file com_msg.c.

228{
229 MSG_WriteShort (sb, (int)Q_rint(f*(65536.0/360.0)) & 65535);
230}
void MSG_WriteShort(sizebuf_t *sb, int c)
Definition com_msg.c:138
#define Q_rint(x)
Definition mathlib.h:69

References f, MSG_WriteShort(), and Q_rint.

Referenced by CL_SendMove(), EntityState5_WriteUpdate(), EntityState_WriteFields(), MSG_WriteAngle(), QW_MSG_WriteDeltaUsercmd(), and SV_WriteClientdataToMessage().

◆ MSG_WriteAngle32f()

void MSG_WriteAngle32f ( sizebuf_t * sb,
float f )

Definition at line 232 of file com_msg.c.

233{
234 MSG_WriteFloat (sb, f);
235}
void MSG_WriteFloat(sizebuf_t *sb, float f)
Definition com_msg.c:158

References f, and MSG_WriteFloat().

Referenced by CL_SendMove().

◆ MSG_WriteAngle8i()

void MSG_WriteAngle8i ( sizebuf_t * sb,
float f )

Definition at line 222 of file com_msg.c.

223{
224 MSG_WriteByte (sb, (int)Q_rint(f*(256.0/360.0)) & 255);
225}
void MSG_WriteByte(sizebuf_t *sb, int c)
Definition com_msg.c:130

References f, MSG_WriteByte(), and Q_rint.

Referenced by CL_SendMove(), EntityState5_WriteUpdate(), EntityState_WriteFields(), and MSG_WriteAngle().

◆ MSG_WriteByte()

void MSG_WriteByte ( sizebuf_t * sb,
int c )

Definition at line 130 of file com_msg.c.

131{
132 unsigned char *buf;
133
134 buf = SZ_GetSpace (sb, 1);
135 buf[0] = c;
136}
unsigned char * SZ_GetSpace(sizebuf_t *buf, int length)
Definition common.c:49

References buf, and SZ_GetSpace().

Referenced by CL_DisconnectEx(), CL_ForwardToServer(), CL_ParseServerInfo(), CL_PQRcon_f(), CL_SendMove(), CL_SendPlayerInfo(), CL_SetInfo(), CL_SignonReply(), CL_Stop_f(), Cvar_SetQuick_Internal(), EntityFrame4_WriteFrame(), EntityFrame5_WriteFrame(), EntityFrame_WriteFrame(), EntityFrameCSQC_WriteFrame(), EntityFrameQuake_WriteFrame(), EntityState5_WriteUpdate(), EntityState_WriteExtendBits(), EntityState_WriteFields(), MakeDownloadPacket(), MSG_WriteAngle8i(), NetConn_ClientFrame(), NetConn_ServerParsePacket(), Protocol_WriteStatsReliable(), QW_CL_CheckOrDownloadFile(), QW_CL_NextUpload_f(), QW_CL_ParseDownload(), QW_CL_ParseModelList(), QW_CL_ParseSoundList(), QW_CL_RequestNextDownload(), QW_MSG_WriteDeltaUsercmd(), Sbar_DeathmatchOverlay(), SV_BroadcastPrint(), SV_ClientCommands(), SV_ClientPrint(), SV_Color_f(), SV_CreateBaseline(), SV_DropClient(), SV_ModelIndex(), SV_Name(), SV_Pause_f(), SV_Pings_f(), SV_PreSpawn_f(), SV_SendClientDatagram(), SV_SendServerinfo(), SV_SoundIndex(), SV_Spawn_f(), SV_SpawnServer(), SV_StartEffect(), SV_StartParticle(), SV_StartPointSound(), SV_StartSound(), SV_StopDemoRecording(), SV_UpdateToReliableMessages(), SV_WriteClientdataToMessage(), SV_WriteNetnameIntoDemo(), VM_M_WriteByte(), VM_SV_ambientsound(), VM_SV_makestatic(), VM_SV_pointparticles(), VM_SV_setcolor(), VM_SV_setpause(), VM_SV_te_beam(), VM_SV_te_blood(), VM_SV_te_bloodshower(), VM_SV_te_customflash(), VM_SV_te_explosion(), VM_SV_te_explosion2(), VM_SV_te_explosionquad(), VM_SV_te_explosionrgb(), VM_SV_te_flamejet(), VM_SV_te_gunshot(), VM_SV_te_gunshotquad(), VM_SV_te_knightspike(), VM_SV_te_lavasplash(), VM_SV_te_lightning1(), VM_SV_te_lightning2(), VM_SV_te_lightning3(), VM_SV_te_particlecube(), VM_SV_te_particlerain(), VM_SV_te_particlesnow(), VM_SV_te_plasmaburn(), VM_SV_te_smallflash(), VM_SV_te_spark(), VM_SV_te_spike(), VM_SV_te_spikequad(), VM_SV_te_superspike(), VM_SV_te_superspikequad(), VM_SV_te_tarexplosion(), VM_SV_te_teleport(), VM_SV_te_wizspike(), VM_SV_trailparticles(), and VM_SV_WriteByte().

◆ MSG_WriteChar()

◆ MSG_WriteCoord()

void MSG_WriteCoord ( sizebuf_t * sb,
float f,
protocolversion_t protocol )

Definition at line 202 of file com_msg.c.

203{
204 if (protocol == PROTOCOL_QUAKE || protocol == PROTOCOL_QUAKEDP || protocol == PROTOCOL_NEHAHRAMOVIE || protocol == PROTOCOL_NEHAHRABJP || protocol == PROTOCOL_NEHAHRABJP2 || protocol == PROTOCOL_NEHAHRABJP3 || protocol == PROTOCOL_QUAKEWORLD)
205 MSG_WriteCoord13i (sb, f);
206 else if (protocol == PROTOCOL_DARKPLACES1)
207 MSG_WriteCoord32f (sb, f);
208 else if (protocol == PROTOCOL_DARKPLACES2 || protocol == PROTOCOL_DARKPLACES3 || protocol == PROTOCOL_DARKPLACES4)
209 MSG_WriteCoord16i (sb, f);
210 else
211 MSG_WriteCoord32f (sb, f);
212}
void MSG_WriteCoord32f(sizebuf_t *sb, float f)
Definition com_msg.c:197
void MSG_WriteCoord13i(sizebuf_t *sb, float f)
Definition com_msg.c:187
void MSG_WriteCoord16i(sizebuf_t *sb, float f)
Definition com_msg.c:192

References f, MSG_WriteCoord13i(), MSG_WriteCoord16i(), MSG_WriteCoord32f(), PROTOCOL_DARKPLACES1, PROTOCOL_DARKPLACES2, PROTOCOL_DARKPLACES3, PROTOCOL_DARKPLACES4, PROTOCOL_NEHAHRABJP, PROTOCOL_NEHAHRABJP2, PROTOCOL_NEHAHRABJP3, PROTOCOL_NEHAHRAMOVIE, PROTOCOL_QUAKE, PROTOCOL_QUAKEDP, and PROTOCOL_QUAKEWORLD.

Referenced by EntityFrameQuake_WriteFrame(), MSG_WriteVector(), SV_CreateBaseline(), SV_StartEffect(), SV_StartParticle(), SV_StartPointSound(), SV_StartSound(), SV_WriteClientdataToMessage(), VM_M_WriteCoord(), VM_SV_makestatic(), VM_SV_te_beam(), VM_SV_te_blood(), VM_SV_te_bloodshower(), VM_SV_te_customflash(), VM_SV_te_explosion(), VM_SV_te_explosion2(), VM_SV_te_explosionquad(), VM_SV_te_explosionrgb(), VM_SV_te_flamejet(), VM_SV_te_gunshot(), VM_SV_te_gunshotquad(), VM_SV_te_knightspike(), VM_SV_te_lavasplash(), VM_SV_te_lightning1(), VM_SV_te_lightning2(), VM_SV_te_lightning3(), VM_SV_te_particlecube(), VM_SV_te_particlerain(), VM_SV_te_particlesnow(), VM_SV_te_plasmaburn(), VM_SV_te_smallflash(), VM_SV_te_spark(), VM_SV_te_spike(), VM_SV_te_spikequad(), VM_SV_te_superspike(), VM_SV_te_superspikequad(), VM_SV_te_tarexplosion(), VM_SV_te_teleport(), VM_SV_te_wizspike(), and VM_SV_WriteCoord().

◆ MSG_WriteCoord13i()

void MSG_WriteCoord13i ( sizebuf_t * sb,
float f )

Definition at line 187 of file com_msg.c.

188{
189 MSG_WriteShort (sb, Q_rint(f*8));
190}

References f, MSG_WriteShort(), and Q_rint.

Referenced by EntityState5_WriteUpdate(), and MSG_WriteCoord().

◆ MSG_WriteCoord16i()

void MSG_WriteCoord16i ( sizebuf_t * sb,
float f )

Definition at line 192 of file com_msg.c.

193{
194 MSG_WriteShort (sb, Q_rint(f));
195}

References f, MSG_WriteShort(), and Q_rint.

Referenced by CL_SendMove(), EntityState_WriteFields(), MSG_WriteCoord(), and SV_WriteClientdataToMessage().

◆ MSG_WriteCoord32f()

void MSG_WriteCoord32f ( sizebuf_t * sb,
float f )

Definition at line 197 of file com_msg.c.

198{
199 MSG_WriteFloat (sb, f);
200}

References f, and MSG_WriteFloat().

Referenced by EntityState5_WriteUpdate(), EntityState_WriteFields(), MSG_WriteCoord(), and SV_WriteClientdataToMessage().

◆ MSG_WriteFloat()

void MSG_WriteFloat ( sizebuf_t * sb,
float f )

Definition at line 158 of file com_msg.c.

159{
160 union
161 {
162 float f;
163 int l;
164 } dat;
165
166
167 dat.f = f;
168 dat.l = LittleLong (dat.l);
169
170 SZ_Write (sb, (unsigned char *)&dat.l, 4);
171}
void SZ_Write(sizebuf_t *buf, const unsigned char *data, int length)
Definition common.c:72
#define LittleLong(l)
Definition common.h:92

References f, LittleLong, and SZ_Write().

Referenced by CL_SendMove(), EntityFrame_WriteFrame(), EntityFrameQuake_WriteFrame(), MSG_WriteAngle32f(), MSG_WriteCoord32f(), SV_SendClientDatagram(), and SV_Spawn_f().

◆ MSG_WriteLong()

◆ MSG_WriteShort()

◆ MSG_WriteString()

◆ MSG_WriteUnterminatedString()

void MSG_WriteUnterminatedString ( sizebuf_t * sb,
const char * s )

Definition at line 181 of file com_msg.c.

182{
183 if (s && *s)
184 SZ_Write (sb, (unsigned char *)s, (int)strlen(s));
185}

References strlen(), and SZ_Write().

Referenced by NetConn_ServerParsePacket(), SCR_CaptureVideo_RIFF_IndexEntry(), SCR_CaptureVideo_RIFF_WriteFourCC(), SV_Pings_f(), SV_WriteNetnameIntoDemo(), and VM_SV_WriteUnterminatedString().

◆ MSG_WriteVector()

void MSG_WriteVector ( sizebuf_t * sb,
const vec3_t v,
protocolversion_t protocol )

Definition at line 214 of file com_msg.c.

215{
216 MSG_WriteCoord (sb, v[0], protocol);
217 MSG_WriteCoord (sb, v[1], protocol);
218 MSG_WriteCoord (sb, v[2], protocol);
219}
void MSG_WriteCoord(sizebuf_t *sb, float f, protocolversion_t protocol)
Definition com_msg.c:202

References MSG_WriteCoord(), and v.

Referenced by VM_SV_ambientsound(), VM_SV_pointparticles(), and VM_SV_trailparticles().

◆ StoreBigLong()

void StoreBigLong ( unsigned char * buffer,
unsigned int i )

Encode a big endian 32bit int to the given buffer.

Definition at line 81 of file com_msg.c.

82{
83 buffer[0] = (i >> 24) & 0xFF;
84 buffer[1] = (i >> 16) & 0xFF;
85 buffer[2] = (i >> 8) & 0xFF;
86 buffer[3] = i & 0xFF;
87}

References buffer, and i.

Referenced by CL_PQRcon_f(), Con_Rcon_Redirect_Flush(), NetConn_ClientFrame(), NetConn_ReceivedMessage(), NetConn_SendUnreliableMessage(), and NetConn_ServerParsePacket().

◆ StoreBigShort()

void StoreBigShort ( unsigned char * buffer,
unsigned short i )

Encode a big endian 16bit int to the given buffer.

Definition at line 89 of file com_msg.c.

90{
91 buffer[0] = (i >> 8) & 0xFF;
92 buffer[1] = i & 0xFF;
93}

References buffer, and i.

◆ StoreLittleLong()

void StoreLittleLong ( unsigned char * buffer,
unsigned int i )

Encode a little endian 32bit int to the given buffer.

Definition at line 95 of file com_msg.c.

96{
97 buffer[0] = i & 0xFF;
98 buffer[1] = (i >> 8) & 0xFF;
99 buffer[2] = (i >> 16) & 0xFF;
100 buffer[3] = (i >> 24) & 0xFF;
101}

References buffer, and i.

Referenced by NetConn_SendUnreliableMessage(), and R_SaveTextureDDSFile().

◆ StoreLittleShort()

void StoreLittleShort ( unsigned char * buffer,
unsigned short i )

Encode a little endian 16bit int to the given buffer.

Definition at line 103 of file com_msg.c.

104{
105 buffer[0] = i & 0xFF;
106 buffer[1] = (i >> 8) & 0xFF;
107}

References buffer, and i.