diff --git a/include/QF/msg.h b/include/QF/msg.h index d10d435ae..cf0aa8505 100644 --- a/include/QF/msg.h +++ b/include/QF/msg.h @@ -41,7 +41,7 @@ void MSG_WriteLong (sizebuf_t *sb, int c); void MSG_WriteLongBE (sizebuf_t *sb, int c); void MSG_WriteFloat (sizebuf_t *sb, float f); void MSG_WriteString (sizebuf_t *sb, const char *s); -void MSG_WriteBytes (sizebuf_t *sb, const void *buf, int len); +void MSG_WriteBytes (sizebuf_t *sb, const void *buf, unsigned len); void MSG_WriteCoord (sizebuf_t *sb, float coord); void MSG_WriteCoordV (sizebuf_t *sb, const vec3_t coord); void MSG_WriteCoordAngleV (sizebuf_t *sb, const vec3_t coord, @@ -53,11 +53,11 @@ void MSG_WriteAngle16V (sizebuf_t *sb, const vec3_t angle); void MSG_WriteUTF8 (sizebuf_t *sb, unsigned utf8); typedef struct msg_s { - int readcount; - qboolean badread; // set if a read goes beyond end of message - sizebuf_t *message; - size_t badread_string_size; - char *badread_string; + unsigned readcount; + qboolean badread; // set if a read goes beyond end of message + sizebuf_t *message; + size_t badread_string_size; + char *badread_string; } qmsg_t; /** Reset the message read status. @@ -75,7 +75,7 @@ void MSG_BeginReading (qmsg_t *msg); \param msg The message to check. \return The number of bytes that have been read. */ -int MSG_GetReadCount(qmsg_t *msg) __attribute__((pure)); +unsigned MSG_GetReadCount(qmsg_t *msg) __attribute__((pure)); /** Read a single byte from the message. @@ -175,7 +175,7 @@ const char *MSG_ReadString (qmsg_t *msg); \param len The number of bytes to read. \return The number of bytes read from the message. */ -int MSG_ReadBytes (qmsg_t *msg, void *buf, int len); +int MSG_ReadBytes (qmsg_t *msg, void *buf, unsigned len); /** Read a little-endian 16-bit fixed point (13.3) coordinate value from the message. diff --git a/include/QF/sizebuf.h b/include/QF/sizebuf.h index 5e0e9a93c..c454cdc4c 100644 --- a/include/QF/sizebuf.h +++ b/include/QF/sizebuf.h @@ -37,18 +37,18 @@ typedef struct sizebuf_s { - qboolean allowoverflow; // if false, do a Sys_Error - qboolean overflowed; // set to true if the buffer size failed - byte *data; - int maxsize; - int cursize; + qboolean allowoverflow; // if false, do a Sys_Error + qboolean overflowed; // set to true if the buffer size failed + byte *data; + unsigned maxsize; + unsigned cursize; } sizebuf_t; -void SZ_Alloc (sizebuf_t *buf, int maxsize); +void SZ_Alloc (sizebuf_t *buf, unsigned maxsize); void SZ_Free (sizebuf_t *buf); void SZ_Clear (sizebuf_t *buf); -void *SZ_GetSpace (sizebuf_t *buf, int length); -void SZ_Write (sizebuf_t *buf, const void *data, int length); +void *SZ_GetSpace (sizebuf_t *buf, unsigned length); +void SZ_Write (sizebuf_t *buf, const void *data, unsigned length); void SZ_Print (sizebuf_t *buf, const char *data); // strcats onto the sizebuf void SZ_Dump (sizebuf_t *buf); diff --git a/include/netchan.h b/include/netchan.h index 6197cc8db..d502f1030 100644 --- a/include/netchan.h +++ b/include/netchan.h @@ -317,7 +317,7 @@ void Netchan_Init_Cvars (void); \param length The size of the unreliable packet. \param data The data of the unreliable packet. */ -void Netchan_Transmit (netchan_t *chan, int length, byte *data); +void Netchan_Transmit (netchan_t *chan, unsigned length, byte *data); /** Send an out-of-band packet. @@ -325,7 +325,7 @@ void Netchan_Transmit (netchan_t *chan, int length, byte *data); \param length The length of the data to be sent. \param data The data to be sent. */ -void Netchan_OutOfBand (netadr_t adr, int length, byte *data); +void Netchan_OutOfBand (netadr_t adr, unsigned length, byte *data); /** Send a formatted string as an out-of-band packet. \param adr The address to which the data will be sent. diff --git a/include/qw/msg_backbuf.h b/include/qw/msg_backbuf.h index 12cbb0b06..0a6cea2db 100644 --- a/include/qw/msg_backbuf.h +++ b/include/qw/msg_backbuf.h @@ -43,10 +43,10 @@ typedef struct backbuf_s { const char *name; } backbuf_t; -int MSG_ReliableCheckSize (backbuf_t *rel, int maxsize, int minsize) __attribute__((pure)); -sizebuf_t *MSG_ReliableCheckBlock(backbuf_t *rel, int maxsize); +int MSG_ReliableCheckSize (backbuf_t *rel, unsigned maxsize, unsigned minsize) __attribute__((pure)); +sizebuf_t *MSG_ReliableCheckBlock(backbuf_t *rel, unsigned maxsize); void MSG_Reliable_FinishWrite(backbuf_t *rel); -sizebuf_t *MSG_ReliableWrite_Begin(backbuf_t *rel, int c, int maxsize); +sizebuf_t *MSG_ReliableWrite_Begin(backbuf_t *rel, int c, unsigned maxsize); void MSG_ReliableWrite_Angle(backbuf_t *rel, float f); void MSG_ReliableWrite_Angle16(backbuf_t *rel, float f); void MSG_ReliableWrite_Byte(backbuf_t *rel, int c); @@ -56,7 +56,7 @@ void MSG_ReliableWrite_Coord(backbuf_t *rel, float f); void MSG_ReliableWrite_Long(backbuf_t *rel, int c); void MSG_ReliableWrite_Short(backbuf_t *rel, int c); void MSG_ReliableWrite_String(backbuf_t *rel, const char *s); -void MSG_ReliableWrite_SZ(backbuf_t *rel, const void *data, int len); +void MSG_ReliableWrite_SZ(backbuf_t *rel, const void *data, unsigned len); void MSG_ReliableWrite_AngleV(backbuf_t *rel, const vec3_t v); void MSG_ReliableWrite_CoordV(backbuf_t *rel, const vec3_t v); void MSG_Reliable_Send (backbuf_t *rel); diff --git a/libs/net/net_chan.c b/libs/net/net_chan.c index 61f125117..53557a95c 100644 --- a/libs/net/net_chan.c +++ b/libs/net/net_chan.c @@ -92,7 +92,7 @@ Netchan_Init_Cvars (void) Sends an out-of-band datagram */ void -Netchan_OutOfBand (netadr_t adr, int length, byte * data) +Netchan_OutOfBand (netadr_t adr, unsigned length, byte * data) { byte send_buf[MAX_MSGLEN + PACKET_HEADER]; sizebuf_t send; @@ -185,7 +185,7 @@ Netchan_CanReliable (netchan_t *chan) } void -Netchan_Transmit (netchan_t *chan, int length, byte *data) +Netchan_Transmit (netchan_t *chan, unsigned length, byte *data) { byte send_buf[MAX_MSGLEN + PACKET_HEADER]; int i; diff --git a/libs/qw/msg_backbuf.c b/libs/qw/msg_backbuf.c index 90d80704c..3a87cedc5 100644 --- a/libs/qw/msg_backbuf.c +++ b/libs/qw/msg_backbuf.c @@ -59,7 +59,7 @@ PushBackbuf (backbuf_t *rel) } int -MSG_ReliableCheckSize (backbuf_t *rel, int maxsize, int minsize) +MSG_ReliableCheckSize (backbuf_t *rel, unsigned maxsize, unsigned minsize) { sizebuf_t *msg = &rel->netchan->message; @@ -80,7 +80,7 @@ MSG_ReliableCheckSize (backbuf_t *rel, int maxsize, int minsize) // check to see if client block will fit, if not, rotate buffers sizebuf_t * -MSG_ReliableCheckBlock (backbuf_t *rel, int maxsize) +MSG_ReliableCheckBlock (backbuf_t *rel, unsigned maxsize) { sizebuf_t *msg = &rel->netchan->message; @@ -108,7 +108,7 @@ MSG_ReliableCheckBlock (backbuf_t *rel, int maxsize) // begin a client block, estimated maximum size sizebuf_t * -MSG_ReliableWrite_Begin (backbuf_t *rel, int c, int maxsize) +MSG_ReliableWrite_Begin (backbuf_t *rel, int c, unsigned maxsize) { sizebuf_t *msg; msg = MSG_ReliableCheckBlock (rel, maxsize); @@ -226,7 +226,7 @@ MSG_ReliableWrite_String (backbuf_t *rel, const char *s) } void -MSG_ReliableWrite_SZ (backbuf_t *rel, const void *data, int len) +MSG_ReliableWrite_SZ (backbuf_t *rel, const void *data, unsigned len) { if (rel->num_backbuf) { SZ_Write (&rel->backbuf, data, len); diff --git a/libs/util/msg.c b/libs/util/msg.c index 92596dcc6..0908dff2b 100644 --- a/libs/util/msg.c +++ b/libs/util/msg.c @@ -126,7 +126,7 @@ MSG_WriteString (sizebuf_t *sb, const char *s) } VISIBLE void -MSG_WriteBytes (sizebuf_t *sb, const void *buf, int len) +MSG_WriteBytes (sizebuf_t *sb, const void *buf, unsigned len) { SZ_Write (sb, buf, len); } @@ -253,7 +253,7 @@ MSG_BeginReading (qmsg_t *msg) msg->badread = false; } -VISIBLE int +VISIBLE unsigned MSG_GetReadCount (qmsg_t *msg) { return msg->readcount; @@ -403,7 +403,7 @@ MSG_ReadString (qmsg_t *msg) } VISIBLE int -MSG_ReadBytes (qmsg_t *msg, void *buf, int len) +MSG_ReadBytes (qmsg_t *msg, void *buf, unsigned len) { if (msg->badread || len > msg->message->cursize - msg->readcount) { msg->badread = true; @@ -474,7 +474,8 @@ VISIBLE int MSG_ReadUTF8 (qmsg_t *msg) { byte *buf, *start, c; - int val = 0, count; + int val = 0; + unsigned count; if (msg->badread || msg->message->cursize == msg->readcount) { msg->badread = true; diff --git a/libs/util/sizebuf.c b/libs/util/sizebuf.c index f7d433110..25f835a4f 100644 --- a/libs/util/sizebuf.c +++ b/libs/util/sizebuf.c @@ -41,7 +41,7 @@ VISIBLE void -SZ_Alloc (sizebuf_t *buf, int maxsize) +SZ_Alloc (sizebuf_t *buf, unsigned maxsize) { if (maxsize < 256) maxsize = 256; @@ -58,7 +58,7 @@ SZ_Clear (sizebuf_t *buf) } VISIBLE void * -SZ_GetSpace (sizebuf_t *buf, int length) +SZ_GetSpace (sizebuf_t *buf, unsigned length) { void *data; @@ -83,7 +83,7 @@ getspace: } VISIBLE void -SZ_Write (sizebuf_t *buf, const void *data, int length) +SZ_Write (sizebuf_t *buf, const void *data, unsigned length) { memcpy (SZ_GetSpace (buf, length), data, length); } @@ -91,7 +91,7 @@ SZ_Write (sizebuf_t *buf, const void *data, int length) VISIBLE void SZ_Print (sizebuf_t *buf, const char *data) { - int len; + unsigned len; len = strlen (data) + 1; if (buf->cursize && !buf->data[buf->cursize - 1]) @@ -103,7 +103,7 @@ SZ_Print (sizebuf_t *buf, const char *data) VISIBLE void SZ_Dump (sizebuf_t *buf) { - int i; + unsigned i; char chars[17], c; chars[16] = 0; diff --git a/nq/source/cl_demo.c b/nq/source/cl_demo.c index 0d7e91a51..a119cb8b6 100644 --- a/nq/source/cl_demo.c +++ b/nq/source/cl_demo.c @@ -174,7 +174,8 @@ check_next_demopacket (void) static int read_demopacket (void) { - int i, r; + int i; + unsigned r; float f; Qread (cls.demofile, &net_message->message->cursize, 4); diff --git a/qtv/source/server.c b/qtv/source/server.c index 00778acea..28f43ad6f 100644 --- a/qtv/source/server.c +++ b/qtv/source/server.c @@ -124,7 +124,7 @@ server_compare (const void *a, const void *b) } static void -setup_sub_message (qmsg_t *msg, qmsg_t *sub, sizebuf_t *buf, int len) +setup_sub_message (qmsg_t *msg, qmsg_t *sub, sizebuf_t *buf, unsigned len) { memset (sub, 0, sizeof (qmsg_t)); memset (buf, 0, sizeof (sizebuf_t)); @@ -274,7 +274,7 @@ server_handler (connection_t *con, void *object) if (!Netchan_Process (&sv->netchan)) return; if (0) { - int i; + unsigned i; for (i = 0; i < net_message->message->cursize; i++) qtv_printf ("%c%02x", (i % 16) ? ' ' : '\n', diff --git a/qw/include/sv_recorder.h b/qw/include/sv_recorder.h index f8be8b97f..a2875360a 100644 --- a/qw/include/sv_recorder.h +++ b/qw/include/sv_recorder.h @@ -41,7 +41,7 @@ recorder_t *SVR_AddUser (void (*writer)(void *, struct sizebuf_s *, int), void (*finish)(void *, struct sizebuf_s *), int demo, void *user); void SVR_RemoveUser (recorder_t *r); -struct sizebuf_s *SVR_WriteBegin (byte type, int to, int size); +struct sizebuf_s *SVR_WriteBegin (byte type, int to, unsigned size); struct sizebuf_s *SVR_Datagram (void) __attribute__((const)); void SVR_ForceFrame (void); void SVR_Pause (recorder_t *r); diff --git a/qw/source/cl_demo.c b/qw/source/cl_demo.c index 51789e572..dd4114e14 100644 --- a/qw/source/cl_demo.c +++ b/qw/source/cl_demo.c @@ -271,7 +271,7 @@ check_next_demopacket (void) static int read_demopacket (void) { - int r; + unsigned r; Qread (cls.demofile, &net_message->message->cursize, 4); net_message->message->cursize = diff --git a/qw/source/cl_main.c b/qw/source/cl_main.c index 09ef477c4..e2deb673b 100644 --- a/qw/source/cl_main.c +++ b/qw/source/cl_main.c @@ -1013,8 +1013,10 @@ CL_ReadPackets (void) { while (CL_GetMessage ()) { - if (net_message->message->cursize == -1) + // non-packet set up by the demo reader + if ((int) net_message->message->cursize == -1) { continue; + } if (cls.demoplayback && net_packetlog->int_val) Log_Incoming_Packet (net_message->message->data, diff --git a/qw/source/sv_recorder.c b/qw/source/sv_recorder.c index d2555862e..cd5cdf1c2 100644 --- a/qw/source/sv_recorder.c +++ b/qw/source/sv_recorder.c @@ -56,8 +56,8 @@ typedef struct dbuffer_s { byte *data; - int start, end, last; - int maxsize; + unsigned start, end, last; + unsigned maxsize; } dbuffer_t; typedef struct header_s { @@ -70,7 +70,7 @@ typedef struct header_s { typedef struct demobuf_s { sizebuf_t sz; - int bufsize; + unsigned bufsize; header_t *h; } demobuf_t; @@ -200,9 +200,9 @@ write_msg (sizebuf_t *msg, int type, int to, float time, sizebuf_t *dst) static void write_to_msg (int type, int to, float time, sizebuf_t *dst) { - int pos = 0; + unsigned pos = 0; header_t *p; - int size; + unsigned size; sizebuf_t msg; p = (header_t *) rec.dbuf->sz.data; @@ -256,7 +256,7 @@ static void set_buf (byte type, int to) { header_t *p; - int pos = 0; + unsigned pos = 0; p = (header_t *) rec.dbuf->sz.data; @@ -464,7 +464,7 @@ write_packet (void) } sizebuf_t * -SVR_WriteBegin (byte type, int to, int size) +SVR_WriteBegin (byte type, int to, unsigned size) { byte *p; qboolean move = false;