]> git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
more size_t
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Tue, 5 Jul 2005 10:49:06 +0000 (10:49 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Tue, 5 Jul 2005 10:49:06 +0000 (10:49 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@5497 d7cf8633-e32d-0410-b094-e92efae38249

24 files changed:
cgame.c
cl_demo.c
cl_main.c
cl_parse.c
cl_screen.c
cmd.c
common.c
common.h
console.c
cvar.c
fs.c
fs.h
gl_rmain.c
host_cmd.c
keys.c
menu.c
netconn.c
progsvm.h
prvm_cmds.c
prvm_edict.c
prvm_exec.c
r_shadow.c
sbar.c
snd_mix.c

diff --git a/cgame.c b/cgame.c
index 86da9a53d8074849f5d6ee6981eb276349164949..ad162bc14c9a2eccfd52afc4b4e07f9386549236 100644 (file)
--- a/cgame.c
+++ b/cgame.c
@@ -72,7 +72,7 @@ static localentity_t *entspawn(void)
 static void entremove(localentity_t *e)
 {
        int i;
-       i = (e - localentity) / sizeof(localentity_t);
+       i = (int)((e - localentity) / sizeof(localentity_t));
        if (i < 0 || i >= MAX_LOCALENTITIES)
                return; // this should be an error
        //memset(e, 0, sizeof(*e));
index cdf8209cfa086e15278ac48e504f4c034d3da167..865a1b36a5d3152cafdbd76c08ac5bd5043f8002 100644 (file)
--- a/cl_demo.c
+++ b/cl_demo.c
@@ -185,7 +185,7 @@ void CL_ReadDemoMessage(void)
                VectorCopy(cl.mviewangles[0], cl.mviewangles[1]);
                for (i = 0;i < 3;i++)
                {
-                       r = FS_Read(cls.demofile, &f, 4);
+                       r = (int)FS_Read(cls.demofile, &f, 4);
                        cl.mviewangles[0][i] = LittleFloat(f);
                }
 
index d638d18598e827bcfd0478a5df1321eeb41e87d5..632e185056080ddda5e08182f312d8e9ae74216a 100644 (file)
--- a/cl_main.c
+++ b/cl_main.c
@@ -331,7 +331,7 @@ static void CL_PrintEntities_f(void)
                        strlcpy (name, ent->render.model->name, 25);
                else
                        strcpy(name, "--no model--");
-               for (j = strlen(name);j < 25;j++)
+               for (j = (int)strlen(name);j < 25;j++)
                        name[j] = ' ';
                Con_Printf("%3i: %s:%4i (%5i %5i %5i) [%3i %3i %3i] %4.2f %5.3f\n", i, name, ent->render.frame, (int) ent->render.origin[0], (int) ent->render.origin[1], (int) ent->render.origin[2], (int) ent->render.angles[0] % 360, (int) ent->render.angles[1] % 360, (int) ent->render.angles[2] % 360, ent->render.scale, ent->render.alpha);
        }
index 6cfe6acf3ad19b18a8ffda7df8f8a54c99e9b0da..20e9e70a62792f53adcdc5b511cc0216218898eb 100644 (file)
@@ -1489,7 +1489,7 @@ void CL_ParseServerMessage(void)
                                Host_Error ("svc_lightstyle >= MAX_LIGHTSTYLES");
                        strlcpy (cl_lightstyle[i].map,  MSG_ReadString(), sizeof (cl_lightstyle[i].map));
                        cl_lightstyle[i].map[MAX_STYLESTRING - 1] = 0;
-                       cl_lightstyle[i].length = strlen(cl_lightstyle[i].map);
+                       cl_lightstyle[i].length = (int)strlen(cl_lightstyle[i].map);
                        break;
 
                case svc_sound:
index 5519df6e7a1349371480ddc31246fbcea8605b50..c11c4966231d576a16c57f4354e50caac5761223 100644 (file)
@@ -61,7 +61,7 @@ static vec4_t string_colors[] =
        {1.0, 1.0, 1.0, 1.0}, // white
        // [515]'s BX_COLOREDTEXT extension
        {1.0, 1.0, 1.0, 0.5}, // half transparent
-       {0.5, 0.5, 0.5, 1.0}  // half brightness        
+       {0.5, 0.5, 0.5, 1.0}  // half brightness
        // Black's color table
        //{1.0, 1.0, 1.0, 1.0},
        //{1.0, 0.0, 0.0, 1.0},
@@ -91,9 +91,9 @@ void DrawQ_ColoredString( float x, float y, const char *text, int maxlen, float
        color = string_colors[colorindex];
 
        if( maxlen < 1)
-               len = strlen( text );
+               len = (int)strlen( text );
        else
-               len = min( maxlen, (signed) strlen( text ) );
+               len = min( maxlen, (int) strlen( text ) );
 
        start = current = text;
        while( len > 0 ) {
@@ -127,7 +127,7 @@ void DrawQ_ColoredString( float x, float y, const char *text, int maxlen, float
                                } while( len > 0 && '0' <= *current && *current <= '9' );
                                // set the color
                                color = string_colors[colorindex];
-                               // we jump over the color tag 
+                               // we jump over the color tag
                                start = current;
                        }
                }
@@ -433,7 +433,7 @@ void R_TimeReport(char *desc)
        t = (int) ((r_timereport_current - r_timereport_temp) * 1000000.0);
 
        dpsnprintf(tempbuf, sizeof(tempbuf), "%8i %s", t, desc);
-       length = strlen(tempbuf);
+       length = (int)strlen(tempbuf);
        while (length < 20)
                tempbuf[length++] = ' ';
        tempbuf[length] = 0;
@@ -610,7 +610,7 @@ void DrawQ_String_Real(float x, float y, const char *string, int maxlen, float s
        if (alpha < (1.0f / 255.0f))
                return;
        if (maxlen < 1)
-               len = strlen(string);
+               len = (int)strlen(string);
        else
                for (len = 0;len < maxlen && string[len];len++);
        for (;len > 0 && string[0] == ' ';string++, x += scalex, len--);
diff --git a/cmd.c b/cmd.c
index 0a6459743b36b8ad65f5d08ed62c749d29ddf5f0..41c38794562dbf90b5ab7bfec9a135bb3dad0274 100644 (file)
--- a/cmd.c
+++ b/cmd.c
@@ -79,7 +79,7 @@ void Cbuf_AddText (const char *text)
 {
        int             l;
 
-       l = strlen (text);
+       l = (int)strlen (text);
 
        if (cmd_text.cursize + l >= cmd_text.maxsize)
        {
@@ -87,7 +87,7 @@ void Cbuf_AddText (const char *text)
                return;
        }
 
-       SZ_Write (&cmd_text, text, strlen (text));
+       SZ_Write (&cmd_text, text, (int)strlen (text));
 }
 
 
@@ -412,7 +412,7 @@ static void Cmd_List_f (void)
        if (Cmd_Argc() > 1)
        {
                partial = Cmd_Argv (1);
-               len = strlen(partial);
+               len = (int)strlen(partial);
        }
        else
        {
@@ -555,7 +555,7 @@ static void Cmd_TokenizeString (const char *text)
 
                if (cmd_argc < MAX_ARGS)
                {
-                       l = strlen(com_token) + 1;
+                       l = (int)strlen(com_token) + 1;
                        if (cmd_tokenizebufferpos + l > CMD_TOKENIZELENGTH)
                        {
                                Con_Printf("Cmd_TokenizeString: ran out of %i character buffer space for command arguements\n", CMD_TOKENIZELENGTH);
@@ -638,7 +638,7 @@ Cmd_CompleteCommand
 const char *Cmd_CompleteCommand (const char *partial)
 {
        cmd_function_t *cmd;
-       int len;
+       size_t len;
 
        len = strlen(partial);
 
@@ -665,7 +665,8 @@ const char *Cmd_CompleteCommand (const char *partial)
 int Cmd_CompleteCountPossible (const char *partial)
 {
        cmd_function_t *cmd;
-       int len, h;
+       size_t len;
+       int h;
 
        h = 0;
        len = strlen(partial);
@@ -693,9 +694,9 @@ int Cmd_CompleteCountPossible (const char *partial)
 const char **Cmd_CompleteBuildList (const char *partial)
 {
        cmd_function_t *cmd;
-       int len = 0;
-       int bpos = 0;
-       int sizeofbuf = (Cmd_CompleteCountPossible (partial) + 1) * sizeof (const char *);
+       size_t len = 0;
+       size_t bpos = 0;
+       size_t sizeofbuf = (Cmd_CompleteCountPossible (partial) + 1) * sizeof (const char *);
        const char **buf;
 
        len = strlen(partial);
@@ -721,7 +722,7 @@ const char **Cmd_CompleteBuildList (const char *partial)
 const char *Cmd_CompleteAlias (const char *partial)
 {
        cmdalias_t *alias;
-       int len;
+       size_t len;
 
        len = strlen(partial);
 
@@ -748,7 +749,7 @@ const char *Cmd_CompleteAlias (const char *partial)
 int Cmd_CompleteAliasCountPossible (const char *partial)
 {
        cmdalias_t      *alias;
-       int                     len;
+       size_t          len;
        int                     h;
 
        h = 0;
@@ -778,9 +779,9 @@ int Cmd_CompleteAliasCountPossible (const char *partial)
 const char **Cmd_CompleteAliasBuildList (const char *partial)
 {
        cmdalias_t *alias;
-       int len = 0;
-       int bpos = 0;
-       int sizeofbuf = (Cmd_CompleteAliasCountPossible (partial) + 1) * sizeof (const char *);
+       size_t len = 0;
+       size_t bpos = 0;
+       size_t sizeofbuf = (Cmd_CompleteAliasCountPossible (partial) + 1) * sizeof (const char *);
        const char **buf;
 
        len = strlen(partial);
@@ -871,7 +872,7 @@ void Cmd_ForwardStringToServer (const char *s)
        // attention, it has been eradicated from here, its only (former) use in
        // all of darkplaces.
        MSG_WriteByte(&cls.message, clc_stringcmd);
-       SZ_Write(&cls.message, s, strlen(s) + 1);
+       SZ_Write(&cls.message, s, (int)strlen(s) + 1);
 }
 
 /*
index bfdb26ee0ee56f8f40886e9ad6e8f35420395392..a8d0a9f43d262cfe40a7ee85db488d4e017751d8 100644 (file)
--- a/common.c
+++ b/common.c
@@ -171,7 +171,7 @@ static unsigned short crctable[256] =
        0x6e17, 0x7e36, 0x4e55, 0x5e74, 0x2e93, 0x3eb2, 0x0ed1, 0x1ef0
 };
 
-unsigned short CRC_Block(const qbyte *data, int size)
+unsigned short CRC_Block(const qbyte *data, size_t size)
 {
        unsigned short crc = CRC_INIT_VALUE;
        while (size--)
@@ -249,7 +249,7 @@ void MSG_WriteString (sizebuf_t *sb, const char *s)
        if (!s)
                SZ_Write (sb, "", 1);
        else
-               SZ_Write (sb, s, strlen(s)+1);
+               SZ_Write (sb, s, (int)strlen(s)+1);
 }
 
 void MSG_WriteCoord13i (sizebuf_t *sb, float f)
@@ -1131,7 +1131,7 @@ int COM_ReadAndTokenizeLine(const char **text, char **argv, int maxargc, char *t
        l = *text;
        commentprefixlength = 0;
        if (commentprefix)
-               commentprefixlength = strlen(commentprefix);
+               commentprefixlength = (int)strlen(commentprefix);
        while (*l && *l != '\n' && *l != '\r')
        {
                if (*l > ' ')
index 210b8af85bc92a4188bc7074223a2640121cc5f6..cceb571af3ff090c3b1c66a3a357bc165da5c286 100644 (file)
--- a/common.h
+++ b/common.h
@@ -62,7 +62,7 @@ void SZ_HexDumpToConsole(const sizebuf_t *buf);
 
 void Com_HexDumpToConsole(const qbyte *data, int size);
 
-unsigned short CRC_Block(const qbyte *data, int size);
+unsigned short CRC_Block(const qbyte *data, size_t size);
 
 
 //============================================================================
index 148c05716bfd8798a1244a325798d77639a60082..3cb08835c33335e1eada3588fc842973ec59cde9 100644 (file)
--- a/console.c
+++ b/console.c
@@ -182,7 +182,7 @@ void Log_ConPrint (const char *msg)
                // If we need to enlarge the log queue
                if (len > remain)
                {
-                       unsigned int factor = ((logq_ind + len) / logq_size) + 1;
+                       size_t factor = ((logq_ind + len) / logq_size) + 1;
                        qbyte* newqueue;
 
                        logq_size *= factor;
@@ -693,7 +693,7 @@ void Con_DrawInput (void)
        // use strlen of edit_line instead of key_linepos to allow editing
        // of early characters w/o erasing
 
-       y = strlen(text);
+       y = (int)strlen(text);
 
 // fill out remainder with spaces
        for (i = y; i < 256; i++)
@@ -851,7 +851,7 @@ void Con_DisplayList(const char **list)
        const char **walk = list;
 
        while (*walk) {
-               len = strlen(*walk);
+               len = (int)strlen(*walk);
                if (len > maxlen)
                        maxlen = len;
                walk++;
@@ -859,7 +859,7 @@ void Con_DisplayList(const char **list)
        maxlen += 1;
 
        while (*list) {
-               len = strlen(*list);
+               len = (int)strlen(*list);
                if (pos + maxlen >= width) {
                        Con_Print("\n");
                        pos = 0;
@@ -909,7 +909,7 @@ void Con_CompleteCommandLine (void)
                else
                        list[0] = Cmd_CompleteAliasBuildList(s);
                cmd = *list[0];
-               cmd_len = strlen (cmd);
+               cmd_len = (int)strlen (cmd);
        } else {
                if (c)
                        cmd = *(list[0] = Cmd_CompleteBuildList(s));
@@ -918,7 +918,7 @@ void Con_CompleteCommandLine (void)
                if (a)
                        cmd = *(list[2] = Cmd_CompleteAliasBuildList(s));
 
-               cmd_len = strlen (s);
+               cmd_len = (int)strlen (s);
                do {
                        for (i = 0; i < 3; i++) {
                                char ch = cmd[cmd_len];
diff --git a/cvar.c b/cvar.c
index 8236ae848f54f500376ffc028a9cfd878cbdfdb9..5df43cc2726f989ad893c6530a76502284fec1ec 100644 (file)
--- a/cvar.c
+++ b/cvar.c
@@ -119,7 +119,7 @@ Cvar_CompleteVariable
 const char *Cvar_CompleteVariable (const char *partial)
 {
        cvar_t          *cvar;
-       int                     len;
+       size_t          len;
 
        len = strlen(partial);
 
@@ -146,7 +146,7 @@ const char *Cvar_CompleteVariable (const char *partial)
 int Cvar_CompleteCountPossible (const char *partial)
 {
        cvar_t  *cvar;
-       int             len;
+       size_t  len;
        int             h;
 
        h = 0;
@@ -175,9 +175,9 @@ int Cvar_CompleteCountPossible (const char *partial)
 const char **Cvar_CompleteBuildList (const char *partial)
 {
        const cvar_t *cvar;
-       int len = 0;
-       int bpos = 0;
-       int sizeofbuf = (Cvar_CompleteCountPossible (partial) + 1) * sizeof (const char *);
+       size_t len = 0;
+       size_t bpos = 0;
+       size_t sizeofbuf = (Cvar_CompleteCountPossible (partial) + 1) * sizeof (const char *);
        const char **buf;
 
        len = strlen(partial);
@@ -379,7 +379,7 @@ cvar_t *Cvar_Get (const char *name, const char *value, int flags)
                cvar->flags |= flags;
                Cvar_SetQuick_Internal (cvar, value);
                // also set the default value (but only once)
-               if (~cvar->flags & CVAR_DEFAULTSET) 
+               if (~cvar->flags & CVAR_DEFAULTSET)
                {
                        cvar->flags |= CVAR_DEFAULTSET;
 
@@ -481,7 +481,8 @@ void Cvar_List_f (void)
 {
        cvar_t *cvar;
        const char *partial;
-       int len, count;
+       size_t len;
+       int count;
 
        if (Cmd_Argc() > 1)
        {
diff --git a/fs.c b/fs.c
index ce6ec632639f5bb302091656949566076a2e4f1d..bfab7a8b328aba39aa8207775da61b511dbf6c97 100644 (file)
--- a/fs.c
+++ b/fs.c
@@ -258,7 +258,7 @@ VARIABLES
 
 mempool_t *fs_mempool;
 
-int fs_filesize;
+size_t fs_filesize;
 
 pack_t *packlist = NULL;
 
@@ -433,7 +433,7 @@ int PK3_BuildFileList (pack_t *pack, const pk3_endOfCentralDir_t *eocd)
 {
        qbyte *central_dir, *ptr;
        unsigned int ind;
-       int remaining;
+       size_t remaining;
 
        // Load the central directory in memory
        central_dir = Mem_Alloc (tempmempool, eocd->cdir_size);
@@ -475,7 +475,7 @@ int PK3_BuildFileList (pack_t *pack, const pk3_endOfCentralDir_t *eocd)
                if ((ptr[8] & 0x29) == 0 && (ptr[38] & 0x18) == 0)
                {
                        // Still enough bytes for the name?
-                       if ((size_t) remaining < namesize || namesize >= sizeof (*pack->files))
+                       if (remaining < namesize || namesize >= sizeof (*pack->files))
                        {
                                Mem_Free (central_dir);
                                return -1;
@@ -958,7 +958,7 @@ void FS_Init (void)
        if (i && i < com_argc-1)
        {
                strlcpy (fs_basedir, com_argv[i+1], sizeof (fs_basedir));
-               i = strlen (fs_basedir);
+               i = (int)strlen (fs_basedir);
                if (i > 0 && (fs_basedir[i-1] == '\\' || fs_basedir[i-1] == '/'))
                        fs_basedir[i-1] = 0;
        }
@@ -1157,7 +1157,7 @@ qfile_t *FS_OpenPackedFile (pack_t* pack, int pack_ind)
 
        pfile = &pack->files[pack_ind];
 
-       fs_filesize = -1;
+       fs_filesize = 0;
 
        // If we don't have the true offset, get it now
        if (! (pfile->flags & PACKFILE_FLAG_TRUEOFFS))
@@ -1383,7 +1383,7 @@ qfile_t *FS_OpenReadFile (const char *filename, qboolean quiet, qboolean nonbloc
        // Not found?
        if (search == NULL)
        {
-               fs_filesize = -1;
+               fs_filesize = 0;
                return NULL;
        }
 
@@ -1621,7 +1621,7 @@ size_t FS_Read (qfile_t* file, void* buffer, size_t buffersize)
                }
 
                ztk->zstream.next_in = &ztk->input[ztk->in_ind];
-               ztk->zstream.avail_in = ztk->in_len - ztk->in_ind;
+               ztk->zstream.avail_in = (unsigned int)(ztk->in_len - ztk->in_ind);
 
                // Now that we are sure we have compressed data available, we need to determine
                // if it's better to inflate it in "file->buff" or directly in "buffer"
@@ -1652,7 +1652,7 @@ size_t FS_Read (qfile_t* file, void* buffer, size_t buffersize)
                else
                {
                        ztk->zstream.next_out = &((qbyte*)buffer)[done];
-                       ztk->zstream.avail_out = buffersize;
+                       ztk->zstream.avail_out = (unsigned int)buffersize;
                        error = qz_inflate (&ztk->zstream, Z_SYNC_FLUSH);
                        if (error != Z_OK && error != Z_STREAM_END)
                        {
@@ -1793,14 +1793,14 @@ int FS_Seek (qfile_t* file, long offset, int whence)
        switch (whence)
        {
                case SEEK_CUR:
-                       offset += file->position - file->buff_len + file->buff_ind;
+                       offset += (long)(file->position - file->buff_len + file->buff_ind);
                        break;
 
                case SEEK_SET:
                        break;
 
                case SEEK_END:
-                       offset += file->real_length;
+                       offset += (long)file->real_length;
                        break;
 
                default:
@@ -1879,7 +1879,7 @@ FS_Tell
 Give the current position in a file
 ====================
 */
-long FS_Tell (qfile_t* file)
+size_t FS_Tell (qfile_t* file)
 {
        return file->position - file->buff_len + file->buff_ind;
 }
@@ -2075,7 +2075,7 @@ fssearch_t *FS_Search(const char *pattern, int caseinsensitive, int quiet)
        fssearch_t *search;
        searchpath_t *searchpath;
        pack_t *pak;
-       int i, basepathlength, numfiles, numchars;
+       size_t i, basepathlength, numfiles, numchars;
        stringlist_t *dir, *dirfile, *liststart, *listcurrent, *listtemp;
        const char *slash, *backslash, *colon, *separator;
        char *basepath;
@@ -2217,12 +2217,12 @@ void FS_FreeSearch(fssearch_t *search)
 extern int con_linewidth;
 int FS_ListDirectory(const char *pattern, int oneperline)
 {
-       int numfiles;
-       int numcolumns;
-       int numlines;
-       int columnwidth;
-       int linebufpos;
-       int i, j, k, l;
+       size_t numfiles;
+       size_t numcolumns;
+       size_t numlines;
+       size_t columnwidth;
+       size_t linebufpos;
+       size_t i, j, k, l;
        const char *name;
        char linebuf[4096];
        fssearch_t *search;
@@ -2261,11 +2261,11 @@ int FS_ListDirectory(const char *pattern, int oneperline)
                                        if (l < numfiles)
                                        {
                                                name = search->filenames[l];
-                                               for (j = 0;name[j] && j < (int)sizeof(linebuf) - 1;j++)
+                                               for (j = 0;name[j] && linebufpos + 1 < sizeof(linebuf);j++)
                                                        linebuf[linebufpos++] = name[j];
                                                // space out name unless it's the last on the line
-                                               if (k < (numcolumns - 1) && l < (numfiles - 1))
-                                                       for (;j < columnwidth && j < (int)sizeof(linebuf) - 1;j++)
+                                               if (k + 1 < numcolumns && l + 1 < numfiles)
+                                                       for (;j < columnwidth && linebufpos + 1 < sizeof(linebuf);j++)
                                                                linebuf[linebufpos++] = ' ';
                                        }
                                }
diff --git a/fs.h b/fs.h
index 878d121cb657b135292ee1d744e72571f28374b4..7e9192a593e1d78c6440669940f04b60611fab06 100644 (file)
--- a/fs.h
+++ b/fs.h
@@ -36,7 +36,7 @@ typedef struct qfile_s qfile_t;
 extern char fs_gamedir [MAX_OSPATH];
 extern char fs_basedir [MAX_OSPATH];
 
-extern int fs_filesize;  // set by FS_Open (in "read" mode) and FS_LoadFile
+extern size_t fs_filesize;  // set by FS_Open (in "read" mode) and FS_LoadFile
 
 
 // ------ Main functions ------ //
@@ -54,7 +54,7 @@ int FS_VPrintf(qfile_t* file, const char* format, va_list ap);
 int FS_Getc (qfile_t* file);
 int FS_UnGetc (qfile_t* file, unsigned char c);
 int FS_Seek (qfile_t* file, long offset, int whence);
-long FS_Tell (qfile_t* file);
+size_t FS_Tell (qfile_t* file);
 void FS_Purge (qfile_t* file);
 
 typedef struct fssearch_s
index 2302d2abd526b223a71f91b22d7236e0a9c19267..276a6455021dd00123234bbed1fa4d4c9c5dbbfa 100644 (file)
@@ -473,7 +473,7 @@ void gl_main_newmap(void)
        if (cl.worldmodel)
        {
                strlcpy(entname, cl.worldmodel->name, sizeof(entname));
-               l = strlen(entname) - 4;
+               l = (int)strlen(entname) - 4;
                if (l >= 0 && !strcmp(entname + l, ".bsp"))
                {
                        strcpy(entname + l, ".ent");
index 7a533d9b2d2893f36670b870d96fdffab238da75..3a62b1dfb75b2b62d6cc3f959c839a7ea0b9da24 100644 (file)
@@ -971,7 +971,7 @@ void Host_Say_Team_f(void)
 void Host_Tell_f(void)
 {
        client_t *save;
-       int j;
+       size_t j;
        const char *p1, *p2;
        char text[1024]; // LordHavoc: FIXME: temporary buffer overflow fix (was 64)
        qboolean fromServer = false;
@@ -1018,7 +1018,7 @@ void Host_Tell_f(void)
        }
        while (p2 > p1 && (p2[-1] == '\n' || p2[-1] == '\r'))
                p2--;
-       for (j = strlen(text);j < (int)(sizeof(text) - 2) && p1 < p2;)
+       for (j = strlen(text);j < (sizeof(text) - 2) && p1 < p2;)
                text[j++] = *p1++;
        text[j++] = '\n';
        text[j++] = 0;
diff --git a/keys.c b/keys.c
index 5b1aad5fcb7a82030d87c5c4fc20672bbf03b887..4be917f352ad3a9412ce74101d798fd67c06fc7a 100644 (file)
--- a/keys.c
+++ b/keys.c
@@ -272,7 +272,7 @@ Key_Console (int key, char ascii)
                {
                        int i;
                        strtok(cbd, "\n\r\b");
-                       i = strlen(cbd);
+                       i = (int)strlen(cbd);
                        if (i + key_linepos >= MAX_INPUTLINE)
                                i= MAX_INPUTLINE - key_linepos;
                        if (i > 0)
@@ -378,7 +378,7 @@ Key_Console (int key, char ascii)
                {
                        history_line--;
                        strcpy(key_lines[edit_line], key_lines[history_line]);
-                       key_linepos = strlen(key_lines[edit_line]);
+                       key_linepos = (int)strlen(key_lines[edit_line]);
                }
                return;
        }
@@ -396,7 +396,7 @@ Key_Console (int key, char ascii)
                else
                {
                        strcpy(key_lines[edit_line], key_lines[history_line]);
-                       key_linepos = strlen(key_lines[edit_line]);
+                       key_linepos = (int)strlen(key_lines[edit_line]);
                }
                return;
        }
@@ -436,7 +436,7 @@ Key_Console (int key, char ascii)
        if (key_linepos < MAX_INPUTLINE-1)
        {
                int len;
-               len = strlen(&key_lines[edit_line][key_linepos]);
+               len = (int)strlen(&key_lines[edit_line][key_linepos]);
                // check insert mode, or always insert if at end of line
                if (key_insert || len == 0)
                {
@@ -553,8 +553,8 @@ Key_KeynumToString (int keynum)
 void
 Key_SetBinding (int keynum, int bindmap, const char *binding)
 {
-       char       *new;
-       int         l;
+       char *new;
+       size_t l;
 
        if (keynum == -1)
                return;
diff --git a/menu.c b/menu.c
index f1a1355204e01962b00f9a909a42131de0f6271d..a3b37a6290e7c0972d9184f3fe04dd6ed5b69fb9 100644 (file)
--- a/menu.c
+++ b/menu.c
@@ -819,7 +819,7 @@ int         loadable[MAX_SAVEGAMES];
 
 void M_ScanSaves (void)
 {
-       int             i, j, len;
+       size_t  i, j, len;
        char    name[MAX_OSPATH];
        char    buf[SAVEGAME_COMMENT_LENGTH + 256];
        const char *t;
@@ -830,7 +830,7 @@ void M_ScanSaves (void)
        {
                strcpy (m_filenames[i], "--- UNUSED SLOT ---");
                loadable[i] = false;
-               sprintf (name, "s%i.sav", i);
+               sprintf (name, "s%i.sav", (int)i);
                f = FS_Open (name, "rb", false, false);
                if (!f)
                        continue;
@@ -1449,7 +1449,7 @@ forward:
                        break;
                if (setup_cursor == 0)
                {
-                       l = strlen(setup_myname);
+                       l = (int)strlen(setup_myname);
                        if (l < 15)
                        {
                                setup_myname[l+1] = 0;
@@ -1622,7 +1622,7 @@ void M_Options_PrintCheckbox(char *s, int enabled, int yes)
        {
                DrawQ_Fill(menu_x, menu_y + opty, 320, 8, optnum == optcursor ? (0.5 + 0.2 * sin(realtime * M_PI)) : 0, 0, 0, 0.5, 0);
                M_ItemPrint(0, opty, s, enabled);
-               M_DrawCheckbox(0 + strlen(s) * 8 + 8, opty, yes);
+               M_DrawCheckbox(0 + (int)strlen(s) * 8 + 8, opty, yes);
        }
        opty += 8;
        optnum++;
@@ -1634,7 +1634,7 @@ void M_Options_PrintSlider(char *s, int enabled, float value, float minvalue, fl
        {
                DrawQ_Fill(menu_x, menu_y + opty, 320, 8, optnum == optcursor ? (0.5 + 0.2 * sin(realtime * M_PI)) : 0, 0, 0, 0.5, 0);
                M_ItemPrint(0, opty, s, enabled);
-               M_DrawSlider(0 + strlen(s) * 8 + 8, opty, value, minvalue, maxvalue);
+               M_DrawSlider(0 + (int)strlen(s) * 8 + 8, opty, value, minvalue, maxvalue);
        }
        opty += 8;
        optnum++;
@@ -3090,7 +3090,7 @@ void M_Quit_Draw (void)
        int i, l, linelength, firstline, lastline, lines;
        for (i = 0, linelength = 0, firstline = 9999, lastline = -1;m_quit_message[i];i++)
        {
-               if ((l = strlen(m_quit_message[i])))
+               if ((l = (int)strlen(m_quit_message[i])))
                {
                        if (firstline > i)
                                firstline = i;
@@ -3258,7 +3258,7 @@ void M_LanConfig_Key (int key, char ascii)
 
                if (lanConfig_cursor == 2)
                {
-                       l = strlen(lanConfig_joinname);
+                       l = (int)strlen(lanConfig_joinname);
                        if (l < 21)
                        {
                                lanConfig_joinname[l+1] = 0;
@@ -3270,7 +3270,7 @@ void M_LanConfig_Key (int key, char ascii)
                        break;
                if (lanConfig_cursor == 0)
                {
-                       l = strlen(lanConfig_portname);
+                       l = (int)strlen(lanConfig_portname);
                        if (l < 5)
                        {
                                lanConfig_portname[l+1] = 0;
@@ -4115,7 +4115,7 @@ void M_GameOptions_Key (int key, char ascii)
        case K_BACKSPACE:
                if (gameoptions_cursor == 9)
                {
-                       l = strlen(hostname.string);
+                       l = (int)strlen(hostname.string);
                        if (l)
                        {
                                l = min(l - 1, 37);
@@ -4131,7 +4131,7 @@ void M_GameOptions_Key (int key, char ascii)
                        break;
                if (gameoptions_cursor == 9)
                {
-                       l = strlen(hostname.string);
+                       l = (int)strlen(hostname.string);
                        if (l < 37)
                        {
                                memcpy(hostnamebuf, hostname.string, l);
index c914d0c2a179635a3340d44b0d9ea69fed313719..9c6d50be14057ea19854417e54c79f6b62385961 100755 (executable)
--- a/netconn.c
+++ b/netconn.c
@@ -428,7 +428,7 @@ int NetConn_Write(lhnetsocket_t *mysocket, const void *data, int length, const l
 int NetConn_WriteString(lhnetsocket_t *mysocket, const char *string, const lhnetaddress_t *peeraddress)
 {
        // note this does not include the trailing NULL because we add that in the parser
-       return NetConn_Write(mysocket, string, strlen(string), peeraddress);
+       return NetConn_Write(mysocket, string, (int)strlen(string), peeraddress);
 }
 
 int NetConn_SendReliableMessage(netconn_t *conn, sizebuf_t *data)
@@ -681,7 +681,7 @@ void NetConn_OpenServerPort(const char *addressstring, int defaultport)
                                Con_Printf("Server failed to open socket on address %s\n", addressstring2);
                        }
                }
-               else 
+               else
                {
                        Con_Printf("Server unable to parse address %s\n", addressstring);
                        // if it cant parse one address, it wont be able to parse another for sure
@@ -1399,7 +1399,7 @@ static qboolean NetConn_BuildStatusResponse(const char* challenge, char* out_msg
                int left;
 
                ptr = out_msg + length;
-               left = out_size - length;
+               left = (int)out_size - length;
 
                for (i = 0;i < (unsigned int)svs.maxclients;i++)
                {
index d86b0b648b985e331173b4e4fd1165fedf73e7ae..c977d7ab6b05e097fef515c757ebb4f7f54a8d86 100644 (file)
--- a/progsvm.h
+++ b/progsvm.h
@@ -489,7 +489,7 @@ void PRVM_ED_PrintNum (int ent);
 
 const char *PRVM_GetString(int num);
 int PRVM_SetEngineString(const char *s);
-int PRVM_AllocString(int bufferlength, char **pointer);
+int PRVM_AllocString(size_t bufferlength, char **pointer);
 void PRVM_FreeString(int num);
 
 //============================================================================
index 8e07db729d6cc20b8c113c7995d5b6957a6b1c81..c2d32dbef80d5b1efd13a90af4850bfba1d9eced 100644 (file)
@@ -74,7 +74,7 @@ checkextension(extensionname)
 // kind of helper function
 static qboolean checkextension(const char *name)
 {
-       int len;
+       size_t len;
        char *e, *start;
        len = strlen(name);
 
@@ -545,7 +545,7 @@ VM_cvar_defstring
 const string   VM_cvar_defstring (string)
 ========================
 */
-void VM_cvar_defstring (void) 
+void VM_cvar_defstring (void)
 {
        char *out;
        const char *name;
@@ -1680,7 +1680,7 @@ fputs(float fhandle, string s)
 //void(float fhandle, string s) fputs = #113; // writes a line of text to the end of the file
 void VM_fputs(void)
 {
-       int stringlength;
+       size_t stringlength;
        char string[VM_STRINGTEMP_LENGTH];
        int filenum;
 
@@ -1873,7 +1873,7 @@ int num_tokens = 0;
 char *tokens[256], tokenbuf[4096];
 void VM_tokenize (void)
 {
-       int pos;
+       size_t pos;
        const char *p;
 
        VM_SAFEPARMCOUNT(1,VM_tokenize);
index c5b6f5edc6c90b6a7dc71890528cc4a95f0b4eab..e365238744ff07089e00e19a0ae2ea66094e9fd1 100644 (file)
@@ -499,7 +499,7 @@ padded to 20 field width
 char *PRVM_GlobalString (int ofs)
 {
        char    *s;
-       int             i;
+       size_t  i;
        ddef_t  *def;
        void    *val;
        static char     line[128];
@@ -524,7 +524,7 @@ char *PRVM_GlobalString (int ofs)
 
 char *PRVM_GlobalStringNoContents (int ofs)
 {
-       int             i;
+       size_t  i;
        ddef_t  *def;
        static char     line[128];
 
@@ -554,7 +554,7 @@ For debugging
 // LordHavoc: changed to print out every 4096 characters (incase there are a lot of fields to print)
 void PRVM_ED_Print(prvm_edict_t *ed)
 {
-       int             l;
+       size_t  l;
        ddef_t  *d;
        int             *v;
        int             i, j;
@@ -870,7 +870,7 @@ returns false if error
 */
 qboolean PRVM_ED_ParseEpair(prvm_edict_t *ent, ddef_t *key, const char *s)
 {
-       int i, l;
+       size_t i, l;
        char *new_p;
        ddef_t *def;
        prvm_eval_t *val;
@@ -926,9 +926,9 @@ qboolean PRVM_ED_ParseEpair(prvm_edict_t *ent, ddef_t *key, const char *s)
        case ev_entity:
                while (*s && *s <= ' ')
                        s++;
-               i = atoi(s);
-               if (i < 0 || i >= prog->limit_edicts)
-                       Con_Printf("PRVM_ED_ParseEpair: ev_entity reference too large (edict %i >= MAX_EDICTS %i) on %s\n", i, MAX_EDICTS, PRVM_NAME);
+               i = (unsigned int)atoi(s);
+               if (i >= prog->limit_edicts)
+                       Con_Printf("PRVM_ED_ParseEpair: ev_entity reference too large (edict %u >= MAX_EDICTS %u) on %s\n", (unsigned int)i, (unsigned int)MAX_EDICTS, PRVM_NAME);
                while (i >= prog->max_edicts)
                        PRVM_MEM_IncreaseEdicts();
                        //SV_IncreaseEdicts();
@@ -1015,7 +1015,7 @@ const char *PRVM_ED_ParseEdict (const char *data, prvm_edict_t *ent)
        qboolean anglehack;
        qboolean init;
        char keyname[256];
-       int n;
+       size_t n;
 
        init = false;
 
@@ -1308,7 +1308,7 @@ void PRVM_LoadProgs (const char * filename, int numrequiredfunc, char **required
        {
                if (prog->progs->ofs_strings + prog->stringssize >= fs_filesize)
                        PRVM_ERROR ("%s: %s strings go past end of file\n", PRVM_NAME, filename);
-               prog->stringssize += strlen (prog->strings + prog->stringssize) + 1;
+               prog->stringssize += (int)strlen (prog->strings + prog->stringssize) + 1;
        }
        prog->numknownstrings = 0;
        prog->maxknownstrings = 0;
@@ -1626,7 +1626,7 @@ void PRVM_Fields_f (void)
                        name = tempstring2;
                }
                strcat(tempstring, name);
-               for (j = strlen(name);j < 25;j++)
+               for (j = (int)strlen(name);j < 25;j++)
                        strcat(tempstring, " ");
                sprintf(tempstring2, "%5d", counts[i]);
                strcat(tempstring, tempstring2);
@@ -1898,7 +1898,7 @@ int PRVM_SetEngineString(const char *s)
        return -1 - i;
 }
 
-int PRVM_AllocString(int bufferlength, char **pointer)
+int PRVM_AllocString(size_t bufferlength, char **pointer)
 {
        int i;
        if (!bufferlength)
index 7b0c0a5e3bfe78bfcabe1508f9e4c4d89a399b42..5160fad8f9a3b13deaf9561c397163b49c36c6e9 100644 (file)
@@ -123,8 +123,8 @@ PRVM_PrintStatement
 */
 void PRVM_PrintStatement (dstatement_t *s)
 {
-       int             i;
-       
+       size_t i;
+
        if( prog->statement_linenums ) {
                int opnum;
 
index fe2e6af389819823b8006e676ebfdd3285a28405..b37dd00f14f691ba1d2fcfb2940d82bfdb990256 100644 (file)
@@ -3363,7 +3363,7 @@ void R_Shadow_LoadWorldLights(void)
 void R_Shadow_SaveWorldLights(void)
 {
        dlight_t *light;
-       int bufchars, bufmaxchars;
+       size_t bufchars, bufmaxchars;
        char *buf, *oldbuf;
        char name[MAX_QPATH];
        char line[1024];
diff --git a/sbar.c b/sbar.c
index 7db9e4058c5bd3597d334cf5af8da0a6effed031..53fd9136e600921c2b07b0ca4deec2b9bf58f7ae 100644 (file)
--- a/sbar.c
+++ b/sbar.c
@@ -504,10 +504,10 @@ void Sbar_SoloScoreboard (void)
 
 // draw level name
        if (gamemode == GAME_NEXUIZ) {
-               l = strlen (cl.worldmodel->name);
+               l = (int) strlen (cl.worldmodel->name);
                Sbar_DrawString (232 - l*4, 12, cl.worldmodel->name);
        } else {
-               l = strlen (cl.levelname);
+               l = (int) strlen (cl.levelname);
                Sbar_DrawString (232 - l*4, 12, cl.levelname);
        }
 }
@@ -1179,7 +1179,7 @@ float Sbar_PrintScoreboardItem(scoreboard_t *s, float x, float y)
        // print the text
        //DrawQ_String(x, y, va("%c%4i %s", (s - cl.scores) == cl.playerentity - 1 ? 13 : ' ', (int) s->frags, s->name), 0, 8, 8, 1, 1, 1, 1 * sbar_alpha_fg.value, 0);
        // FIXME: use a constant for this color tag instead
-       DrawQ_ColoredString(x, y, va("%c%4i %s" STRING_COLOR_DEFAULT_STR, (s - cl.scores) == cl.playerentity - 1 ? 13 : ' ', (int) s->frags, s->name), 0, 8, 8, 1, 1, 1, 1 * sbar_alpha_fg.value, 0, NULL ); 
+       DrawQ_ColoredString(x, y, va("%c%4i %s" STRING_COLOR_DEFAULT_STR, (s - cl.scores) == cl.playerentity - 1 ? 13 : ' ', (int) s->frags, s->name), 0, 8, 8, 1, 1, 1, 1 * sbar_alpha_fg.value, 0, NULL );
        return 8;
 }
 
index 2315f7c9fc22aeeb83efaeecfea6d27ff827a490..76614bfad0ab89b9d85db27b11418b366cded533 100644 (file)
--- a/snd_mix.c
+++ b/snd_mix.c
@@ -277,7 +277,7 @@ void S_PaintChannels(int endtime)
 
                                // paint up to end
                                if (ch->end < end)
-                                       count = ch->end - ltime;
+                                       count = (int)ch->end - ltime;
                                else
                                        count = end - ltime;