Ejemplo n.º 1
0
Archivo: msg.c Proyecto: sousix/QDM68
/*
============
MSG_WriteBits
============
*/
void MSG_WriteBits( sizebuf_t *msg, int value, int bits ) {
	int				remaining;
	int				i;
	byte			*buf;

	if( msg->maxsize - msg->cursize < 4 ) {
		msg->overflowed = qtrue;
		return;
	}

	if( !bits || bits < -31 || bits > 32 ) {
		Com_Error( ERR_DROP, "MSG_WriteBits: bad bits %i", bits );
	}

	if( bits < 0 ) {
		bits = -bits;
	}

	if( msg->uncompressed ) {
		if( bits <= 8 ) {
			buf = MSG_GetSpace( msg, 1 );
			buf[0] = value;		
		} else if( bits <= 16 ) {
			buf = MSG_GetSpace( msg, 2 );
			buf[0] = value & 0xFF;
			buf[1] = value >> 8;
		} else if( bits <= 32 ) {
Ejemplo n.º 2
0
void MSG_WriteInt3( msg_t *msg, int c )
{
	qbyte *buf = ( qbyte* )MSG_GetSpace( msg, 3 );
	buf[0] = ( qbyte )( c&0xff );
	buf[1] = ( qbyte )( ( c>>8 )&0xff );
	buf[2] = ( qbyte )( ( c>>16 )&0xff );
}
Ejemplo n.º 3
0
Archivo: msg.c Proyecto: tenght/qfusion
void MSG_WriteInt3( msg_t *msg, int c )
{
	uint8_t *buf = ( uint8_t* )MSG_GetSpace( msg, 3 );
	buf[0] = ( uint8_t )( c&0xff );
	buf[1] = ( uint8_t )( ( c>>8 )&0xff );
	buf[2] = ( uint8_t )( ( c>>16 )&0xff );
}
Ejemplo n.º 4
0
Archivo: msg.c Proyecto: tenght/qfusion
void MSG_WriteLong( msg_t *msg, int c )
{
	uint8_t *buf = ( uint8_t* )MSG_GetSpace( msg, 4 );
	buf[0] = ( uint8_t )( c&0xff );
	buf[1] = ( uint8_t )( ( c>>8 )&0xff );
	buf[2] = ( uint8_t )( ( c>>16 )&0xff );
	buf[3] = ( uint8_t )( c>>24 );
}
Ejemplo n.º 5
0
void MSG_WriteShort( msg_t *msg, int c )
{
	unsigned short *sp = (unsigned short *)MSG_GetSpace( msg, 2 );
	*sp = LittleShort( c );
}
Ejemplo n.º 6
0
void MSG_WriteByte( msg_t *msg, int c )
{
	qbyte *buf = ( qbyte* )MSG_GetSpace( msg, 1 );
	buf[0] = ( qbyte )( c&0xff );
}
Ejemplo n.º 7
0
void MSG_WriteChar( msg_t *msg, int c )
{
	qbyte *buf = ( qbyte* )MSG_GetSpace( msg, 1 );
	buf[0] = ( char )c;
}
Ejemplo n.º 8
0
void MSG_CopyData( msg_t *buf, const void *data, size_t length )
{
	memcpy( MSG_GetSpace( buf, length ), data, length );
}
Ejemplo n.º 9
0
void MSG_WriteLong( msg_t *msg, int c )
{
	unsigned int *ip = (unsigned int *)MSG_GetSpace( msg, 4 );
	*ip = LittleLong( c );
}
Ejemplo n.º 10
0
Archivo: msg.c Proyecto: sousix/QDM68
/*
============
MSG_WriteRawData
============
*/
void MSG_WriteRawData( sizebuf_t *msg, const void *data, int length ) {
	if( length > 0 ) {
		memcpy( MSG_GetSpace( msg, length ), data, length );
	}
}
Ejemplo n.º 11
0
Archivo: msg.c Proyecto: sousix/QDM68
	}

	if( bits < 0 ) {
		bits = -bits;
	}

	if( msg->uncompressed ) {
		if( bits <= 8 ) {
			buf = MSG_GetSpace( msg, 1 );
			buf[0] = value;		
		} else if( bits <= 16 ) {
			buf = MSG_GetSpace( msg, 2 );
			buf[0] = value & 0xFF;
			buf[1] = value >> 8;
		} else if( bits <= 32 ) {
			buf = MSG_GetSpace( msg, 4 );
			buf[0] = value & 0xFF;
			buf[1] = (value >> 8) & 0xFF;
			buf[2] = (value >> 16) & 0xFF;
			buf[3] = value >> 24;
		}
		return;
	} 

	value &= 0xFFFFFFFFU >> (32 - bits);
	remaining = bits & 7;

	for( i=0; i<remaining ; i++ ) {
		if( !(msg->bit & 7) ) {
			msg->data[msg->bit >> 3] = 0;
		} 
Ejemplo n.º 12
0
void MSG_WriteData( msg_t *buf, const void *data, int length ) {
	memcpy (MSG_GetSpace(buf,length),data,length);		
}
Ejemplo n.º 13
0
Archivo: msg.c Proyecto: tenght/qfusion
void MSG_WriteShort( msg_t *msg, int c )
{
	uint8_t *buf = ( uint8_t* )MSG_GetSpace( msg, 2 );
	buf[0] = ( uint8_t )( c&0xff );
	buf[1] = ( uint8_t )( ( c>>8 )&0xff );
}
Ejemplo n.º 14
0
Archivo: msg.c Proyecto: tenght/qfusion
void MSG_WriteByte( msg_t *msg, int c )
{
	uint8_t *buf = ( uint8_t* )MSG_GetSpace( msg, 1 );
	buf[0] = ( uint8_t )( c&0xff );
}
Ejemplo n.º 15
0
Archivo: msg.c Proyecto: tenght/qfusion
void MSG_WriteChar( msg_t *msg, int c )
{
	uint8_t *buf = ( uint8_t* )MSG_GetSpace( msg, 1 );
	buf[0] = ( char )c;
}