summaryrefslogtreecommitdiff
path: root/src/q_msg.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/q_msg.h')
-rw-r--r--src/q_msg.h216
1 files changed, 111 insertions, 105 deletions
diff --git a/src/q_msg.h b/src/q_msg.h
index ce874ce..9935db9 100644
--- a/src/q_msg.h
+++ b/src/q_msg.h
@@ -8,7 +8,7 @@ of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
@@ -22,13 +22,13 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
// q_msg.h
//
-#define SZ_MSG_WRITE MakeRawLong( 'w', 'r', 'i', 't' )
-#define SZ_MSG_READ MakeRawLong( 'r', 'e', 'a', 'd' )
-#define SZ_NC_SEND_OLD MakeRawLong( 'n', 'c', '1', 's' )
-#define SZ_NC_SEND_NEW MakeRawLong( 'n', 'c', '2', 's' )
-#define SZ_NC_SEND_FRG MakeRawLong( 'n', 'c', '2', 'f' )
-#define SZ_NC_FRG_IN MakeRawLong( 'n', 'c', '2', 'i' )
-#define SZ_NC_FRG_OUT MakeRawLong( 'n', 'c', '2', 'o' )
+#define SZ_MSG_WRITE MakeRawLong('w', 'r', 'i', 't')
+#define SZ_MSG_READ MakeRawLong('r', 'e', 'a', 'd')
+#define SZ_NC_SEND_OLD MakeRawLong('n', 'c', '1', 's')
+#define SZ_NC_SEND_NEW MakeRawLong('n', 'c', '2', 's')
+#define SZ_NC_SEND_FRG MakeRawLong('n', 'c', '2', 'f')
+#define SZ_NC_FRG_IN MakeRawLong('n', 'c', '2', 'i')
+#define SZ_NC_FRG_OUT MakeRawLong('n', 'c', '2', 'o')
typedef struct sizebuf_s {
uint32_t tag;
@@ -42,44 +42,45 @@ typedef struct sizebuf_s {
size_t bitpos;
} sizebuf_t;
-void SZ_Init( sizebuf_t *buf, void *data, size_t length );
-void SZ_TagInit( sizebuf_t *buf, void *data, size_t length, uint32_t tag );
-void SZ_Clear( sizebuf_t *buf );
-void *SZ_GetSpace( sizebuf_t *buf, size_t length );
-void SZ_WriteByte( sizebuf_t *sb, int c );
-void SZ_WriteShort( sizebuf_t *sb, int c );
-void SZ_WriteLong( sizebuf_t *sb, int c );
-void SZ_WriteString( sizebuf_t *sb, const char *string );
-
-static inline void *SZ_Write( sizebuf_t *buf, const void *data, size_t length ) {
- return memcpy( SZ_GetSpace( buf, length ), data, length );
+void SZ_Init(sizebuf_t *buf, void *data, size_t length);
+void SZ_TagInit(sizebuf_t *buf, void *data, size_t length, uint32_t tag);
+void SZ_Clear(sizebuf_t *buf);
+void *SZ_GetSpace(sizebuf_t *buf, size_t length);
+void SZ_WriteByte(sizebuf_t *sb, int c);
+void SZ_WriteShort(sizebuf_t *sb, int c);
+void SZ_WriteLong(sizebuf_t *sb, int c);
+void SZ_WriteString(sizebuf_t *sb, const char *string);
+
+static inline void *SZ_Write(sizebuf_t *buf, const void *data, size_t length)
+{
+ return memcpy(SZ_GetSpace(buf, length), data, length);
}
//============================================================================
typedef enum {
- MSG_PS_IGNORE_GUNINDEX = ( 1 << 0 ),
- MSG_PS_IGNORE_GUNFRAMES = ( 1 << 1 ),
- MSG_PS_IGNORE_BLEND = ( 1 << 2 ),
- MSG_PS_IGNORE_VIEWANGLES = ( 1 << 3 ),
- MSG_PS_IGNORE_DELTAANGLES = ( 1 << 4 ),
- MSG_PS_IGNORE_PREDICTION = ( 1 << 5 ), // mutually exclusive with IGNORE_VIEWANGLES
- MSG_PS_FORCE = ( 1 << 7 ),
- MSG_PS_REMOVE = ( 1 << 8 )
+ MSG_PS_IGNORE_GUNINDEX = (1 << 0),
+ MSG_PS_IGNORE_GUNFRAMES = (1 << 1),
+ MSG_PS_IGNORE_BLEND = (1 << 2),
+ MSG_PS_IGNORE_VIEWANGLES = (1 << 3),
+ MSG_PS_IGNORE_DELTAANGLES = (1 << 4),
+ MSG_PS_IGNORE_PREDICTION = (1 << 5), // mutually exclusive with IGNORE_VIEWANGLES
+ MSG_PS_FORCE = (1 << 7),
+ MSG_PS_REMOVE = (1 << 8)
} msgPsFlags_t;
typedef enum {
- MSG_ES_FORCE = ( 1 << 0 ),
- MSG_ES_NEWENTITY = ( 1 << 1 ),
- MSG_ES_FIRSTPERSON = ( 1 << 2 ),
- MSG_ES_LONGSOLID = ( 1 << 3 ),
- MSG_ES_UMASK = ( 1 << 4 ),
- MSG_ES_BEAMORIGIN = ( 1 << 5 ),
- MSG_ES_SHORTANGLES = ( 1 << 6 ),
- MSG_ES_REMOVE = ( 1 << 7 )
+ MSG_ES_FORCE = (1 << 0),
+ MSG_ES_NEWENTITY = (1 << 1),
+ MSG_ES_FIRSTPERSON = (1 << 2),
+ MSG_ES_LONGSOLID = (1 << 3),
+ MSG_ES_UMASK = (1 << 4),
+ MSG_ES_BEAMORIGIN = (1 << 5),
+ MSG_ES_SHORTANGLES = (1 << 6),
+ MSG_ES_REMOVE = (1 << 7)
} msgEsFlags_t;
-
+
extern sizebuf_t msg_write;
extern byte msg_write_buffer[MAX_MSGLEN];
@@ -90,119 +91,123 @@ extern const entity_state_t nullEntityState;
extern const player_state_t nullPlayerState;
extern const usercmd_t nullUserCmd;
-void MSG_Init( void );
+void MSG_Init(void);
-void MSG_BeginWriting( void );
-void MSG_WriteChar( int c );
-void MSG_WriteByte( int c );
-void MSG_WriteShort( int c );
-void MSG_WriteLong( int c );
-void MSG_WriteString( const char *s );
-void MSG_WritePos( const vec3_t pos );
-void MSG_WriteAngle( float f );
+void MSG_BeginWriting(void);
+void MSG_WriteChar(int c);
+void MSG_WriteByte(int c);
+void MSG_WriteShort(int c);
+void MSG_WriteLong(int c);
+void MSG_WriteString(const char *s);
+void MSG_WritePos(const vec3_t pos);
+void MSG_WriteAngle(float f);
#if USE_CLIENT
-void MSG_WriteBits( int value, int bits );
-int MSG_WriteDeltaUsercmd( const usercmd_t *from, const usercmd_t *cmd, int version );
-int MSG_WriteDeltaUsercmd_Enhanced( const usercmd_t *from, const usercmd_t *cmd, int version );
+void MSG_WriteBits(int value, int bits);
+int MSG_WriteDeltaUsercmd(const usercmd_t *from, const usercmd_t *cmd, int version);
+int MSG_WriteDeltaUsercmd_Enhanced(const usercmd_t *from, const usercmd_t *cmd, int version);
#endif
-void MSG_WriteDir ( const vec3_t vector);
-void MSG_WriteDeltaEntity( const entity_state_t *from, const entity_state_t *to, msgEsFlags_t flags );
-void MSG_WriteDeltaPlayerstate_Default( const player_state_t *from, const player_state_t *to );
-int MSG_WriteDeltaPlayerstate_Enhanced( const player_state_t *from, player_state_t *to, msgPsFlags_t flags );
-void MSG_WriteDeltaPlayerstate_Packet( const player_state_t *from, const player_state_t *to, int number, msgPsFlags_t flags );
-void MSG_FlushTo( sizebuf_t *dest );
-void MSG_Printf( const char *fmt, ... ) q_printf( 1, 2 );
-
-static inline void *MSG_WriteData( const void *data, size_t length ) {
- return memcpy( SZ_GetSpace( &msg_write, length ), data, length );
+void MSG_WriteDir(const vec3_t vector);
+void MSG_WriteDeltaEntity(const entity_state_t *from, const entity_state_t *to, msgEsFlags_t flags);
+void MSG_WriteDeltaPlayerstate_Default(const player_state_t *from, const player_state_t *to);
+int MSG_WriteDeltaPlayerstate_Enhanced(const player_state_t *from, player_state_t *to, msgPsFlags_t flags);
+void MSG_WriteDeltaPlayerstate_Packet(const player_state_t *from, const player_state_t *to, int number, msgPsFlags_t flags);
+void MSG_FlushTo(sizebuf_t *dest);
+void MSG_Printf(const char *fmt, ...) q_printf(1, 2);
+
+static inline void *MSG_WriteData(const void *data, size_t length)
+{
+ return memcpy(SZ_GetSpace(&msg_write, length), data, length);
}
-void MSG_BeginReading( void );
-byte *MSG_ReadData( size_t len );
-int MSG_ReadChar( void );
-int MSG_ReadByte( void );
-int MSG_ReadShort( void );
-int MSG_ReadWord( void );
-int MSG_ReadLong( void );
-size_t MSG_ReadString( char *dest, size_t size );
-size_t MSG_ReadStringLine( char *dest, size_t size );
+void MSG_BeginReading(void);
+byte *MSG_ReadData(size_t len);
+int MSG_ReadChar(void);
+int MSG_ReadByte(void);
+int MSG_ReadShort(void);
+int MSG_ReadWord(void);
+int MSG_ReadLong(void);
+size_t MSG_ReadString(char *dest, size_t size);
+size_t MSG_ReadStringLine(char *dest, size_t size);
#if USE_CLIENT
-void MSG_ReadPos( vec3_t pos );
-void MSG_ReadDir( vec3_t vector );
+void MSG_ReadPos(vec3_t pos);
+void MSG_ReadDir(vec3_t vector);
#endif
-int MSG_ReadBits( int bits );
-void MSG_ReadDeltaUsercmd( const usercmd_t *from, usercmd_t *cmd );
-void MSG_ReadDeltaUsercmd_Hacked( const usercmd_t *from, usercmd_t *to );
-void MSG_ReadDeltaUsercmd_Enhanced( const usercmd_t *from, usercmd_t *to, int version );
-int MSG_ParseEntityBits( int *bits );
-void MSG_ParseDeltaEntity( const entity_state_t *from, entity_state_t *to, int number, int bits, msgEsFlags_t flags );
+int MSG_ReadBits(int bits);
+void MSG_ReadDeltaUsercmd(const usercmd_t *from, usercmd_t *cmd);
+void MSG_ReadDeltaUsercmd_Hacked(const usercmd_t *from, usercmd_t *to);
+void MSG_ReadDeltaUsercmd_Enhanced(const usercmd_t *from, usercmd_t *to, int version);
+int MSG_ParseEntityBits(int *bits);
+void MSG_ParseDeltaEntity(const entity_state_t *from, entity_state_t *to, int number, int bits, msgEsFlags_t flags);
#if USE_CLIENT
-void MSG_ParseDeltaPlayerstate_Default( const player_state_t *from, player_state_t *to, int flags );
-void MSG_ParseDeltaPlayerstate_Enhanced( const player_state_t *from, player_state_t *to, int flags, int extraflags );
+void MSG_ParseDeltaPlayerstate_Default(const player_state_t *from, player_state_t *to, int flags);
+void MSG_ParseDeltaPlayerstate_Enhanced(const player_state_t *from, player_state_t *to, int flags, int extraflags);
#endif
-void MSG_ParseDeltaPlayerstate_Packet( const player_state_t *from, player_state_t *to, int flags );
+void MSG_ParseDeltaPlayerstate_Packet(const player_state_t *from, player_state_t *to, int flags);
#ifdef _DEBUG
#if USE_CLIENT
-void MSG_ShowDeltaPlayerstateBits_Default( int flags );
-void MSG_ShowDeltaPlayerstateBits_Enhanced( int flags );
-void MSG_ShowDeltaUsercmdBits_Enhanced( int bits );
+void MSG_ShowDeltaPlayerstateBits_Default(int flags);
+void MSG_ShowDeltaPlayerstateBits_Enhanced(int flags);
+void MSG_ShowDeltaUsercmdBits_Enhanced(int bits);
#endif
#if USE_CLIENT || USE_MVD_CLIENT
-void MSG_ShowDeltaEntityBits( int bits );
-void MSG_ShowDeltaPlayerstateBits_Packet( int flags );
-const char *MSG_ServerCommandString( int cmd );
-#define MSG_ShowSVC( cmd ) \
- Com_LPrintf( PRINT_DEVELOPER, "%3"PRIz":%s\n", msg_read.readcount - 1, \
- MSG_ServerCommandString( cmd ) )
+void MSG_ShowDeltaEntityBits(int bits);
+void MSG_ShowDeltaPlayerstateBits_Packet(int flags);
+const char *MSG_ServerCommandString(int cmd);
+#define MSG_ShowSVC(cmd) \
+ Com_LPrintf(PRINT_DEVELOPER, "%3"PRIz":%s\n", msg_read.readcount - 1, \
+ MSG_ServerCommandString(cmd))
#endif // USE_CLIENT || USE_MVD_CLIENT
#endif // _DEBUG
//============================================================================
-static inline int MSG_PackSolid16( const vec3_t mins, const vec3_t maxs ) {
+static inline int MSG_PackSolid16(const vec3_t mins, const vec3_t maxs)
+{
int x, zd, zu;
// assume that x/y are equal and symetric
x = maxs[0] / 8;
- clamp( x, 1, 31 );
+ clamp(x, 1, 31);
// z is not symetric
zd = -mins[2] / 8;
- clamp( zd, 1, 31 );
+ clamp(zd, 1, 31);
// and z maxs can be negative...
- zu = ( maxs[2] + 32 ) / 8;
- clamp( zu, 1, 63 );
+ zu = (maxs[2] + 32) / 8;
+ clamp(zu, 1, 63);
- return ( zu << 10 ) | ( zd << 5 ) | x;
+ return (zu << 10) | (zd << 5) | x;
}
-static inline int MSG_PackSolid32( const vec3_t mins, const vec3_t maxs ) {
+static inline int MSG_PackSolid32(const vec3_t mins, const vec3_t maxs)
+{
int x, zd, zu;
// assume that x/y are equal and symetric
x = maxs[0];
- clamp( x, 1, 255 );
+ clamp(x, 1, 255);
// z is not symetric
zd = -mins[2];
- clamp( zd, 1, 255 );
+ clamp(zd, 1, 255);
// and z maxs can be negative...
zu = maxs[2] + 32768;
- clamp( zu, 1, 65535 );
+ clamp(zu, 1, 65535);
- return ( zu << 16 ) | ( zd << 8 ) | x;
+ return (zu << 16) | (zd << 8) | x;
}
-static inline void MSG_UnpackSolid16( int solid, vec3_t mins, vec3_t maxs ) {
+static inline void MSG_UnpackSolid16(int solid, vec3_t mins, vec3_t maxs)
+{
int x, zd, zu;
- x = 8 * ( solid & 31 );
- zd = 8 * ( ( solid >> 5 ) & 31 );
- zu = 8 * ( ( solid >> 10 ) & 63 ) - 32;
+ x = 8 * (solid & 31);
+ zd = 8 * ((solid >> 5) & 31);
+ zu = 8 * ((solid >> 10) & 63) - 32;
mins[0] = mins[1] = -x;
maxs[0] = maxs[1] = x;
@@ -210,12 +215,13 @@ static inline void MSG_UnpackSolid16( int solid, vec3_t mins, vec3_t maxs ) {
maxs[2] = zu;
}
-static inline void MSG_UnpackSolid32( int solid, vec3_t mins, vec3_t maxs ) {
+static inline void MSG_UnpackSolid32(int solid, vec3_t mins, vec3_t maxs)
+{
int x, zd, zu;
x = solid & 255;
- zd = ( solid >> 8 ) & 255;
- zu = ( ( solid >> 16 ) & 65535 ) - 32768;
+ zd = (solid >> 8) & 255;
+ zu = ((solid >> 16) & 65535) - 32768;
mins[0] = mins[1] = -x;
maxs[0] = maxs[1] = x;