1 /* 2 Copyright (C) 1997-2001 Id Software, Inc. 3 4 This program is free software; you can redistribute it and/or 5 modify it under the terms of the GNU General Public License 6 as published by the Free Software Foundation; either version 2 7 of the License, or (at your option) any later version. 8 9 This program is distributed in the hope that it will be useful, 10 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 13 See the GNU General Public License for more details. 14 15 You should have received a copy of the GNU General Public License 16 along with this program; if not, write to the Free Software 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 19 */ 20 21 // 22 // q_msg.h 23 // 24 25 typedef struct sizebuf_s { 26 qboolean allowoverflow; 27 qboolean overflowed; // set to qtrue if the buffer size failed 28 byte *data; 29 int maxsize; 30 int cursize; 31 int readcount; 32 int bitpos; 33 } sizebuf_t; 34 35 void SZ_Init( sizebuf_t *buf, byte *data, int length ); 36 void SZ_Clear( sizebuf_t *buf ); 37 void *SZ_GetSpace( sizebuf_t *buf, int length ); 38 void SZ_Write( sizebuf_t *buf, const void *data, int length ); 39 void SZ_WriteByte( sizebuf_t *sb, int c ); 40 void SZ_WriteShort( sizebuf_t *sb, int c ); 41 void SZ_WriteLong( sizebuf_t *sb, int c ); 42 void SZ_WritePos( sizebuf_t *sb, const vec3_t pos ); 43 void SZ_WriteExactPos( sizebuf_t *sb, const vec3_t pos ); 44 void SZ_WriteString( sizebuf_t *sb, const char *string ); 45 46 //============================================================================ 47 48 #define NUMVERTEXNORMALS 162 49 extern vec3_t bytedirs[NUMVERTEXNORMALS]; 50 51 typedef enum { 52 MSG_PS_IGNORE_GUNINDEX = ( 1 << 0 ), 53 MSG_PS_IGNORE_GUNFRAMES = ( 1 << 1 ), 54 MSG_PS_IGNORE_BLEND = ( 1 << 2 ), 55 MSG_PS_IGNORE_VIEWANGLES = ( 1 << 3 ), /* ignored by *_Packet version */ 56 MSG_PS_IGNORE_DELTAANGLES = ( 1 << 4 ), 57 MSG_PS_IGNORE_PREDICTION = ( 1 << 5 ), /* mutually exclusive with IGNORE_VIEWANGLES */ 58 MSG_PS_WRITE_CLIENTNUM = ( 1 << 6 ), /* ignored by *_Packet version */ 59 MSG_PS_FORCE = ( 1 << 7 ) /* supported by *_Packet version only */ 60 } msgPsFlags_t; 61 62 typedef enum { 63 MSG_ES_FORCE = ( 1 << 0 ), 64 MSG_ES_NEWENTITY = ( 1 << 1 ), 65 MSG_ES_FIRSTPERSON = ( 1 << 2 ) 66 } msgEsFlags_t; 67 68 extern sizebuf_t msg_write; 69 extern byte msg_write_buffer[MAX_MSGLEN]; 70 71 extern sizebuf_t msg_read; 72 extern byte msg_read_buffer[MAX_MSGLEN]; 73 74 void MSG_Init( void ); 75 76 void MSG_BeginWriting( void ); 77 void MSG_WriteChar( int c ); 78 void MSG_WriteByte( int c ); 79 void MSG_WriteShort( int c ); 80 void MSG_WriteLong( int c ); 81 void MSG_WriteFloat( float f ); 82 void MSG_WriteString( const char *s ); 83 void MSG_WriteCoord( float f ); 84 void MSG_WritePos( const vec3_t pos ); 85 void MSG_WriteAngle( float f ); 86 void MSG_WriteAngle16( float f ); 87 void MSG_WriteBits( int value, int bits ); 88 int MSG_WriteDeltaUsercmd( const usercmd_t *from, const usercmd_t *cmd ); 89 int MSG_WriteDeltaUsercmd_Enhanced( const usercmd_t *from, const usercmd_t *cmd ); 90 void MSG_WriteDir ( const vec3_t vector); 91 void MSG_WriteData( const void *data, int length ); 92 void MSG_WriteDeltaEntity( const entity_state_t *from, entity_state_t *to, msgEsFlags_t flags ); 93 void MSG_WriteDeltaPlayerstate_Default( const player_state_t *from, const player_state_t *to ); 94 int MSG_WriteDeltaPlayerstate_Enhanced( const playerStateEx_t *from, playerStateEx_t *to, msgPsFlags_t flags ); 95 void MSG_WriteDeltaPlayerstate_Packet( const playerStateEx_t *from, playerStateEx_t *to, msgPsFlags_t flags ); 96 void MSG_FlushTo( sizebuf_t *dest ); 97 98 void MSG_BeginReading( void ); 99 int MSG_ReadChar( void ); 100 int MSG_ReadByte( void ); 101 int MSG_ReadShort( void ); 102 int MSG_ReadLong( void ); 103 float MSG_ReadFloat( void ); 104 char *MSG_ReadString( void ); 105 char *MSG_ReadStringLine( void ); 106 float MSG_ReadCoord( void ); 107 void MSG_ReadPos( vec3_t pos ); 108 void MSG_ReadExactPos( vec3_t pos ); 109 float MSG_ReadAngle( void ); 110 float MSG_ReadAngle16 ( void ); 111 int MSG_ReadBits( int bits ); 112 void MSG_ReadDeltaUsercmd( const usercmd_t *from, usercmd_t *cmd ); 113 void MSG_ReadDeltaUsercmd_Enhanced( const usercmd_t *from, usercmd_t *to ); 114 void MSG_ReadDir( vec3_t vector ); 115 void MSG_ReadData( void *buffer, int size ); 116 int MSG_ParseEntityBits( int *bits ); 117 void MSG_ParseDeltaEntity( const entity_state_t *from, entity_state_t *to, int number, int bits ); 118 void MSG_ParseDeltaPlayerstate_Default( const player_state_t *from, player_state_t *to, int flags ); 119 void MSG_ParseDeltaPlayerstate_Enhanced( const playerStateEx_t *from, playerStateEx_t *to, int flags ); 120 121 void MSG_ShowDeltaEntityBits( int bits ); 122 void MSG_ShowDeltaPlayerstateBits_Default( int flags ); 123 void MSG_ShowDeltaPlayerstateBits_Enhanced( int flags ); 124 void MSG_ShowDeltaUsercmdBits_Enhanced( int bits ); 125 const char *MSG_ServerCommandString( int cmd ); 126 127 void MSG_ParseZPacket( void (*parsefunc)( void ) ); 128 129 130