From 11e05215e5f3cee630f54b9836dab1b36b5b4ffc Mon Sep 17 00:00:00 2001 From: havoc Date: Tue, 5 Jul 2005 10:49:06 +0000 Subject: [PATCH] more size_t git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@5497 d7cf8633-e32d-0410-b094-e92efae38249 --- cgame.c | 2 +- cl_demo.c | 2 +- cl_main.c | 2 +- cl_parse.c | 2 +- cl_screen.c | 12 ++++++------ cmd.c | 31 ++++++++++++++++--------------- common.c | 6 +++--- common.h | 2 +- console.c | 12 ++++++------ cvar.c | 15 ++++++++------- fs.c | 42 +++++++++++++++++++++--------------------- fs.h | 4 ++-- gl_rmain.c | 2 +- host_cmd.c | 4 ++-- keys.c | 12 ++++++------ menu.c | 20 ++++++++++---------- netconn.c | 6 +++--- progsvm.h | 2 +- prvm_cmds.c | 8 ++++---- prvm_edict.c | 22 +++++++++++----------- prvm_exec.c | 4 ++-- r_shadow.c | 2 +- sbar.c | 6 +++--- snd_mix.c | 2 +- 24 files changed, 112 insertions(+), 110 deletions(-) diff --git a/cgame.c b/cgame.c index 86da9a53..ad162bc1 100644 --- 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)); diff --git a/cl_demo.c b/cl_demo.c index cdf8209c..865a1b36 100644 --- 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); } diff --git a/cl_main.c b/cl_main.c index d638d185..632e1850 100644 --- 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); } diff --git a/cl_parse.c b/cl_parse.c index 6cfe6acf..20e9e70a 100644 --- a/cl_parse.c +++ b/cl_parse.c @@ -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: diff --git a/cl_screen.c b/cl_screen.c index 5519df6e..c11c4966 100644 --- a/cl_screen.c +++ b/cl_screen.c @@ -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 0a645974..41c38794 100644 --- 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); } /* diff --git a/common.c b/common.c index bfdb26ee..a8d0a9f4 100644 --- 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 > ' ') diff --git a/common.h b/common.h index 210b8af8..cceb571a 100644 --- 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); //============================================================================ diff --git a/console.c b/console.c index 148c0571..3cb08835 100644 --- 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 8236ae84..5df43cc2 100644 --- 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 ce6ec632..bfab7a8b 100644 --- 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 878d121c..7e9192a5 100644 --- 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 diff --git a/gl_rmain.c b/gl_rmain.c index 2302d2ab..276a6455 100644 --- a/gl_rmain.c +++ b/gl_rmain.c @@ -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"); diff --git a/host_cmd.c b/host_cmd.c index 7a533d9b..3a62b1df 100644 --- a/host_cmd.c +++ b/host_cmd.c @@ -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 5b1aad5f..4be917f3 100644 --- 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 f1a13552..a3b37a62 100644 --- 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); diff --git a/netconn.c b/netconn.c index c914d0c2..9c6d50be 100755 --- 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++) { diff --git a/progsvm.h b/progsvm.h index d86b0b64..c977d7ab 100644 --- 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); //============================================================================ diff --git a/prvm_cmds.c b/prvm_cmds.c index 8e07db72..c2d32dbe 100644 --- a/prvm_cmds.c +++ b/prvm_cmds.c @@ -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); diff --git a/prvm_edict.c b/prvm_edict.c index c5b6f5ed..e3652387 100644 --- a/prvm_edict.c +++ b/prvm_edict.c @@ -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) diff --git a/prvm_exec.c b/prvm_exec.c index 7b0c0a5e..5160fad8 100644 --- a/prvm_exec.c +++ b/prvm_exec.c @@ -123,8 +123,8 @@ PRVM_PrintStatement */ void PRVM_PrintStatement (dstatement_t *s) { - int i; - + size_t i; + if( prog->statement_linenums ) { int opnum; diff --git a/r_shadow.c b/r_shadow.c index fe2e6af3..b37dd00f 100644 --- a/r_shadow.c +++ b/r_shadow.c @@ -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 7db9e405..53fd9136 100644 --- 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; } diff --git a/snd_mix.c b/snd_mix.c index 2315f7c9..76614bfa 100644 --- 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; -- 2.39.2