UFO: Alien Invasion
Loading...
Searching...
No Matches
netpack.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define NUMVERTEXNORMALS   162

Functions

void NET_WriteChar (dbuffer *bufbuf, char c)
void NET_WriteByte (dbuffer *bufbuf, byte c)
void NET_WriteShort (dbuffer *bufbuf, int c)
void NET_WriteLong (dbuffer *bufbuf, int c)
void NET_WriteString (dbuffer *bufbuf, const char *str)
void NET_WriteRawString (dbuffer *bufbuf, const char *str)
 Skip the zero string terminal character. If you need it, use NET_WriteString.
void NET_WriteCoord (dbuffer *bufbuf, float f)
void NET_WritePos (dbuffer *bufbuf, const vec3_t pos)
void NET_Write2Pos (dbuffer *bufbuf, const vec2_t pos)
void NET_WriteGPos (dbuffer *bufbuf, const pos3_t pos)
void NET_WriteAngle (dbuffer *bufbuf, float f)
void NET_WriteAngle16 (dbuffer *bufbuf, float f)
void NET_WriteDir (dbuffer *bufbuf, const vec3_t vector)
void NET_vWriteFormat (dbuffer *bufbuf, const char *format, va_list ap)
 Writes to buffer according to format; version without syntactic sugar for variable arguments, to call it from other functions with variable arguments.
void NET_WriteFormat (dbuffer *bufbuf, const char *format,...)
 The user-friendly version of NET_WriteFormat that writes variable arguments to buffer according to format.
void NET_VPrintf (dbuffer *bufbuf, const char *format, va_list ap, char *str, size_t length)
void NET_WriteMsg (struct net_stream *s, dbuffer &bufbuf)
 Enqueue the buffer in the net stream for ONE client.
void NET_WriteConstMsg (struct net_stream *s, const dbuffer &bufbuf)
 Enqueue the buffer in the net stream for MULTIPLE clients.
void NET_OOB_Printf (struct net_stream *s, const char *format,...) __attribute__((format(__printf__
void int NET_ReadChar (dbuffer *bufbuf)
int NET_ReadByte (dbuffer *bufbuf)
 Reads a byte from the netchannel.
int NET_ReadShort (dbuffer *bufbuf)
int NET_PeekByte (const dbuffer *bufbuf)
int NET_PeekShort (const dbuffer *bufbuf)
 Peeks into a buffer without changing it to get a short int.
int NET_PeekLong (const dbuffer *bufbuf)
int NET_ReadLong (dbuffer *bufbuf)
int NET_ReadString (dbuffer *bufbuf, char *string, size_t length)
int NET_ReadStringLine (dbuffer *bufbuf, char *string, size_t length)
float NET_ReadCoord (dbuffer *bufbuf)
void NET_ReadPos (dbuffer *bufbuf, vec3_t pos)
void NET_Read2Pos (dbuffer *bufbuf, vec2_t pos)
void NET_ReadGPos (dbuffer *bufbuf, pos3_t pos)
float NET_ReadAngle (dbuffer *bufbuf)
float NET_ReadAngle16 (dbuffer *bufbuf)
void NET_ReadDir (dbuffer *bufbuf, vec3_t vector)
void NET_ReadData (dbuffer *bufbuf, void *buffer, int sizesize)
void NET_vReadFormat (dbuffer *bufbuf, const char *format, va_list ap)
 Reads from a buffer according to format; version without syntactic sugar for variable arguments, to call it from other functions with variable arguments.
void NET_ReadFormat (dbuffer *bufbuf, const char *format,...)
 The user-friendly version of NET_ReadFormat that reads variable arguments from a buffer according to format.
void NET_SkipFormat (dbuffer *bufbuf, const char *format)

Variables

const vec3_t bytedirs [NUMVERTEXNORMALS]

Macro Definition Documentation

◆ NUMVERTEXNORMALS

#define NUMVERTEXNORMALS   162

Definition at line 30 of file netpack.h.

Function Documentation

◆ NET_OOB_Printf()

◆ NET_PeekByte()

int NET_PeekByte ( const dbuffer * buf)

Definition at line 251 of file netpack.cpp.

References NET_PeekByte().

Referenced by CL_ActorDoMoveTime(), NET_OOB_Printf(), and NET_PeekByte().

◆ NET_PeekLong()

int NET_PeekLong ( const dbuffer * buf)

Definition at line 273 of file netpack.cpp.

References LittleLong, NET_PeekLong(), and v.

Referenced by CL_ActorDoMove(), CL_ActorDoMoveTime(), NET_OOB_Printf(), and NET_PeekLong().

◆ NET_PeekShort()

int NET_PeekShort ( const dbuffer * buf)

Peeks into a buffer without changing it to get a short int.

Parameters
bufThe buffer, returned unchanged, no need to be copied before.
Returns
The short at the beginning of the buffer, -1 if it couldn't be read.

Definition at line 264 of file netpack.cpp.

References LittleShort, NET_PeekShort(), and v.

Referenced by CL_CheckDefault(), NET_OOB_Printf(), and NET_PeekShort().

◆ NET_Read2Pos()

void NET_Read2Pos ( dbuffer * buf,
vec2_t pos )
See also
NET_Write2Pos

Definition at line 355 of file netpack.cpp.

References NET_Read2Pos(), NET_ReadLong(), and POSSCALE.

Referenced by NET_OOB_Printf(), and NET_Read2Pos().

◆ NET_ReadAngle()

float NET_ReadAngle ( dbuffer * buf)

◆ NET_ReadAngle16()

float NET_ReadAngle16 ( dbuffer * buf)

Definition at line 388 of file netpack.cpp.

References NET_ReadAngle16(), NET_ReadShort(), and SHORT2ANGLE.

Referenced by NET_OOB_Printf(), and NET_ReadAngle16().

◆ NET_ReadByte()

int NET_ReadByte ( dbuffer * buf)

Reads a byte from the netchannel.

Note
Beware that you don't put this into a byte or short - this will overflow use an int value to store the return value when you read this via the net format strings!!!

Definition at line 234 of file netpack.cpp.

References NET_ReadByte().

Referenced by CL_ActorDoMove(), CL_ActorDoMoveTime(), CL_DoEndRound(), CL_EndRoundAnnounce(), CL_ParseEvent(), CL_ParseResults(), CL_ParseServerMessage(), CL_ReadPackets(), CL_StartGame(), GAME_GetImportData(), cgame_import_t::int(), NET_OOB_Printf(), NET_ReadByte(), NET_ReadData(), NET_ReadDir(), NET_ReadGPos(), NET_ReadString(), NET_ReadStringLine(), NET_SkipFormat(), NET_vReadFormat(), SV_ReadByte(), and SV_ReadPacket().

◆ NET_ReadChar()

void int NET_ReadChar ( dbuffer * buf)

returns -1 if no more characters are available

Definition at line 221 of file netpack.cpp.

References NET_ReadChar().

Referenced by NET_OOB_Printf(), NET_ReadAngle(), NET_ReadChar(), NET_SkipFormat(), NET_vReadFormat(), and SV_ReadChar().

◆ NET_ReadCoord()

float NET_ReadCoord ( dbuffer * buf)

Definition at line 347 of file netpack.cpp.

References NET_ReadCoord(), and NET_ReadLong().

Referenced by NET_OOB_Printf(), and NET_ReadCoord().

◆ NET_ReadData()

void NET_ReadData ( dbuffer * buf,
void * buffer,
int size )

Definition at line 394 of file netpack.cpp.

References data, i, len, NET_ReadByte(), and NET_ReadData().

Referenced by NET_OOB_Printf(), NET_ReadData(), and SV_ReadData().

◆ NET_ReadDir()

void NET_ReadDir ( dbuffer * buf,
vec3_t vector )

◆ NET_ReadFormat()

◆ NET_ReadGPos()

void NET_ReadGPos ( dbuffer * buf,
pos3_t pos )
See also
NET_WriteGPos
NET_ReadByte
Note
pos3_t are byte values

Definition at line 376 of file netpack.cpp.

References NET_ReadByte(), and NET_ReadGPos().

Referenced by CL_ActorDoMove(), NET_OOB_Printf(), NET_ReadGPos(), NET_SkipFormat(), NET_vReadFormat(), and SV_ReadGPos().

◆ NET_ReadLong()

◆ NET_ReadPos()

void NET_ReadPos ( dbuffer * buf,
vec3_t pos )

◆ NET_ReadShort()

◆ NET_ReadString()

int NET_ReadString ( dbuffer * buf,
char * string,
size_t length )
Note
Don't use this function in a way like char* s = NET_ReadString(sb); char* t = NET_ReadString(sb); The second reading uses the same data buffer for the string - so s is no longer the first - but the second string
See also
NET_ReadStringLine
Parameters
[in,out]bufThe input buffer to read the string data from
[out]stringThe output buffer to read the string into
[in]lengthThe size of the output buffer

Definition at line 302 of file netpack.cpp.

References length, NET_ReadByte(), and NET_ReadString().

Referenced by CL_ConnectionlessPacket(), CL_ParseServerData(), CL_ParseServerMessage(), CL_SetConfigString(), GAME_GetImportData(), cgame_import_t::int(), NET_OOB_Printf(), NET_ReadString(), NET_SkipFormat(), NET_vReadFormat(), SV_ExecuteClientMessage(), and SV_ReadString().

◆ NET_ReadStringLine()

int NET_ReadStringLine ( dbuffer * buf,
char * string,
size_t length )

◆ NET_SkipFormat()

◆ NET_VPrintf()

void NET_VPrintf ( dbuffer * buf,
const char * format,
va_list ap,
char * str,
size_t length )

◆ NET_vReadFormat()

void NET_vReadFormat ( dbuffer * buf,
const char * format,
va_list ap )

Reads from a buffer according to format; version without syntactic sugar for variable arguments, to call it from other functions with variable arguments.

See also
SV_ReadFormat
Parameters
[in]bufThe buffer we read the data from
[in]formatThe format string may not be nullptr
apThe variadic function argument list corresponding to the format string

Definition at line 415 of file netpack.cpp.

References Com_Error(), ERR_DROP, format(), i, length, NET_ReadAngle(), NET_ReadByte(), NET_ReadChar(), NET_ReadDir(), NET_ReadGPos(), NET_ReadLong(), NET_ReadPos(), NET_ReadShort(), NET_ReadString(), and NET_vReadFormat().

Referenced by NET_OOB_Printf(), NET_ReadFormat(), NET_vReadFormat(), and SV_ReadFormat().

◆ NET_vWriteFormat()

void NET_vWriteFormat ( dbuffer * buf,
const char * format,
va_list ap )

Writes to buffer according to format; version without syntactic sugar for variable arguments, to call it from other functions with variable arguments.

Note
short and char are promoted to int when passed to variadic functions!

Definition at line 149 of file netpack.cpp.

References Com_Error(), ERR_DROP, format(), i, NET_vWriteFormat(), NET_WriteAngle(), NET_WriteByte(), NET_WriteChar(), NET_WriteDir(), NET_WriteGPos(), NET_WriteLong(), NET_WritePos(), NET_WriteShort(), and NET_WriteString().

Referenced by MSG_Write_PA(), NET_vWriteFormat(), NET_WriteFormat(), and SV_WriteFormat().

◆ NET_Write2Pos()

void NET_Write2Pos ( dbuffer * buf,
const vec2_t pos )
See also
NET_Read2Pos

Definition at line 87 of file netpack.cpp.

References NET_Write2Pos(), NET_WriteLong(), and POSSCALE.

Referenced by NET_Write2Pos().

◆ NET_WriteAngle()

void NET_WriteAngle ( dbuffer * buf,
float f )

Definition at line 110 of file netpack.cpp.

References f, NET_WriteAngle(), and NET_WriteByte().

Referenced by NET_vWriteFormat(), NET_WriteAngle(), and SV_WriteAngle().

◆ NET_WriteAngle16()

void NET_WriteAngle16 ( dbuffer * buf,
float f )

Definition at line 115 of file netpack.cpp.

References ANGLE2SHORT, f, NET_WriteAngle16(), and NET_WriteShort().

Referenced by NET_WriteAngle16().

◆ NET_WriteByte()

◆ NET_WriteChar()

void NET_WriteChar ( dbuffer * buf,
char c )

◆ NET_WriteConstMsg()

void NET_WriteConstMsg ( struct net_stream * s,
const dbuffer & buf )

Enqueue the buffer in the net stream for MULTIPLE clients.

Note
Same as NET_WriteMsg but doesn't free the buffer, use this if you send the same buffer to more than one connected clients
Make sure that you free the msg buffer after you called this
See also
NET_WriteMsg

Definition at line 588 of file netpack.cpp.

References len, LittleLong, NET_StreamEnqueue(), and NET_WriteConstMsg().

Referenced by NET_WriteConstMsg(), SV_BroadcastPrintf(), SV_FinalMessage(), and SV_Multicast().

◆ NET_WriteCoord()

void NET_WriteCoord ( dbuffer * buf,
float f )

Definition at line 79 of file netpack.cpp.

References f, NET_WriteCoord(), and NET_WriteLong().

Referenced by NET_WriteCoord().

◆ NET_WriteDir()

void NET_WriteDir ( dbuffer * buf,
const vec3_t dir )
Note
EV_ACTOR_SHOOT is using WriteDir for writing the normal, but ReadByte for reading it - keep that in mind when you change something here

Definition at line 124 of file netpack.cpp.

References bytedirs, DotProduct, i, lengthof, NET_WriteByte(), and NET_WriteDir().

Referenced by NET_vWriteFormat(), NET_WriteDir(), and SV_WriteDir().

◆ NET_WriteFormat()

void NET_WriteFormat ( dbuffer * buf,
const char * format,
... )

The user-friendly version of NET_WriteFormat that writes variable arguments to buffer according to format.

Definition at line 207 of file netpack.cpp.

References format(), NET_vWriteFormat(), and NET_WriteFormat().

Referenced by GAME_NetSendItem(), MSG_Write_PA(), and NET_WriteFormat().

◆ NET_WriteGPos()

void NET_WriteGPos ( dbuffer * buf,
const pos3_t pos )

Definition at line 103 of file netpack.cpp.

References NET_WriteByte(), and NET_WriteGPos().

Referenced by NET_vWriteFormat(), NET_WriteGPos(), and SV_WriteGPos().

◆ NET_WriteLong()

◆ NET_WriteMsg()

◆ NET_WritePos()

void NET_WritePos ( dbuffer * buf,
const vec3_t pos )
See also
NET_ReadPos

Definition at line 96 of file netpack.cpp.

References NET_WriteLong(), NET_WritePos(), and POSSCALE.

Referenced by NET_vWriteFormat(), NET_WritePos(), SV_QueueWritePos(), and SV_WritePos().

◆ NET_WriteRawString()

void NET_WriteRawString ( dbuffer * buf,
const char * str )

Skip the zero string terminal character. If you need it, use NET_WriteString.

Definition at line 71 of file netpack.cpp.

References Com_DPrintf(), DEBUG_EVENTSYS, and NET_WriteRawString().

Referenced by NET_WriteRawString(), SVC_Status(), and SVC_TeamInfo().

◆ NET_WriteShort()

◆ NET_WriteString()

Variable Documentation

◆ bytedirs

const vec3_t bytedirs[NUMVERTEXNORMALS]
extern