From d090340b054029faddb432e2c66085e6e91abcf7 Mon Sep 17 00:00:00 2001 From: havoc Date: Thu, 29 May 2014 20:01:57 +0000 Subject: [PATCH] Fixed a large number of WIN64 type conversion warnings. Changed FS_Write to do multiple write calls if the size exceeds 1GB, this is to accommodate WIN64 where write() takes a UINT rather than size_t. We have no use of such large writes at this time, so this is a mostly theoretical feature. git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@12081 d7cf8633-e32d-0410-b094-e92efae38249 --- cap_avi.c | 2 +- cap_ogg.c | 4 ++-- cl_main.c | 2 +- cl_parse.c | 2 +- cl_screen.c | 2 +- cmd.c | 6 +++--- common.c | 2 +- console.c | 26 +++++++++++------------ crypto.c | 26 +++++++++++------------ csprogs.c | 4 ++-- dpsoftrast.c | 8 ++++---- fs.c | 29 ++++++++++++++++++-------- ft2.h | 4 ++++ gl_backend.c | 26 +++++++++++------------ gl_rmain.c | 22 ++++++++++---------- gl_textures.c | 4 ++-- glquake.h | 2 +- host_cmd.c | 8 ++++---- jpeg.c | 4 ++-- keys.c | 32 ++++++++++++++--------------- libcurl.c | 2 +- menu.c | 2 +- model_brush.c | 26 +++++++++++------------ model_shared.c | 26 +++++++++++------------ model_shared.h | 4 ++-- netconn.c | 56 +++++++++++++++++++++++++------------------------- prvm_cmds.c | 28 ++++++++++++------------- r_shadow.c | 16 +++++++-------- snd_main.c | 2 +- snd_mem.c | 4 ++-- sv_user.c | 2 +- svvm_cmds.c | 4 ++-- sys_linux.c | 2 +- sys_sdl.c | 2 +- utf8lib.c | 14 ++++++------- vid_sdl.c | 7 ++++++- 36 files changed, 216 insertions(+), 196 deletions(-) diff --git a/cap_avi.c b/cap_avi.c index 9a238e80..fff2f7a5 100644 --- a/cap_avi.c +++ b/cap_avi.c @@ -473,7 +473,7 @@ static void SCR_CaptureVideo_Avi_SoundFrame(const portable_sampleframe_t *paintb out_ptr[3] = (unsigned char)(n1 >> 8); } - x = length*4; + x = (int)length*4; if(format->canseek) { SCR_CaptureVideo_RIFF_OverflowCheck(8 + x); diff --git a/cap_ogg.c b/cap_ogg.c index a4913aeb..e9abc7ae 100644 --- a/cap_ogg.c +++ b/cap_ogg.c @@ -914,14 +914,14 @@ static void SCR_CaptureVideo_Ogg_SoundFrame(const portable_sampleframe_t *paintb ogg_packet pt; int *map = mapping[bound(1, cls.capturevideo.soundchannels, 8) - 1]; - vorbis_buffer = qvorbis_analysis_buffer(&format->vd, length); + vorbis_buffer = qvorbis_analysis_buffer(&format->vd, (int)length); for(j = 0; j < cls.capturevideo.soundchannels; ++j) { float *b = vorbis_buffer[map[j]]; for(i = 0; i < length; ++i) b[i] = paintbuffer[i].sample[j]; } - qvorbis_analysis_wrote(&format->vd, length); + qvorbis_analysis_wrote(&format->vd, (int)length); while(qvorbis_analysis_blockout(&format->vd, &format->vb) == 1) { diff --git a/cl_main.c b/cl_main.c index 9ae5e69c..2ae4f860 100644 --- a/cl_main.c +++ b/cl_main.c @@ -2109,7 +2109,7 @@ static void CL_Locs_AddNode(vec3_t mins, vec3_t maxs, const char *name) int namelen; if (!name) name = ""; - namelen = strlen(name); + namelen = (int)strlen(name); node = (cl_locnode_t *) Mem_Alloc(cls.levelmempool, sizeof(cl_locnode_t) + namelen + 1); VectorSet(node->mins, min(mins[0], maxs[0]), min(mins[1], maxs[1]), min(mins[2], maxs[2])); VectorSet(node->maxs, max(mins[0], maxs[0]), max(mins[1], maxs[1]), max(mins[2], maxs[2])); diff --git a/cl_parse.c b/cl_parse.c index 48de06e7..f7e77a3b 100644 --- a/cl_parse.c +++ b/cl_parse.c @@ -1377,7 +1377,7 @@ static void CL_StopDownload(int size, int crc) { Con_Printf("Inflated download: new size: %u (%g%%)\n", (unsigned)inflated_size, 100.0 - 100.0*(cls.qw_downloadmemorycursize / (float)inflated_size)); cls.qw_downloadmemory = out; - cls.qw_downloadmemorycursize = inflated_size; + cls.qw_downloadmemorycursize = (int)inflated_size; } else { diff --git a/cl_screen.c b/cl_screen.c index 17ad5a7f..7e15123c 100644 --- a/cl_screen.c +++ b/cl_screen.c @@ -1776,7 +1776,7 @@ static void SCR_CaptureVideo_VideoFrame(int newframestepframenum) void SCR_CaptureVideo_SoundFrame(const portable_sampleframe_t *paintbuffer, size_t length) { - cls.capturevideo.soundsampleframe += length; + cls.capturevideo.soundsampleframe += (int)length; cls.capturevideo.soundframe(paintbuffer, length); } diff --git a/cmd.c b/cmd.c index ba6aec5b..1e2b915a 100644 --- a/cmd.c +++ b/cmd.c @@ -142,7 +142,7 @@ static void Cmd_Centerprint_f (void) strlcat(msg, " ", sizeof(msg)); strlcat(msg, Cmd_Argv(i), sizeof(msg)); } - c = strlen(msg); + c = (unsigned int)strlen(msg); for(p = 0, i = 0; i < c; ++i) { if(msg[i] == '\\') @@ -219,7 +219,7 @@ void Cbuf_InsertText (const char *text) { // we don't have a SZ_Prepend, so... memmove(cmd_text.data + l, cmd_text.data, cmd_text.cursize); - cmd_text.cursize += l; + cmd_text.cursize += (int)l; memcpy(cmd_text.data, text, l); } Cbuf_UnlockThreadMutex(); @@ -2106,7 +2106,7 @@ void Cmd_ForwardStringToServer (const char *s) break; } // write the resulting text - SZ_Write(&cls.netcon->message, (unsigned char *)temp, strlen(temp)); + SZ_Write(&cls.netcon->message, (unsigned char *)temp, (int)strlen(temp)); s += 2; continue; } diff --git a/common.c b/common.c index 47edc4c9..b36dae52 100644 --- a/common.c +++ b/common.c @@ -2287,7 +2287,7 @@ size_t base64_encode(unsigned char *buf, size_t buflen, size_t outbuflen) for(i = blocks; i > 0; ) { --i; - base64_3to4(buf + 3*i, buf + 4*i, buflen - 3*i); + base64_3to4(buf + 3*i, buf + 4*i, (int)(buflen - 3*i)); } return blocks * 4; } diff --git a/console.c b/console.c index 1bf3790a..8dde83d9 100644 --- a/console.c +++ b/console.c @@ -714,7 +714,7 @@ static void Con_MessageMode_f (void) if(Cmd_Argc() > 1) { dpsnprintf(chat_buffer, sizeof(chat_buffer), "%s ", Cmd_Args()); - chat_bufferlen = strlen(chat_buffer); + chat_bufferlen = (unsigned int)strlen(chat_buffer); } } @@ -731,7 +731,7 @@ static void Con_MessageMode2_f (void) if(Cmd_Argc() > 1) { dpsnprintf(chat_buffer, sizeof(chat_buffer), "%s ", Cmd_Args()); - chat_bufferlen = strlen(chat_buffer); + chat_bufferlen = (unsigned int)strlen(chat_buffer); } } @@ -746,7 +746,7 @@ static void Con_CommandMode_f (void) if(Cmd_Argc() > 1) { dpsnprintf(chat_buffer, sizeof(chat_buffer), "%s ", Cmd_Args()); - chat_bufferlen = strlen(chat_buffer); + chat_bufferlen = (unsigned int)strlen(chat_buffer); } chat_mode = -1; // command } @@ -983,7 +983,7 @@ void Con_Rcon_Redirect_Init(lhnetsocket_t *sock, lhnetaddress_t *dest, qboolean rcon_redirect_buffer[2] = 0; rcon_redirect_buffer[3] = 0; // this is a reply to a CCREQ_RCON - rcon_redirect_buffer[4] = (char)CCREP_RCON; + rcon_redirect_buffer[4] = (unsigned char)CCREP_RCON; } else memcpy(rcon_redirect_buffer, "\377\377\377\377n", 5); // QW rcon print @@ -1543,7 +1543,7 @@ static void Con_DrawInput (void) text[key_linepos] = 11 + 130 * key_insert; // either solid or triangle facing right else if (y + 3 < (int)sizeof(editlinecopy)-1) { - int ofs = u8_bytelen(text + key_linepos, 1); + int ofs = (int)u8_bytelen(text + key_linepos, 1); size_t len; const char *curbuf; char charbuf16[16]; @@ -2458,10 +2458,10 @@ static void Nicks_CutMatchesNormal(int count) // cut match 0 down to the longest possible completion int i; unsigned int c, l; - c = strlen(Nicks_sanlist[0]) - 1; + c = (unsigned int)strlen(Nicks_sanlist[0]) - 1; for(i = 1; i < count; ++i) { - l = strlen(Nicks_sanlist[i]) - 1; + l = (unsigned int)strlen(Nicks_sanlist[i]) - 1; if(l < c) c = l; @@ -2500,7 +2500,7 @@ static void Nicks_CutMatchesAlphaNumeric(int count) char *a, *b; char space_char = (con_nickcompletion_flags.integer & NICKS_NO_SPACES) ? 'a' : ' '; // yes this is correct, we want NO spaces when no spaces - c = strlen(Nicks_sanlist[0]); + c = (unsigned int)strlen(Nicks_sanlist[0]); for(i = 0, l = 0; i < (int)c; ++i) { if( (Nicks_sanlist[0][i] >= 'a' && Nicks_sanlist[0][i] <= 'z') || @@ -2558,7 +2558,7 @@ static void Nicks_CutMatchesNoSpaces(int count) char tempstr[sizeof(Nicks_sanlist[0])]; char *a, *b; - c = strlen(Nicks_sanlist[0]); + c = (unsigned int)strlen(Nicks_sanlist[0]); for(i = 0, l = 0; i < (int)c; ++i) { if(Nicks_sanlist[0][i] != ' ') // here it's what's NOT copied @@ -2713,10 +2713,10 @@ int Nicks_CompleteChatLine(char *buffer, size_t size, unsigned int pos) len = min(size - Nicks_matchpos - 3, strlen(msg)); memcpy(&buffer[Nicks_matchpos], msg, len); if( len < (size - 7) ) // space for color (^[0-9] or ^xrgb) and space and \0 - len = Nicks_AddLastColor(buffer, Nicks_matchpos+len); + len = (int)Nicks_AddLastColor(buffer, Nicks_matchpos+(int)len); buffer[len++] = ' '; buffer[len] = 0; - return len; + return (int)len; } else if(n > 1) { int len; @@ -2727,7 +2727,7 @@ int Nicks_CompleteChatLine(char *buffer, size_t size, unsigned int pos) Nicks_CutMatches(n); msg = Nicks_sanlist[0]; - len = min(size - Nicks_matchpos, strlen(msg)); + len = (int)min(size - Nicks_matchpos, strlen(msg)); memcpy(&buffer[Nicks_matchpos], msg, len); buffer[Nicks_matchpos + len] = 0; //pos += len; @@ -3021,7 +3021,7 @@ done: if(n) { // was a nick, might have an offset, and needs colors ;) --blub key_linepos = pos - Nicks_offset[0]; - cmd_len = strlen(Nicks_list[0]); + cmd_len = (int)strlen(Nicks_list[0]); cmd_len = min(cmd_len, (int)sizeof(key_line) - 3 - pos); memcpy(&key_line[key_linepos] , Nicks_list[0], cmd_len); diff --git a/crypto.c b/crypto.c index b9f21454..016ff9b6 100644 --- a/crypto.c +++ b/crypto.c @@ -90,7 +90,7 @@ static size_t Crypto_UnParsePack(char *buf, size_t len, unsigned long header, co { if(pos + 4 + lumpsize[i] > len) return 0; - Crypto_UnLittleLong(&buf[pos], lumpsize[i]); + Crypto_UnLittleLong(&buf[pos], (unsigned long)lumpsize[i]); pos += 4; memcpy(&buf[pos], lumps[i], lumpsize[i]); pos += lumpsize[i]; @@ -1083,7 +1083,7 @@ static void Crypto_KeyGen_Finished(int code, size_t length_received, unsigned ch if(keygen_i < 0) { Con_Printf("Unexpected response from keygen server:\n"); - Com_HexDumpToConsole(buffer, length_received); + Com_HexDumpToConsole(buffer, (int)length_received); SV_UnlockThreadMutex(); return; } @@ -1096,7 +1096,7 @@ static void Crypto_KeyGen_Finished(int code, size_t length_received, unsigned ch else { Con_Printf("Invalid response from keygen server:\n"); - Com_HexDumpToConsole(buffer, length_received); + Com_HexDumpToConsole(buffer, (int)length_received); } keygen_i = -1; SV_UnlockThreadMutex(); @@ -1485,15 +1485,15 @@ const void *Crypto_EncryptPacket(crypto_t *crypto, const void *data_src, size_t if(developer_networking.integer) { Con_Print("To be encrypted:\n"); - Com_HexDumpToConsole((const unsigned char *) data_src, len_src); + Com_HexDumpToConsole((const unsigned char *) data_src, (int)len_src); } - if(len_src + 32 > len || !HMAC_SHA256_32BYTES(h, (const unsigned char *) data_src, len_src, crypto->dhkey, DHKEY_SIZE)) + if(len_src + 32 > len || !HMAC_SHA256_32BYTES(h, (const unsigned char *) data_src, (int)len_src, crypto->dhkey, DHKEY_SIZE)) { Con_Printf("Crypto_EncryptPacket failed (not enough space: %d bytes in, %d bytes out)\n", (int) len_src, (int) len); return NULL; } *len_dst = ((len_src + 15) / 16) * 16 + 16; // add 16 for HMAC, then round to 16-size for AES - ((unsigned char *) data_dst)[0] = *len_dst - len_src; + ((unsigned char *) data_dst)[0] = (unsigned char)(*len_dst - len_src); memcpy(((unsigned char *) data_dst)+1, h, 15); aescpy(crypto->dhkey, (const unsigned char *) data_dst, ((unsigned char *) data_dst) + 16, (const unsigned char *) data_src, len_src); // IV dst src len @@ -1501,7 +1501,7 @@ const void *Crypto_EncryptPacket(crypto_t *crypto, const void *data_src, size_t else { // HMAC packet = 16 bytes HMAC-SHA-256 (truncated to 128 bits), data - if(len_src + 16 > len || !HMAC_SHA256_32BYTES(h, (const unsigned char *) data_src, len_src, crypto->dhkey, DHKEY_SIZE)) + if(len_src + 16 > len || !HMAC_SHA256_32BYTES(h, (const unsigned char *) data_src, (int)len_src, crypto->dhkey, DHKEY_SIZE)) { Con_Printf("Crypto_EncryptPacket failed (not enough space: %d bytes in, %d bytes out)\n", (int) len_src, (int) len); return NULL; @@ -1559,7 +1559,7 @@ const void *Crypto_DecryptPacket(crypto_t *crypto, const void *data_src, size_t } seacpy(crypto->dhkey, (unsigned char *) data_src, (unsigned char *) data_dst, ((const unsigned char *) data_src) + 16, *len_dst); // IV dst src len - if(!HMAC_SHA256_32BYTES(h, (const unsigned char *) data_dst, *len_dst, crypto->dhkey, DHKEY_SIZE)) + if(!HMAC_SHA256_32BYTES(h, (const unsigned char *) data_dst, (int)*len_dst, crypto->dhkey, DHKEY_SIZE)) { Con_Printf("HMAC fail\n"); return NULL; @@ -1572,7 +1572,7 @@ const void *Crypto_DecryptPacket(crypto_t *crypto, const void *data_src, size_t if(developer_networking.integer) { Con_Print("Decrypted:\n"); - Com_HexDumpToConsole((const unsigned char *) data_dst, *len_dst); + Com_HexDumpToConsole((const unsigned char *) data_dst, (int)*len_dst); } return data_dst; // no need to copy } @@ -1590,10 +1590,10 @@ const void *Crypto_DecryptPacket(crypto_t *crypto, const void *data_src, size_t return NULL; } //memcpy(data_dst, data_src + 16, *len_dst); - if(!HMAC_SHA256_32BYTES(h, ((const unsigned char *) data_src) + 16, *len_dst, crypto->dhkey, DHKEY_SIZE)) + if(!HMAC_SHA256_32BYTES(h, ((const unsigned char *) data_src) + 16, (int)*len_dst, crypto->dhkey, DHKEY_SIZE)) { Con_Printf("HMAC fail\n"); - Com_HexDumpToConsole((const unsigned char *) data_src, len_src); + Com_HexDumpToConsole((const unsigned char *) data_src, (int)len_src); return NULL; } @@ -1611,14 +1611,14 @@ const void *Crypto_DecryptPacket(crypto_t *crypto, const void *data_src, size_t if(memcmp((const unsigned char *) data_src, h, 16)) // ignore first byte, used for length { Con_Printf("HMAC mismatch\n"); - Com_HexDumpToConsole((const unsigned char *) data_src, len_src); + Com_HexDumpToConsole((const unsigned char *) data_src, (int)len_src); return NULL; } } else { Con_Printf("HMAC mismatch\n"); - Com_HexDumpToConsole((const unsigned char *) data_src, len_src); + Com_HexDumpToConsole((const unsigned char *) data_src, (int)len_src); return NULL; } } diff --git a/csprogs.c b/csprogs.c index e9295bce..77b0daeb 100644 --- a/csprogs.c +++ b/csprogs.c @@ -942,7 +942,7 @@ static qboolean CLVM_load_edict(prvm_prog_t *prog, prvm_edict_t *ent) qboolean MakeDownloadPacket(const char *filename, unsigned char *data, size_t len, int crc, int cnt, sizebuf_t *buf, int protocol) { int packetsize = buf->maxsize - 7; // byte short long - int npackets = (len + packetsize - 1) / (packetsize); + int npackets = ((int)len + packetsize - 1) / (packetsize); char vabuf[1024]; if(protocol == PROTOCOL_QUAKEWORLD) @@ -958,7 +958,7 @@ qboolean MakeDownloadPacket(const char *filename, unsigned char *data, size_t le else if(cnt >= 1 && cnt <= npackets) { unsigned long thispacketoffset = (cnt - 1) * packetsize; - int thispacketsize = len - thispacketoffset; + int thispacketsize = (int)len - thispacketoffset; if(thispacketsize > packetsize) thispacketsize = packetsize; diff --git a/dpsoftrast.c b/dpsoftrast.c index 039e7fc5..6a75be2e 100644 --- a/dpsoftrast.c +++ b/dpsoftrast.c @@ -1318,25 +1318,25 @@ void DPSOFTRAST_SetTexture(int unitnum, int index) void DPSOFTRAST_SetVertexPointer(const float *vertex3f, size_t stride) { dpsoftrast.pointer_vertex3f = vertex3f; - dpsoftrast.stride_vertex = stride; + dpsoftrast.stride_vertex = (int)stride; } void DPSOFTRAST_SetColorPointer(const float *color4f, size_t stride) { dpsoftrast.pointer_color4f = color4f; dpsoftrast.pointer_color4ub = NULL; - dpsoftrast.stride_color = stride; + dpsoftrast.stride_color = (int)stride; } void DPSOFTRAST_SetColorPointer4ub(const unsigned char *color4ub, size_t stride) { dpsoftrast.pointer_color4f = NULL; dpsoftrast.pointer_color4ub = color4ub; - dpsoftrast.stride_color = stride; + dpsoftrast.stride_color = (int)stride; } void DPSOFTRAST_SetTexCoordPointer(int unitnum, int numcomponents, size_t stride, const float *texcoordf) { dpsoftrast.pointer_texcoordf[unitnum] = texcoordf; dpsoftrast.components_texcoord[unitnum] = numcomponents; - dpsoftrast.stride_texcoord[unitnum] = stride; + dpsoftrast.stride_texcoord[unitnum] = (int)stride; } DEFCOMMAND(18, SetShader, int mode; int permutation; int exactspecularmath;) diff --git a/fs.c b/fs.c index 45406637..e5cc4709 100644 --- a/fs.c +++ b/fs.c @@ -2706,7 +2706,7 @@ Write "datasize" bytes into a file */ fs_offset_t FS_Write (qfile_t* file, const void* data, size_t datasize) { - fs_offset_t result; + fs_offset_t written = 0; // If necessary, seek to the exact file position we're supposed to be if (file->buff_ind != file->buff_len) @@ -2716,15 +2716,26 @@ fs_offset_t FS_Write (qfile_t* file, const void* data, size_t datasize) FS_Purge (file); // Write the buffer and update the position - result = write (file->handle, data, (fs_offset_t)datasize); + // LordHavoc: to hush a warning about passing size_t to an unsigned int parameter on Win64 we do this as multiple writes if the size would be too big for an integer (we never write that big in one go, but it's a theory) + while (written < (fs_offset_t)datasize) + { + // figure out how much to write in one chunk + fs_offset_t maxchunk = 1<<30; // 1 GiB + int chunk = (int)min((fs_offset_t)datasize - written, maxchunk); + int result = (int)write (file->handle, (const unsigned char *)data + written, chunk); + // if at least some was written, add it to our accumulator + if (result > 0) + written += result; + // if the result is not what we expected, consider the write to be incomplete + if (result != chunk) + break; + } file->position = lseek (file->handle, 0, SEEK_CUR); if (file->real_length < file->position) file->real_length = file->position; - if (result < 0) - return 0; - - return result; + // note that this will never be less than 0 even if the write failed + return written; } @@ -3831,7 +3842,7 @@ unsigned char *FS_Deflate(const unsigned char *data, size_t size, size_t *deflat } strm.next_in = (unsigned char*)data; - strm.avail_in = size; + strm.avail_in = (unsigned int)size; tmp = (unsigned char *) Mem_Alloc(tempmempool, size); if(!tmp) @@ -3842,7 +3853,7 @@ unsigned char *FS_Deflate(const unsigned char *data, size_t size, size_t *deflat } strm.next_out = tmp; - strm.avail_out = size; + strm.avail_out = (unsigned int)size; if(qz_deflate(&strm, Z_FINISH) != Z_STREAM_END) { @@ -3932,7 +3943,7 @@ unsigned char *FS_Inflate(const unsigned char *data, size_t size, size_t *inflat } strm.next_in = (unsigned char*)data; - strm.avail_in = size; + strm.avail_in = (unsigned int)size; do { diff --git a/ft2.h b/ft2.h index e8110a72..aa203be5 100644 --- a/ft2.h +++ b/ft2.h @@ -22,7 +22,11 @@ typedef struct ft2_font_map_s ft2_font_map_t; typedef struct ft2_attachment_s ft2_attachment_t; +#ifdef WIN64 +#define ft2_oldstyle_map ((ft2_font_map_t*)-1LL) +#else #define ft2_oldstyle_map ((ft2_font_map_t*)-1) +#endif typedef float ft2_kernvec[2]; typedef struct ft2_kerning_s diff --git a/gl_backend.c b/gl_backend.c index 8dc6d236..28418bf3 100644 --- a/gl_backend.c +++ b/gl_backend.c @@ -277,7 +277,7 @@ typedef struct gl_state_s IDirect3DSurface9 *d3drt_backbuffercolorsurface; void *d3dvertexbuffer; void *d3dvertexdata; - size_t d3dvertexsize; + int d3dvertexsize; #endif } gl_state_t; @@ -505,7 +505,7 @@ static void gl_backend_devicelost(void) Con_DPrintf("FIXME D3D11 %s:%i %s\n", __FILE__, __LINE__, __FUNCTION__); break; } - endindex = Mem_ExpandableArray_IndexRange(&gl_state.meshbufferarray); + endindex = (int)Mem_ExpandableArray_IndexRange(&gl_state.meshbufferarray); for (i = 0;i < endindex;i++) { buffer = (r_meshbuffer_t *) Mem_ExpandableArray_RecordAtIndex(&gl_state.meshbufferarray, i); @@ -3337,12 +3337,12 @@ void R_Mesh_UpdateMeshBuffer(r_meshbuffer_t *buffer, const void *data, size_t si if (buffer->isindexbuffer) { r_refdef.stats[r_stat_indexbufferuploadcount]++; - r_refdef.stats[r_stat_indexbufferuploadsize] += size; + r_refdef.stats[r_stat_indexbufferuploadsize] += (int)size; } else { r_refdef.stats[r_stat_vertexbufferuploadcount]++; - r_refdef.stats[r_stat_vertexbufferuploadsize] += size; + r_refdef.stats[r_stat_vertexbufferuploadsize] += (int)size; } if (!subdata) buffer->size = size; @@ -3390,7 +3390,7 @@ void R_Mesh_UpdateMeshBuffer(r_meshbuffer_t *buffer, const void *data, size_t si if (buffer->devicebuffer) IDirect3DIndexBuffer9_Release((IDirect3DIndexBuffer9*)buffer->devicebuffer); buffer->devicebuffer = NULL; - if (FAILED(result = IDirect3DDevice9_CreateIndexBuffer(vid_d3d9dev, offset+size, buffer->isdynamic ? D3DUSAGE_WRITEONLY | D3DUSAGE_DYNAMIC : 0, buffer->isindex16 ? D3DFMT_INDEX16 : D3DFMT_INDEX32, buffer->isdynamic ? D3DPOOL_DEFAULT : D3DPOOL_MANAGED, &d3d9indexbuffer, NULL))) + if (FAILED(result = IDirect3DDevice9_CreateIndexBuffer(vid_d3d9dev, (unsigned int)(offset+size), buffer->isdynamic ? D3DUSAGE_WRITEONLY | D3DUSAGE_DYNAMIC : 0, buffer->isindex16 ? D3DFMT_INDEX16 : D3DFMT_INDEX32, buffer->isdynamic ? D3DPOOL_DEFAULT : D3DPOOL_MANAGED, &d3d9indexbuffer, NULL))) Sys_Error("IDirect3DDevice9_CreateIndexBuffer(%p, %d, %x, %x, %x, %p, NULL) returned %x\n", vid_d3d9dev, (int)size, buffer->isdynamic ? (int)D3DUSAGE_DYNAMIC : 0, buffer->isindex16 ? (int)D3DFMT_INDEX16 : (int)D3DFMT_INDEX32, buffer->isdynamic ? (int)D3DPOOL_DEFAULT : (int)D3DPOOL_MANAGED, &d3d9indexbuffer, (int)result); buffer->devicebuffer = (void *)d3d9indexbuffer; buffer->size = offset+size; @@ -3412,7 +3412,7 @@ void R_Mesh_UpdateMeshBuffer(r_meshbuffer_t *buffer, const void *data, size_t si if (buffer->devicebuffer) IDirect3DVertexBuffer9_Release((IDirect3DVertexBuffer9*)buffer->devicebuffer); buffer->devicebuffer = NULL; - if (FAILED(result = IDirect3DDevice9_CreateVertexBuffer(vid_d3d9dev, offset+size, buffer->isdynamic ? D3DUSAGE_WRITEONLY | D3DUSAGE_DYNAMIC : 0, 0, buffer->isdynamic ? D3DPOOL_DEFAULT : D3DPOOL_MANAGED, &d3d9vertexbuffer, NULL))) + if (FAILED(result = IDirect3DDevice9_CreateVertexBuffer(vid_d3d9dev, (unsigned int)(offset+size), buffer->isdynamic ? D3DUSAGE_WRITEONLY | D3DUSAGE_DYNAMIC : 0, 0, buffer->isdynamic ? D3DPOOL_DEFAULT : D3DPOOL_MANAGED, &d3d9vertexbuffer, NULL))) Sys_Error("IDirect3DDevice9_CreateVertexBuffer(%p, %d, %x, %x, %x, %p, NULL) returned %x\n", vid_d3d9dev, (int)size, buffer->isdynamic ? (int)D3DUSAGE_DYNAMIC : 0, 0, buffer->isdynamic ? (int)D3DPOOL_DEFAULT : (int)D3DPOOL_MANAGED, &d3d9vertexbuffer, (int)result); buffer->devicebuffer = (void *)d3d9vertexbuffer; buffer->size = offset+size; @@ -3500,7 +3500,7 @@ void GL_Mesh_ListVBOs(qboolean printeach) size_t bufferstat[R_BUFFERDATA_COUNT][2][2]; r_meshbuffer_t *buffer; memset(bufferstat, 0, sizeof(bufferstat)); - endindex = Mem_ExpandableArray_IndexRange(&gl_state.meshbufferarray); + endindex = (int)Mem_ExpandableArray_IndexRange(&gl_state.meshbufferarray); for (i = 0;i < endindex;i++) { buffer = (r_meshbuffer_t *) Mem_ExpandableArray_RecordAtIndex(&gl_state.meshbufferarray, i); @@ -3554,7 +3554,7 @@ void R_Mesh_VertexPointer(int components, int gltype, size_t stride, const void gl_state.pointer_vertex_offset = bufferoffset; CHECKGLERROR GL_BindVBO(bufferobject); - qglVertexPointer(components, gltype, stride, bufferobject ? (void *)bufferoffset : pointer);CHECKGLERROR + qglVertexPointer(components, gltype, (GLsizei)stride, bufferobject ? (void *)bufferoffset : pointer);CHECKGLERROR } #endif break; @@ -3572,7 +3572,7 @@ void R_Mesh_VertexPointer(int components, int gltype, size_t stride, const void CHECKGLERROR GL_BindVBO(bufferobject); // LordHavoc: special flag added to gltype for unnormalized types - qglVertexAttribPointer(GLSLATTRIB_POSITION, components, gltype & ~0x80000000, (gltype & 0x80000000) == 0, stride, bufferobject ? (void *)bufferoffset : pointer);CHECKGLERROR + qglVertexAttribPointer(GLSLATTRIB_POSITION, components, gltype & ~0x80000000, (gltype & 0x80000000) == 0, (GLsizei)stride, bufferobject ? (void *)bufferoffset : pointer);CHECKGLERROR } break; case RENDERPATH_D3D9: @@ -3614,7 +3614,7 @@ void R_Mesh_ColorPointer(int components, int gltype, size_t stride, const void * gl_state.pointer_color_offset = bufferoffset; CHECKGLERROR GL_BindVBO(bufferobject); - qglColorPointer(components, gltype, stride, bufferobject ? (void *)bufferoffset : pointer);CHECKGLERROR + qglColorPointer(components, gltype, (GLsizei)stride, bufferobject ? (void *)bufferoffset : pointer);CHECKGLERROR } } else @@ -3655,7 +3655,7 @@ void R_Mesh_ColorPointer(int components, int gltype, size_t stride, const void * CHECKGLERROR GL_BindVBO(bufferobject); // LordHavoc: special flag added to gltype for unnormalized types - qglVertexAttribPointer(GLSLATTRIB_COLOR, components, gltype & ~0x80000000, (gltype & 0x80000000) == 0, stride, bufferobject ? (void *)bufferoffset : pointer);CHECKGLERROR + qglVertexAttribPointer(GLSLATTRIB_COLOR, components, gltype & ~0x80000000, (gltype & 0x80000000) == 0, (GLsizei)stride, bufferobject ? (void *)bufferoffset : pointer);CHECKGLERROR } } else @@ -3713,7 +3713,7 @@ void R_Mesh_TexCoordPointer(unsigned int unitnum, int components, int gltype, si unit->pointer_texcoord_offset = bufferoffset; GL_ClientActiveTexture(unitnum); GL_BindVBO(bufferobject); - qglTexCoordPointer(components, gltype, stride, bufferobject ? (void *)bufferoffset : pointer);CHECKGLERROR + qglTexCoordPointer(components, gltype, (GLsizei)stride, bufferobject ? (void *)bufferoffset : pointer);CHECKGLERROR } } else @@ -3751,7 +3751,7 @@ void R_Mesh_TexCoordPointer(unsigned int unitnum, int components, int gltype, si unit->pointer_texcoord_offset = bufferoffset; GL_BindVBO(bufferobject); // LordHavoc: special flag added to gltype for unnormalized types - qglVertexAttribPointer(unitnum+GLSLATTRIB_TEXCOORD0, components, gltype & ~0x80000000, (gltype & 0x80000000) == 0, stride, bufferobject ? (void *)bufferoffset : pointer);CHECKGLERROR + qglVertexAttribPointer(unitnum+GLSLATTRIB_TEXCOORD0, components, gltype & ~0x80000000, (gltype & 0x80000000) == 0, (GLsizei)stride, bufferobject ? (void *)bufferoffset : pointer);CHECKGLERROR } } else diff --git a/gl_rmain.c b/gl_rmain.c index 831f3ce3..0021f7f4 100644 --- a/gl_rmain.c +++ b/gl_rmain.c @@ -1629,7 +1629,7 @@ static void R_HLSL_CacheShader(r_hlsl_permutation_t *p, const char *cachename, c vsresult = qD3DXCompileShaderFromFileA(va(vabuf, sizeof(vabuf), "%s/%s_vs.fx", fs_gamedir, cachename), NULL, NULL, "main", vsversion, shaderflags, &vsbuffer, &vslog, &vsconstanttable); } else - vsresult = qD3DXCompileShader(vertstring, strlen(vertstring), NULL, NULL, "main", vsversion, shaderflags, &vsbuffer, &vslog, &vsconstanttable); + vsresult = qD3DXCompileShader(vertstring, (unsigned int)strlen(vertstring), NULL, NULL, "main", vsversion, shaderflags, &vsbuffer, &vslog, &vsconstanttable); if (vsbuffer) { vsbinsize = ID3DXBuffer_GetBufferSize(vsbuffer); @@ -1652,7 +1652,7 @@ static void R_HLSL_CacheShader(r_hlsl_permutation_t *p, const char *cachename, c psresult = qD3DXCompileShaderFromFileA(va(vabuf, sizeof(vabuf), "%s/%s_ps.fx", fs_gamedir, cachename), NULL, NULL, "main", psversion, shaderflags, &psbuffer, &pslog, &psconstanttable); } else - psresult = qD3DXCompileShader(fragstring, strlen(fragstring), NULL, NULL, "main", psversion, shaderflags, &psbuffer, &pslog, &psconstanttable); + psresult = qD3DXCompileShader(fragstring, (unsigned int)strlen(fragstring), NULL, NULL, "main", psversion, shaderflags, &psbuffer, &pslog, &psconstanttable); if (psbuffer) { psbinsize = ID3DXBuffer_GetBufferSize(psbuffer); @@ -1780,23 +1780,23 @@ static void R_HLSL_CompilePermutation(r_hlsl_permutation_t *p, unsigned int mode vertstring_length = 0; for (i = 0;i < vertstrings_count;i++) - vertstring_length += strlen(vertstrings_list[i]); + vertstring_length += (int)strlen(vertstrings_list[i]); vertstring = t = (char *)Mem_Alloc(tempmempool, vertstring_length + 1); - for (i = 0;i < vertstrings_count;t += strlen(vertstrings_list[i]), i++) + for (i = 0;i < vertstrings_count;t += (int)strlen(vertstrings_list[i]), i++) memcpy(t, vertstrings_list[i], strlen(vertstrings_list[i])); geomstring_length = 0; for (i = 0;i < geomstrings_count;i++) - geomstring_length += strlen(geomstrings_list[i]); + geomstring_length += (int)strlen(geomstrings_list[i]); geomstring = t = (char *)Mem_Alloc(tempmempool, geomstring_length + 1); - for (i = 0;i < geomstrings_count;t += strlen(geomstrings_list[i]), i++) + for (i = 0;i < geomstrings_count;t += (int)strlen(geomstrings_list[i]), i++) memcpy(t, geomstrings_list[i], strlen(geomstrings_list[i])); fragstring_length = 0; for (i = 0;i < fragstrings_count;i++) - fragstring_length += strlen(fragstrings_list[i]); + fragstring_length += (int)strlen(fragstrings_list[i]); fragstring = t = (char *)Mem_Alloc(tempmempool, fragstring_length + 1); - for (i = 0;i < fragstrings_count;t += strlen(fragstrings_list[i]), i++) + for (i = 0;i < fragstrings_count;t += (int)strlen(fragstrings_list[i]), i++) memcpy(t, fragstrings_list[i], strlen(fragstrings_list[i])); // try to load the cached shader, or generate one @@ -1900,7 +1900,7 @@ void R_GLSL_Restart_f(void) { r_hlsl_permutation_t *p; r_hlsl_permutation = NULL; - limit = Mem_ExpandableArray_IndexRange(&r_hlsl_permutationarray); + limit = (unsigned int)Mem_ExpandableArray_IndexRange(&r_hlsl_permutationarray); for (i = 0;i < limit;i++) { if ((p = (r_hlsl_permutation_t*)Mem_ExpandableArray_RecordAtIndex(&r_hlsl_permutationarray, i))) @@ -1927,7 +1927,7 @@ void R_GLSL_Restart_f(void) { r_glsl_permutation_t *p; r_glsl_permutation = NULL; - limit = Mem_ExpandableArray_IndexRange(&r_glsl_permutationarray); + limit = (unsigned int)Mem_ExpandableArray_IndexRange(&r_glsl_permutationarray); for (i = 0;i < limit;i++) { if ((p = (r_glsl_permutation_t*)Mem_ExpandableArray_RecordAtIndex(&r_glsl_permutationarray, i))) @@ -4832,7 +4832,7 @@ r_meshbuffer_t *R_BufferData_Store(size_t datasize, const void *data, r_bufferda Sys_Error("R_BufferData_Store: failed to create a new buffer of sufficient size\n"); mem = r_bufferdata_buffer[r_bufferdata_cycle][type]; - offset = mem->current; + offset = (int)mem->current; mem->current += padsize; // upload the data to the buffer at the chosen offset diff --git a/gl_textures.c b/gl_textures.c index 077d918f..4617d0d6 100644 --- a/gl_textures.c +++ b/gl_textures.c @@ -855,7 +855,7 @@ static void r_textures_devicelost(void) { int i, endindex; gltexture_t *glt; - endindex = Mem_ExpandableArray_IndexRange(&texturearray); + endindex = (int)Mem_ExpandableArray_IndexRange(&texturearray); for (i = 0;i < endindex;i++) { glt = (gltexture_t *) Mem_ExpandableArray_RecordAtIndex(&texturearray, i); @@ -899,7 +899,7 @@ static void r_textures_devicerestored(void) { int i, endindex; gltexture_t *glt; - endindex = Mem_ExpandableArray_IndexRange(&texturearray); + endindex = (int)Mem_ExpandableArray_IndexRange(&texturearray); for (i = 0;i < endindex;i++) { glt = (gltexture_t *) Mem_ExpandableArray_RecordAtIndex(&texturearray, i); diff --git a/glquake.h b/glquake.h index 1505cef6..d642e3e9 100644 --- a/glquake.h +++ b/glquake.h @@ -41,7 +41,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #pragma warning(disable : 4310) // LordHavoc: MSVC++ 2008 x86: cast truncates constant value #pragma warning(disable : 4245) // LordHavoc: MSVC++ 2008 x86: 'initializing' : conversion from 'int' to 'unsigned char', signed/unsigned mismatch #pragma warning(disable : 4204) // LordHavoc: MSVC++ 2008 x86: nonstandard extension used : non-constant aggregate initializer -#pragma warning(disable : 4267) // LordHavoc: MSVC++ 2008 x64, conversion from 'size_t' to 'int', possible loss of data +//#pragma warning(disable : 4267) // LordHavoc: MSVC++ 2008 x64, conversion from 'size_t' to 'int', possible loss of data //#pragma warning(disable : 4244) // LordHavoc: MSVC++ 4 x86, double/float //#pragma warning(disable : 4305) // LordHavoc: MSVC++ 6 x86, double/float //#pragma warning(disable : 4706) // LordHavoc: MSVC++ 2008 x86, assignment within conditional expression diff --git a/host_cmd.c b/host_cmd.c index c9cf39c2..2d3d4dd0 100644 --- a/host_cmd.c +++ b/host_cmd.c @@ -648,7 +648,7 @@ void Host_Savegame_to(prvm_prog_t *prog, const char *name) FS_Printf(f,"sv.sound_precache %i %s\n", i, sv.sound_precache[i]); // darkplaces extension - save buffers - numbuffers = Mem_ExpandableArray_IndexRange(&prog->stringbuffersarray); + numbuffers = (int)Mem_ExpandableArray_IndexRange(&prog->stringbuffersarray); for (i = 0; i < numbuffers; i++) { prvm_stringbuffer_t *stringbuffer = (prvm_stringbuffer_t*) Mem_ExpandableArray_RecordAtIndex(&prog->stringbuffersarray, i); @@ -1088,7 +1088,7 @@ static void Host_Loadgame_f (void) Mem_Free(text); // remove all temporary flagged string buffers (ones created with BufStr_FindCreateReplace) - numbuffers = Mem_ExpandableArray_IndexRange(&prog->stringbuffersarray); + numbuffers = (int)Mem_ExpandableArray_IndexRange(&prog->stringbuffersarray); for (i = 0; i < numbuffers; i++) { if ( (stringbuffer = (prvm_stringbuffer_t *)Mem_ExpandableArray_RecordAtIndex(&prog->stringbuffersarray, i)) ) @@ -2652,11 +2652,11 @@ static void Host_Rcon_f (void) // credit: taken from QuakeWorld char argbuf[1500]; dpsnprintf(argbuf, sizeof(argbuf), "%ld.%06d %s", (long) time(NULL), (int) (rand() % 1000000), Cmd_Args()); memcpy(buf, "\377\377\377\377srcon HMAC-MD4 TIME ", 24); - if(HMAC_MDFOUR_16BYTES((unsigned char *) (buf + 24), (unsigned char *) argbuf, strlen(argbuf), (unsigned char *) rcon_password.string, n)) + if(HMAC_MDFOUR_16BYTES((unsigned char *) (buf + 24), (unsigned char *) argbuf, (int)strlen(argbuf), (unsigned char *) rcon_password.string, n)) { buf[40] = ' '; strlcpy(buf + 41, argbuf, sizeof(buf) - 41); - NetConn_Write(mysocket, buf, 41 + strlen(buf + 41), &to); + NetConn_Write(mysocket, buf, 41 + (int)strlen(buf + 41), &to); } } else diff --git a/jpeg.c b/jpeg.c index 8d32adcb..44e53e42 100644 --- a/jpeg.c +++ b/jpeg.c @@ -970,8 +970,8 @@ size_t JPEG_SaveImage_to_Buffer (char *jpegbuf, size_t jpegsize, int width, int } #endif - //quality_guess = (100 * jpegsize - 41000) / (width*height) + 2; // fits random data - quality_guess = (256 * jpegsize - 81920) / (width*height) - 8; // fits Nexuiz's/Xonotic's map pictures + //quality_guess = (int)((100 * jpegsize - 41000) / (width*height) + 2); // fits random data + quality_guess = (int)((256 * jpegsize - 81920) / (width*height) - 8); // fits Nexuiz's/Xonotic's map pictures quality_guess = bound(0, quality_guess, 100); quality = bound(0, quality_guess + sv_writepicture_quality.integer, 100); // assume it can do 10 failed attempts diff --git a/keys.c b/keys.c index ff8d5786..45d2daf8 100644 --- a/keys.c +++ b/keys.c @@ -116,7 +116,7 @@ static void Key_History_Push(void) if(strncmp(key_line, "]quit ", 6)) // putting these into the history just sucks if(strcmp(key_line, "]rcon_password")) // putting these into the history just sucks if(strncmp(key_line, "]rcon_password ", 15)) // putting these into the history just sucks - ConBuffer_AddLine(&history, key_line + 1, strlen(key_line) - 1, 0); + ConBuffer_AddLine(&history, key_line + 1, (int)strlen(key_line) - 1, 0); Con_Printf("%s\n", key_line); // don't mark empty lines as history history_line = -1; if (history_matchfound) @@ -128,7 +128,7 @@ static qboolean Key_History_Get_foundCommand(void) if (!history_matchfound) return false; strlcpy(key_line + 1, ConBuffer_GetLine(&history, history_line), sizeof(key_line) - 1); - key_linepos = strlen(key_line); + key_linepos = (int)strlen(key_line); history_matchfound = false; return true; } @@ -147,14 +147,14 @@ static void Key_History_Up(void) if(history_line != -1) { strlcpy(key_line + 1, ConBuffer_GetLine(&history, history_line), sizeof(key_line) - 1); - key_linepos = strlen(key_line); + key_linepos = (int)strlen(key_line); } } else if(history_line > 0) { --history_line; // this also does -1 -> 0, so it is good strlcpy(key_line + 1, ConBuffer_GetLine(&history, history_line), sizeof(key_line) - 1); - key_linepos = strlen(key_line); + key_linepos = (int)strlen(key_line); } } @@ -177,7 +177,7 @@ static void Key_History_Down(void) strlcpy(key_line + 1, history_savedline, sizeof(key_line) - 1); } - key_linepos = strlen(key_line); + key_linepos = (int)strlen(key_line); } static void Key_History_First(void) @@ -189,7 +189,7 @@ static void Key_History_First(void) { history_line = 0; strlcpy(key_line + 1, ConBuffer_GetLine(&history, history_line), sizeof(key_line) - 1); - key_linepos = strlen(key_line); + key_linepos = (int)strlen(key_line); } } @@ -202,7 +202,7 @@ static void Key_History_Last(void) { history_line = CONBUFFER_LINES_COUNT(&history) - 1; strlcpy(key_line + 1, ConBuffer_GetLine(&history, history_line), sizeof(key_line) - 1); - key_linepos = strlen(key_line); + key_linepos = (int)strlen(key_line); } } @@ -851,12 +851,12 @@ Key_Console (int key, int unicode) // save the content of the variable in cvar_str cvar_str = Cvar_VariableString(cvar); - cvar_str_len = strlen(cvar_str); + cvar_str_len = (int)strlen(cvar_str); if (cvar_str_len==0) return; // insert space and cvar_str in key_line - chars_to_move = strlen(&key_line[key_linepos]); + chars_to_move = (int)strlen(&key_line[key_linepos]); if (key_linepos + 1 + cvar_str_len + chars_to_move < MAX_INPUTLINE) { if (chars_to_move) @@ -914,7 +914,7 @@ Key_Console (int key, int unicode) { int pos; size_t inchar = 0; - pos = u8_prevbyte(key_line+1, key_linepos-1) + 1; // do NOT give the ']' to u8_prevbyte + pos = (int)u8_prevbyte(key_line+1, key_linepos-1) + 1; // do NOT give the ']' to u8_prevbyte while (pos) if(pos-1 > 0 && key_line[pos-1] == STRING_COLOR_TAG && isdigit(key_line[pos])) pos-=2; @@ -930,11 +930,11 @@ Key_Console (int key, int unicode) } // we need to move to the beginning of the character when in a wide character: u8_charidx(key_line, pos + 1, &inchar); - key_linepos = pos + 1 - inchar; + key_linepos = (int)(pos + 1 - inchar); } else { - key_linepos = u8_prevbyte(key_line+1, key_linepos-1) + 1; // do NOT give the ']' to u8_prevbyte + key_linepos = (int)u8_prevbyte(key_line+1, key_linepos-1) + 1; // do NOT give the ']' to u8_prevbyte } return; } @@ -944,7 +944,7 @@ Key_Console (int key, int unicode) { if (key_linepos > 1) { - int newpos = u8_prevbyte(key_line+1, key_linepos-1) + 1; // do NOT give the ']' to u8_prevbyte + int newpos = (int)u8_prevbyte(key_line+1, key_linepos-1) + 1; // do NOT give the ']' to u8_prevbyte strlcpy(key_line + newpos, key_line + key_linepos, sizeof(key_line) + 1 - key_linepos); key_linepos = newpos; } @@ -1011,7 +1011,7 @@ Key_Console (int key, int unicode) // skip the char if (key_line[pos] == STRING_COLOR_TAG && key_line[pos+1] == STRING_COLOR_TAG) // consider ^^ as a character pos++; - pos += u8_bytelen(key_line + pos, 1); + pos += (int)u8_bytelen(key_line + pos, 1); // now go beyond all next consecutive color tags, if any if(pos < len) @@ -1027,7 +1027,7 @@ Key_Console (int key, int unicode) key_linepos = pos; } else - key_linepos += u8_bytelen(key_line + key_linepos, 1); + key_linepos += (int)u8_bytelen(key_line + key_linepos, 1); return; } @@ -1233,7 +1233,7 @@ Key_Message (int key, int ascii) if (key == K_BACKSPACE) { if (chat_bufferlen) { - chat_bufferlen = u8_prevbyte(chat_buffer, chat_bufferlen); + chat_bufferlen = (unsigned int)u8_prevbyte(chat_buffer, chat_bufferlen); chat_buffer[chat_bufferlen] = 0; } return; diff --git a/libcurl.c b/libcurl.c index 48b9fdaa..fd1671ff 100644 --- a/libcurl.c +++ b/libcurl.c @@ -206,7 +206,7 @@ typedef struct downloadinfo_s CURL *curle; qboolean started; int loadtype; - unsigned long bytes_received; // for buffer + size_t bytes_received; // for buffer double bytes_received_curl; // for throttling double bytes_sent_curl; // for throttling struct downloadinfo_s *next, *prev; diff --git a/menu.c b/menu.c index 9894709d..d3e2b8db 100644 --- a/menu.c +++ b/menu.c @@ -5481,7 +5481,7 @@ void MR_Init(void) res_count = VID_SortModes(res, res_count, false, false, true); if(res_count) { - video_resolutions_count = res_count; + video_resolutions_count = (int)res_count; video_resolutions = (video_resolution_t *) Mem_Alloc(cls.permanentmempool, sizeof(*video_resolutions) * (video_resolutions_count + 1)); memset(&video_resolutions[video_resolutions_count], 0, sizeof(video_resolutions[video_resolutions_count])); for(i = 0; i < res_count; ++i) diff --git a/model_brush.c b/model_brush.c index 1ae93a4e..e25f1cf3 100644 --- a/model_brush.c +++ b/model_brush.c @@ -1729,7 +1729,7 @@ static void Mod_Q1BSP_LoadTextures(sizebuf_t *sb) name[j] = MSG_ReadByte(&miptexsb); name[j] = 0; // pretty up the buffer (replacing any trailing garbage with 0) - for (j = strlen(name);j < 16;j++) + for (j = (int)strlen(name);j < 16;j++) name[j] = 0; if (!name[0]) @@ -2165,7 +2165,7 @@ static void Mod_Q1BSP_LoadVertexes(sizebuf_t *sb) { mvertex_t *out; int i, count; - size_t structsize = 12; + int structsize = 12; if (sb->cursize % structsize) Host_Error("Mod_Q1BSP_LoadVertexes: funny lump size in %s",loadmodel->name); @@ -2187,7 +2187,7 @@ static void Mod_Q1BSP_LoadSubmodels(sizebuf_t *sb, hullinfo_t *hullinfo) { mmodel_t *out; int i, j, count; - size_t structsize = (48+4*hullinfo->filehulls); + int structsize = (48+4*hullinfo->filehulls); if (sb->cursize % structsize) Host_Error ("Mod_Q1BSP_LoadSubmodels: funny lump size in %s", loadmodel->name); @@ -2222,7 +2222,7 @@ static void Mod_Q1BSP_LoadEdges(sizebuf_t *sb) { medge_t *out; int i, count; - size_t structsize = loadmodel->brush.isbsp2 ? 8 : 4; + int structsize = loadmodel->brush.isbsp2 ? 8 : 4; if (sb->cursize % structsize) Host_Error("Mod_Q1BSP_LoadEdges: funny lump size in %s",loadmodel->name); @@ -2260,7 +2260,7 @@ static void Mod_Q1BSP_LoadTexinfo(sizebuf_t *sb) { mtexinfo_t *out; int i, j, k, count, miptex; - size_t structsize = 40; + int structsize = 40; if (sb->cursize % structsize) Host_Error("Mod_Q1BSP_LoadTexinfo: funny lump size in %s",loadmodel->name); @@ -2463,7 +2463,7 @@ static void Mod_Q1BSP_LoadFaces(sizebuf_t *sb) float texmins[2], texmaxs[2], val; rtexture_t *lightmaptexture, *deluxemaptexture; char vabuf[1024]; - size_t structsize = loadmodel->brush.isbsp2 ? 28 : 20; + int structsize = loadmodel->brush.isbsp2 ? 28 : 20; if (sb->cursize % structsize) Host_Error("Mod_Q1BSP_LoadFaces: funny lump size in %s",loadmodel->name); @@ -2771,7 +2771,7 @@ static void Mod_Q1BSP_LoadNodes(sizebuf_t *sb) { int i, j, count, p, child[2]; mnode_t *out; - size_t structsize = loadmodel->brush.isbsp2rmqe ? 32 : (loadmodel->brush.isbsp2 ? 44 : 24); + int structsize = loadmodel->brush.isbsp2rmqe ? 32 : (loadmodel->brush.isbsp2 ? 44 : 24); if (sb->cursize % structsize) Host_Error("Mod_Q1BSP_LoadNodes: funny lump size in %s",loadmodel->name); @@ -2875,7 +2875,7 @@ static void Mod_Q1BSP_LoadLeafs(sizebuf_t *sb) { mleaf_t *out; int i, j, count, p, firstmarksurface, nummarksurfaces; - size_t structsize = loadmodel->brush.isbsp2rmqe ? 32 : (loadmodel->brush.isbsp2 ? 44 : 28); + int structsize = loadmodel->brush.isbsp2rmqe ? 32 : (loadmodel->brush.isbsp2 ? 44 : 28); if (sb->cursize % structsize) Host_Error("Mod_Q1BSP_LoadLeafs: funny lump size in %s",loadmodel->name); @@ -2991,7 +2991,7 @@ static void Mod_Q1BSP_LoadClipnodes(sizebuf_t *sb, hullinfo_t *hullinfo) mclipnode_t *out; int i, count; hull_t *hull; - size_t structsize = loadmodel->brush.isbsp2 ? 12 : 8; + int structsize = loadmodel->brush.isbsp2 ? 12 : 8; if (sb->cursize % structsize) Host_Error("Mod_Q1BSP_LoadClipnodes: funny lump size in %s",loadmodel->name); @@ -3073,7 +3073,7 @@ static void Mod_Q1BSP_MakeHull0(void) static void Mod_Q1BSP_LoadLeaffaces(sizebuf_t *sb) { int i, j; - size_t structsize = loadmodel->brush.isbsp2 ? 4 : 2; + int structsize = loadmodel->brush.isbsp2 ? 4 : 2; if (sb->cursize % structsize) Host_Error("Mod_Q1BSP_LoadLeaffaces: funny lump size in %s",loadmodel->name); @@ -3105,7 +3105,7 @@ static void Mod_Q1BSP_LoadLeaffaces(sizebuf_t *sb) static void Mod_Q1BSP_LoadSurfedges(sizebuf_t *sb) { int i; - size_t structsize = 4; + int structsize = 4; if (sb->cursize % structsize) Host_Error("Mod_Q1BSP_LoadSurfedges: funny lump size in %s",loadmodel->name); @@ -3121,7 +3121,7 @@ static void Mod_Q1BSP_LoadPlanes(sizebuf_t *sb) { int i; mplane_t *out; - size_t structsize = 20; + int structsize = 20; if (sb->cursize % structsize) Host_Error("Mod_Q1BSP_LoadPlanes: funny lump size in %s", loadmodel->name); @@ -3271,7 +3271,7 @@ static void Mod_Q1BSP_RecursiveRecalcNodeBBox(mnode_t *node) static void Mod_Q1BSP_FinalizePortals(void) { - int i, j, numportals, numpoints, portalindex, portalrange = Mem_ExpandableArray_IndexRange(&portalarray); + int i, j, numportals, numpoints, portalindex, portalrange = (int)Mem_ExpandableArray_IndexRange(&portalarray); portal_t *p; mportal_t *portal; mvertex_t *point; diff --git a/model_shared.c b/model_shared.c index 5c87e3dd..fc0c3717 100644 --- a/model_shared.c +++ b/model_shared.c @@ -63,7 +63,7 @@ static q3shader_data_t* q3shader_data; static void mod_start(void) { int i, count; - int nummodels = Mem_ExpandableArray_IndexRange(&models); + int nummodels = (int)Mem_ExpandableArray_IndexRange(&models); dp_model_t *mod; SCR_PushLoadingScreen(false, "Loading models", 1.0); @@ -86,7 +86,7 @@ static void mod_start(void) static void mod_shutdown(void) { int i; - int nummodels = Mem_ExpandableArray_IndexRange(&models); + int nummodels = (int)Mem_ExpandableArray_IndexRange(&models); dp_model_t *mod; for (i = 0;i < nummodels;i++) @@ -101,7 +101,7 @@ static void mod_newmap(void) { msurface_t *surface; int i, j, k, surfacenum, ssize, tsize; - int nummodels = Mem_ExpandableArray_IndexRange(&models); + int nummodels = (int)Mem_ExpandableArray_IndexRange(&models); dp_model_t *mod; for (i = 0;i < nummodels;i++) @@ -533,7 +533,7 @@ dp_model_t *Mod_LoadModel(dp_model_t *mod, qboolean crash, qboolean checkdisk) void Mod_ClearUsed(void) { int i; - int nummodels = Mem_ExpandableArray_IndexRange(&models); + int nummodels = (int)Mem_ExpandableArray_IndexRange(&models); dp_model_t *mod; for (i = 0;i < nummodels;i++) if ((mod = (dp_model_t*) Mem_ExpandableArray_RecordAtIndex(&models, i)) && mod->name[0]) @@ -543,7 +543,7 @@ void Mod_ClearUsed(void) void Mod_PurgeUnused(void) { int i; - int nummodels = Mem_ExpandableArray_IndexRange(&models); + int nummodels = (int)Mem_ExpandableArray_IndexRange(&models); dp_model_t *mod; for (i = 0;i < nummodels;i++) { @@ -573,7 +573,7 @@ dp_model_t *Mod_FindName(const char *name, const char *parentname) // if we're not dedicatd, the renderer calls will crash without video Host_StartVideo(); - nummodels = Mem_ExpandableArray_IndexRange(&models); + nummodels = (int)Mem_ExpandableArray_IndexRange(&models); if (!name[0]) Host_Error ("Mod_ForName: empty name"); @@ -626,7 +626,7 @@ Reloads all models if they have changed void Mod_Reload(void) { int i, count; - int nummodels = Mem_ExpandableArray_IndexRange(&models); + int nummodels = (int)Mem_ExpandableArray_IndexRange(&models); dp_model_t *mod; SCR_PushLoadingScreen(false, "Reloading models", 1.0); @@ -657,7 +657,7 @@ Mod_Print static void Mod_Print(void) { int i; - int nummodels = Mem_ExpandableArray_IndexRange(&models); + int nummodels = (int)Mem_ExpandableArray_IndexRange(&models); dp_model_t *mod; Con_Print("Loaded models:\n"); @@ -1244,7 +1244,7 @@ static void Mod_ShadowMesh_CreateVBOs(shadowmesh_t *mesh, mempool_t *mempool) // other hand animated models don't use a lot of vertices anyway... if (!mesh->vbo_vertexbuffer && !vid.useinterleavedarrays) { - size_t size; + int size; unsigned char *mem; size = 0; mesh->vbooffset_vertexmesh = size;if (mesh->vertexmesh ) size += mesh->numverts * sizeof(r_vertexmesh_t); @@ -1691,7 +1691,7 @@ void Mod_LoadQ3Shaders(void) break; } // name - j = strlen(com_token)+1; + j = (int)strlen(com_token)+1; custsurfaceparmnames[numcustsurfaceflags] = (char *)Mem_Alloc(tempmempool, j); strlcpy(custsurfaceparmnames[numcustsurfaceflags], com_token, j+1); // value @@ -3042,7 +3042,7 @@ void Mod_BuildVBOs(void) // other hand animated models don't use a lot of vertices anyway... if (!loadmodel->surfmesh.vbo_vertexbuffer && !vid.useinterleavedarrays) { - size_t size; + int size; unsigned char *mem; size = 0; loadmodel->surfmesh.vbooffset_vertexmesh = size;if (loadmodel->surfmesh.data_vertexmesh ) size += loadmodel->surfmesh.num_vertices * sizeof(r_vertexmesh_t); @@ -3434,7 +3434,7 @@ static void Mod_Decompile_f(void) { // individual frame // check for additional frames with same name - for (l = 0, k = strlen(animname);animname[l];l++) + for (l = 0, k = (int)strlen(animname);animname[l];l++) if(animname[l] < '0' || animname[l] > '9') k = l + 1; if(k > 0 && animname[k-1] == '_') @@ -3444,7 +3444,7 @@ static void Mod_Decompile_f(void) for (j = i + 1;j < mod->numframes;j++) { strlcpy(animname2, mod->animscenes[j].name, sizeof(animname2)); - for (l = 0, k = strlen(animname2);animname2[l];l++) + for (l = 0, k = (int)strlen(animname2);animname2[l];l++) if(animname2[l] < '0' || animname2[l] > '9') k = l + 1; if(k > 0 && animname[k-1] == '_') diff --git a/model_shared.h b/model_shared.h index dd5d5e07..8fcb9814 100644 --- a/model_shared.h +++ b/model_shared.h @@ -146,10 +146,10 @@ typedef struct surfmesh_s int num_triangles; // number of triangles in the mesh int *data_element3i; // int[tris*3] triangles of the mesh, 3 indices into vertex arrays for each r_meshbuffer_t *data_element3i_indexbuffer; - size_t data_element3i_bufferoffset; + int data_element3i_bufferoffset; unsigned short *data_element3s; // unsigned short[tris*3] triangles of the mesh in unsigned short format (NULL if num_vertices > 65536) r_meshbuffer_t *data_element3s_indexbuffer; - size_t data_element3s_bufferoffset; + int data_element3s_bufferoffset; int *data_neighbor3i; // int[tris*3] neighboring triangle on each edge (-1 if none) // vertex data in system memory int num_vertices; // number of vertices in the mesh diff --git a/netconn.c b/netconn.c index 82717308..940bb1a7 100755 --- a/netconn.c +++ b/netconn.c @@ -840,13 +840,13 @@ int NetConn_SendUnreliableMessage(netconn_t *conn, sizebuf_t *data, protocolvers conn->outgoing_netgraph[conn->outgoing_packetcounter].reliablebytes += packetLen + 28; sendme = Crypto_EncryptPacket(&conn->crypto, &sendbuffer, packetLen, &cryptosendbuffer, &sendmelen, sizeof(cryptosendbuffer)); - if (sendme && NetConn_Write(conn->mysocket, sendme, sendmelen, &conn->peeraddress) == (int)sendmelen) + if (sendme && NetConn_Write(conn->mysocket, sendme, (int)sendmelen, &conn->peeraddress) == (int)sendmelen) { conn->lastSendTime = realtime; conn->packetsReSent++; } - totallen += sendmelen + 28; + totallen += (int)sendmelen + 28; } // if we have a new reliable message to send, do so @@ -892,13 +892,13 @@ int NetConn_SendUnreliableMessage(netconn_t *conn, sizebuf_t *data, protocolvers sendme = Crypto_EncryptPacket(&conn->crypto, &sendbuffer, packetLen, &cryptosendbuffer, &sendmelen, sizeof(cryptosendbuffer)); if(sendme) - NetConn_Write(conn->mysocket, sendme, sendmelen, &conn->peeraddress); + NetConn_Write(conn->mysocket, sendme, (int)sendmelen, &conn->peeraddress); conn->lastSendTime = realtime; conn->packetsSent++; conn->reliableMessagesSent++; - totallen += sendmelen + 28; + totallen += (int)sendmelen + 28; } // if we have an unreliable message to send, do so @@ -922,12 +922,12 @@ int NetConn_SendUnreliableMessage(netconn_t *conn, sizebuf_t *data, protocolvers sendme = Crypto_EncryptPacket(&conn->crypto, &sendbuffer, packetLen, &cryptosendbuffer, &sendmelen, sizeof(cryptosendbuffer)); if(sendme) - NetConn_Write(conn->mysocket, sendme, sendmelen, &conn->peeraddress); + NetConn_Write(conn->mysocket, sendme, (int)sendmelen, &conn->peeraddress); conn->packetsSent++; conn->unreliableMessagesSent++; - totallen += sendmelen + 28; + totallen += (int)sendmelen + 28; } } @@ -1203,7 +1203,7 @@ void NetConn_UpdateSockets(void) static int NetConn_ReceivedMessage(netconn_t *conn, const unsigned char *data, size_t length, protocolversion_t protocol, double newtimeout) { - int originallength = length; + int originallength = (int)length; unsigned char sendbuffer[NET_HEADERSIZE+NET_MAXMESSAGE]; unsigned char cryptosendbuffer[NET_HEADERSIZE+NET_MAXMESSAGE+CRYPTO_HEADERSIZE]; unsigned char cryptoreadbuffer[NET_HEADERSIZE+NET_MAXMESSAGE+CRYPTO_HEADERSIZE]; @@ -1292,13 +1292,13 @@ static int NetConn_ReceivedMessage(netconn_t *conn, const unsigned char *data, s if (conn == cls.netcon) { SZ_Clear(&cl_message); - SZ_Write(&cl_message, data, length); + SZ_Write(&cl_message, data, (int)length); MSG_BeginReading(&cl_message); } else { SZ_Clear(&sv_message); - SZ_Write(&sv_message, data, length); + SZ_Write(&sv_message, data, (int)length); MSG_BeginReading(&sv_message); } return 2; @@ -1312,7 +1312,7 @@ static int NetConn_ReceivedMessage(netconn_t *conn, const unsigned char *data, s const void *sendme; size_t sendmelen; - originallength = length; + originallength = (int)length; data = (const unsigned char *) Crypto_DecryptPacket(&conn->crypto, data, length, cryptoreadbuffer, &length, sizeof(cryptoreadbuffer)); if(!data) return 0; @@ -1365,13 +1365,13 @@ static int NetConn_ReceivedMessage(netconn_t *conn, const unsigned char *data, s if (conn == cls.netcon) { SZ_Clear(&cl_message); - SZ_Write(&cl_message, data, length); + SZ_Write(&cl_message, data, (int)length); MSG_BeginReading(&cl_message); } else { SZ_Clear(&sv_message); - SZ_Write(&sv_message, data, length); + SZ_Write(&sv_message, data, (int)length); MSG_BeginReading(&sv_message); } return 2; @@ -1424,7 +1424,7 @@ static int NetConn_ReceivedMessage(netconn_t *conn, const unsigned char *data, s conn->nq.sendSequence++; sendme = Crypto_EncryptPacket(&conn->crypto, &sendbuffer, packetLen, &cryptosendbuffer, &sendmelen, sizeof(cryptosendbuffer)); - if (sendme && NetConn_Write(conn->mysocket, sendme, sendmelen, &conn->peeraddress) == (int)sendmelen) + if (sendme && NetConn_Write(conn->mysocket, sendme, (int)sendmelen, &conn->peeraddress) == (int)sendmelen) { conn->lastSendTime = realtime; conn->packetsSent++; @@ -1452,7 +1452,7 @@ static int NetConn_ReceivedMessage(netconn_t *conn, const unsigned char *data, s StoreBigLong(temppacket + 4, sequence); sendme = Crypto_EncryptPacket(&conn->crypto, temppacket, 8, &cryptosendbuffer, &sendmelen, sizeof(cryptosendbuffer)); if(sendme) - NetConn_Write(conn->mysocket, sendme, sendmelen, &conn->peeraddress); + NetConn_Write(conn->mysocket, sendme, (int)sendmelen, &conn->peeraddress); if (sequence == conn->nq.receiveSequence) { conn->lastMessageTime = realtime; @@ -1460,7 +1460,7 @@ static int NetConn_ReceivedMessage(netconn_t *conn, const unsigned char *data, s conn->nq.receiveSequence++; if( conn->receiveMessageLength + length <= (int)sizeof( conn->receiveMessage ) ) { memcpy(conn->receiveMessage + conn->receiveMessageLength, data, length); - conn->receiveMessageLength += length; + conn->receiveMessageLength += (int)length; } else { Con_Printf( "Reliable message (seq: %i) too big for message buffer!\n" "Dropping the message!\n", sequence ); @@ -1477,13 +1477,13 @@ static int NetConn_ReceivedMessage(netconn_t *conn, const unsigned char *data, s if (conn == cls.netcon) { SZ_Clear(&cl_message); - SZ_Write(&cl_message, conn->receiveMessage, length); + SZ_Write(&cl_message, conn->receiveMessage, (int)length); MSG_BeginReading(&cl_message); } else { SZ_Clear(&sv_message); - SZ_Write(&sv_message, conn->receiveMessage, length); + SZ_Write(&sv_message, conn->receiveMessage, (int)length); MSG_BeginReading(&sv_message); } return 2; @@ -1823,20 +1823,20 @@ static int NetConn_ClientParsePacket(lhnetsocket_t *mysocket, unsigned char *dat if(sendlength) { memcpy(senddata, "\377\377\377\377", 4); - NetConn_Write(mysocket, senddata, sendlength+4, peeraddress); + NetConn_Write(mysocket, senddata, (int)sendlength+4, peeraddress); } break; case CRYPTO_DISCARD: if(sendlength) { memcpy(senddata, "\377\377\377\377", 4); - NetConn_Write(mysocket, senddata, sendlength+4, peeraddress); + NetConn_Write(mysocket, senddata, (int)sendlength+4, peeraddress); } return true; break; case CRYPTO_REPLACE: string = senddata+4; - length = sendlength; + length = (int)sendlength; break; } @@ -1863,12 +1863,12 @@ static int NetConn_ClientParsePacket(lhnetsocket_t *mysocket, unsigned char *dat e = strchr(rcon_password.string, ' '); n = e ? e-rcon_password.string : (int)strlen(rcon_password.string); - if(HMAC_MDFOUR_16BYTES((unsigned char *) (buf + 29), (unsigned char *) argbuf, strlen(argbuf), (unsigned char *) rcon_password.string, n)) + if(HMAC_MDFOUR_16BYTES((unsigned char *) (buf + 29), (unsigned char *) argbuf, (int)strlen(argbuf), (unsigned char *) rcon_password.string, n)) { int k; buf[45] = ' '; strlcpy(buf + 46, argbuf, sizeof(buf) - 46); - NetConn_Write(mysocket, buf, 46 + strlen(buf + 46), peeraddress); + NetConn_Write(mysocket, buf, 46 + (int)strlen(buf + 46), peeraddress); cls.rcon_commands[i][0] = 0; --cls.rcon_trying; @@ -2695,7 +2695,7 @@ static qboolean hmac_mdfour_time_matching(lhnetaddress_t *peeraddress, const cha if(abs(t1 - t2) > rcon_secure_maxdiff.integer) return false; - if(!HMAC_MDFOUR_16BYTES((unsigned char *) mdfourbuf, (unsigned char *) s, slen, (unsigned char *) password, strlen(password))) + if(!HMAC_MDFOUR_16BYTES((unsigned char *) mdfourbuf, (unsigned char *) s, slen, (unsigned char *) password, (int)strlen(password))) return false; return !memcmp(mdfourbuf, hash, 16); @@ -2718,7 +2718,7 @@ static qboolean hmac_mdfour_challenge_matching(lhnetaddress_t *peeraddress, cons if (i == MAX_CHALLENGES) return false; - if(!HMAC_MDFOUR_16BYTES((unsigned char *) mdfourbuf, (unsigned char *) s, slen, (unsigned char *) password, strlen(password))) + if(!HMAC_MDFOUR_16BYTES((unsigned char *) mdfourbuf, (unsigned char *) s, slen, (unsigned char *) password, (int)strlen(password))) return false; if(memcmp(mdfourbuf, hash, 16)) @@ -2927,20 +2927,20 @@ static int NetConn_ServerParsePacket(lhnetsocket_t *mysocket, unsigned char *dat if(sendlength) { memcpy(senddata, "\377\377\377\377", 4); - NetConn_Write(mysocket, senddata, sendlength+4, peeraddress); + NetConn_Write(mysocket, senddata, (int)sendlength+4, peeraddress); } break; case CRYPTO_DISCARD: if(sendlength) { memcpy(senddata, "\377\377\377\377", 4); - NetConn_Write(mysocket, senddata, sendlength+4, peeraddress); + NetConn_Write(mysocket, senddata, (int)sendlength+4, peeraddress); } return true; break; case CRYPTO_REPLACE: string = senddata+4; - length = sendlength; + length = (int)sendlength; break; } @@ -2973,7 +2973,7 @@ static int NetConn_ServerParsePacket(lhnetsocket_t *mysocket, unsigned char *dat dpsnprintf(response, sizeof(response), "\377\377\377\377challenge %s", challenge[i].string); response_len = strlen(response) + 1; Crypto_ServerAppendToChallenge(string, length, response, &response_len, sizeof(response)); - NetConn_Write(mysocket, response, response_len, peeraddress); + NetConn_Write(mysocket, response, (int)response_len, peeraddress); return true; } if (length > 8 && !memcmp(string, "connect\\", 8)) diff --git a/prvm_cmds.c b/prvm_cmds.c index 746d480e..d8f5681c 100644 --- a/prvm_cmds.c +++ b/prvm_cmds.c @@ -2212,8 +2212,8 @@ void VM_strlennocol(prvm_prog_t *prog) szString = PRVM_G_STRING(OFS_PARM0); - //nCnt = COM_StringLengthNoColors(szString, 0, NULL); - nCnt = u8_COM_StringLengthNoColors(szString, 0, NULL); + //nCnt = (int)COM_StringLengthNoColors(szString, 0, NULL); + nCnt = (int)u8_COM_StringLengthNoColors(szString, 0, NULL); PRVM_G_FLOAT(OFS_RETURN) = nCnt; } @@ -2327,7 +2327,7 @@ void VM_substring(prvm_prog_t *prog) if (start < 0) // FTE_STRINGS feature { - u_slength = u8_strlen(s); + u_slength = (int)u8_strlen(s); start += u_slength; start = bound(0, start, u_slength); } @@ -2335,7 +2335,7 @@ void VM_substring(prvm_prog_t *prog) if (length < 0) // FTE_STRINGS feature { if (!u_slength) // it's not calculated when it's not needed above - u_slength = u8_strlen(s); + u_slength = (int)u8_strlen(s); length += u_slength - start + 1; } @@ -2686,7 +2686,7 @@ void VM_tokenizebyseparator (prvm_prog_t *prog) if (!s[0]) continue; separators[numseparators] = s; - separatorlen[numseparators] = strlen(s); + separatorlen[numseparators] = (int)strlen(s); numseparators++; } @@ -4718,7 +4718,7 @@ void BufStr_Flush(prvm_prog_t *prog) prvm_stringbuffer_t *stringbuffer; int i, numbuffers; - numbuffers = Mem_ExpandableArray_IndexRange(&prog->stringbuffersarray); + numbuffers = (int)Mem_ExpandableArray_IndexRange(&prog->stringbuffersarray); for (i = 0; i < numbuffers; i++) if ( (stringbuffer = (prvm_stringbuffer_t *)Mem_ExpandableArray_RecordAtIndex(&prog->stringbuffersarray, i)) ) BufStr_Del(prog, stringbuffer); @@ -5236,7 +5236,7 @@ void VM_buf_writefile(prvm_prog_t *prog) { if (stringbuffer->strings[strindex]) { - if ((strlength = strlen(stringbuffer->strings[strindex]))) + if ((strlength = (int)strlen(stringbuffer->strings[strindex]))) FS_Write(prog->openfiles[filenum], stringbuffer->strings[strindex], strlength); FS_Write(prog->openfiles[filenum], "\n", 1); } @@ -5259,7 +5259,7 @@ static const char *detect_match_rule(char *pattern, int *matchrule) char *ppos, *qpos; int patternlength; - patternlength = strlen(pattern); + patternlength = (int)strlen(pattern); ppos = strchr(pattern, '*'); qpos = strchr(pattern, '?'); // has ? - pattern @@ -5369,7 +5369,7 @@ void VM_bufstr_find(prvm_prog_t *prog) strlcpy(string, PRVM_G_STRING(OFS_PARM1), sizeof(string)); match = detect_match_rule(string, &matchrule); } - matchlen = strlen(match); + matchlen = (int)strlen(match); // find i = (prog->argc > 3) ? (int)PRVM_G_FLOAT(OFS_PARM3) : 0; @@ -5417,7 +5417,7 @@ void VM_matchpattern(prvm_prog_t *prog) } // offset - l = strlen(match); + l = (int)strlen(match); if (prog->argc > 3) s += max(0, min((unsigned int)PRVM_G_FLOAT(OFS_PARM3), strlen(s)-1)); @@ -5652,7 +5652,7 @@ void VM_strstrofs (prvm_prog_t *prog) instr = PRVM_G_STRING(OFS_PARM0); match = PRVM_G_STRING(OFS_PARM1); firstofs = (prog->argc > 2)?(int)PRVM_G_FLOAT(OFS_PARM2):0; - firstofs = u8_bytelen(instr, firstofs); + firstofs = (int)u8_bytelen(instr, firstofs); if (firstofs && (firstofs < 0 || firstofs > (int)strlen(instr))) { @@ -5675,7 +5675,7 @@ void VM_str2chr (prvm_prog_t *prog) int index; VM_SAFEPARMCOUNT(2, VM_str2chr); s = PRVM_G_STRING(OFS_PARM0); - index = u8_bytelen(s, (int)PRVM_G_FLOAT(OFS_PARM1)); + index = (int)u8_bytelen(s, (int)PRVM_G_FLOAT(OFS_PARM1)); if((unsigned)index < strlen(s)) { @@ -5805,7 +5805,7 @@ void VM_strconv (prvm_prog_t *prog) redalpha = (int) PRVM_G_FLOAT(OFS_PARM1); //0 same, 1 white, 2 red, 5 alternate, 6 alternate-alternate rednum = (int) PRVM_G_FLOAT(OFS_PARM2); //0 same, 1 white, 2 red, 3 redspecial, 4 whitespecial, 5 alternate, 6 alternate-alternate VM_VarString(prog, 3, (char *) resbuf, sizeof(resbuf)); - len = strlen((char *) resbuf); + len = (int)strlen((char *) resbuf); for (i = 0; i < len; i++, result++) //should this be done backwards? { @@ -5957,7 +5957,7 @@ void VM_digest_hex(prvm_prog_t *prog) if(!digest) digest = ""; VM_VarString(prog, 1, s, sizeof(s)); - len = strlen(s); + len = (int)strlen(s); outlen = 0; diff --git a/r_shadow.c b/r_shadow.c index 2878de9d..79ab59f0 100644 --- a/r_shadow.c +++ b/r_shadow.c @@ -2418,7 +2418,7 @@ void R_Shadow_UpdateBounceGridTexture(void) if (enable && r_shadow_bouncegrid_static.integer) { enable = false; - range = Mem_ExpandableArray_IndexRange(&r_shadow_worldlightsarray); // checked + range = (unsigned int)Mem_ExpandableArray_IndexRange(&r_shadow_worldlightsarray); // checked for (lightindex = 0;lightindex < range;lightindex++) { light = (dlight_t *) Mem_ExpandableArray_RecordAtIndex(&r_shadow_worldlightsarray, lightindex); @@ -2605,7 +2605,7 @@ void R_Shadow_UpdateBounceGridTexture(void) // clear variables that produce warnings otherwise memset(splatcolor, 0, sizeof(splatcolor)); // iterate world rtlights - range = Mem_ExpandableArray_IndexRange(&r_shadow_worldlightsarray); // checked + range = (unsigned int)Mem_ExpandableArray_IndexRange(&r_shadow_worldlightsarray); // checked range1 = settings.staticmode ? 0 : r_refdef.scene.numlights; range2 = range + range1; photoncount = 0; @@ -5241,11 +5241,11 @@ void R_Shadow_DrawCoronas(void) if (usequery) { GL_ColorMask(0,0,0,0); - if (r_maxqueries < (range + r_refdef.scene.numlights) * 2) + if (r_maxqueries < ((unsigned int)range + r_refdef.scene.numlights) * 2) if (r_maxqueries < MAX_OCCLUSION_QUERIES) { i = r_maxqueries; - r_maxqueries = (range + r_refdef.scene.numlights) * 4; + r_maxqueries = ((unsigned int)range + r_refdef.scene.numlights) * 4; r_maxqueries = min(r_maxqueries, MAX_OCCLUSION_QUERIES); CHECKGLERROR qglGenQueriesARB(r_maxqueries - i, r_queries + i); @@ -5483,7 +5483,7 @@ int R_Shadow_GetRTLightInfo(unsigned int lightindex, float *origin, float *radiu unsigned int range; dlight_t *light; rtlight_t *rtlight; - range = Mem_ExpandableArray_IndexRange(&r_shadow_worldlightsarray); + range = (unsigned int)Mem_ExpandableArray_IndexRange(&r_shadow_worldlightsarray); if (lightindex >= range) return -1; light = (dlight_t *) Mem_ExpandableArray_RecordAtIndex(&r_shadow_worldlightsarray, lightindex); @@ -6458,7 +6458,7 @@ void R_Shadow_EditLights_DrawSelectedLightProperties(void) if (!light) continue; if (light == r_shadow_selectedlight) - lightnumber = lightindex; + lightnumber = (int)lightindex; lightcount++; } dpsnprintf(temp, sizeof(temp), "Cursor origin: %.0f %.0f %.0f", r_editlights_cursorlocation[0], r_editlights_cursorlocation[1], r_editlights_cursorlocation[2]); DrawQ_String(x, y, temp, 0, 8, 8, 1, 1, 1, 1, 0, NULL, false, FONT_DEFAULT);y += 8; @@ -6734,7 +6734,7 @@ void R_LightPoint(float *color, const vec3_t p, const int flags) if (flags & LP_RTWORLD) { flag = r_refdef.scene.rtworld ? LIGHTFLAG_REALTIMEMODE : LIGHTFLAG_NORMALMODE; - numlights = Mem_ExpandableArray_IndexRange(&r_shadow_worldlightsarray); + numlights = (int)Mem_ExpandableArray_IndexRange(&r_shadow_worldlightsarray); for (i = 0; i < numlights; i++) { dlight = (dlight_t *) Mem_ExpandableArray_RecordAtIndex(&r_shadow_worldlightsarray, i); @@ -6840,7 +6840,7 @@ void R_CompleteLightPoint(vec3_t ambient, vec3_t diffuse, vec3_t lightdir, const if (flags & LP_RTWORLD) { flag = r_refdef.scene.rtworld ? LIGHTFLAG_REALTIMEMODE : LIGHTFLAG_NORMALMODE; - numlights = Mem_ExpandableArray_IndexRange(&r_shadow_worldlightsarray); + numlights = (int)Mem_ExpandableArray_IndexRange(&r_shadow_worldlightsarray); for (i = 0; i < numlights; i++) { dlight = (dlight_t *) Mem_ExpandableArray_RecordAtIndex(&r_shadow_worldlightsarray, i); diff --git a/snd_main.c b/snd_main.c index d79857f4..251084a0 100644 --- a/snd_main.c +++ b/snd_main.c @@ -327,7 +327,7 @@ static void S_SoundList_f (void) { unsigned int size; - size = sfx->memsize; + size = (unsigned int)sfx->memsize; Con_Printf ("%c%c%c(%5iHz %2db %6s) %8i : %s\n", (sfx->loopstart < sfx->total_length) ? 'L' : ' ', (sfx->flags & SFXFLAG_STREAMED) ? 'S' : ' ', diff --git a/snd_mem.c b/snd_mem.c index f6e6fcb3..f6f9c145 100644 --- a/snd_mem.c +++ b/snd_mem.c @@ -90,7 +90,7 @@ snd_buffer_t *Snd_CreateSndBuffer (const unsigned char *samples, unsigned int sa sb->format.channels = in_format->channels; sb->format.width = in_format->width; sb->format.speed = sb_speed; - sb->maxframes = newsampleframes; + sb->maxframes = (unsigned int)newsampleframes; sb->nbframes = 0; if (!Snd_AppendToSndBuffer (sb, samples, sampleframes, in_format)) @@ -289,7 +289,7 @@ qboolean Snd_AppendToSndBuffer (snd_buffer_t* sb, const unsigned char *samples, } } - sb->nbframes += outcount; + sb->nbframes += (unsigned int)outcount; return true; } diff --git a/sv_user.c b/sv_user.c index 377472cc..3ac17f23 100644 --- a/sv_user.c +++ b/sv_user.c @@ -878,7 +878,7 @@ void SV_ReadClientMessage(void) clc_stringcmd_invalid: Con_Printf("Received invalid stringcmd from %s\n", host_client->name); if(developer.integer > 0) - Com_HexDumpToConsole((unsigned char *) s, strlen(s)); + Com_HexDumpToConsole((unsigned char *) s, (int)strlen(s)); break; case clc_disconnect: diff --git a/svvm_cmds.c b/svvm_cmds.c index cc4d7e11..ff55c4fd 100644 --- a/svvm_cmds.c +++ b/svvm_cmds.c @@ -1496,8 +1496,8 @@ static void VM_SV_WritePicture(prvm_prog_t *prog) if(Image_Compress(imgname, size, &buf, &size)) { // actual picture - MSG_WriteShort(WriteDest(prog), size); - SZ_Write(WriteDest(prog), (unsigned char *) buf, size); + MSG_WriteShort(WriteDest(prog), (int)size); + SZ_Write(WriteDest(prog), (unsigned char *) buf, (int)size); } else { diff --git a/sys_linux.c b/sys_linux.c index 0b954301..ac2ea616 100644 --- a/sys_linux.c +++ b/sys_linux.c @@ -62,7 +62,7 @@ void Sys_PrintToTerminal(const char *text) #endif while(*text) { - fs_offset_t written = (fs_offset_t)write(outfd, text, strlen(text)); + fs_offset_t written = (fs_offset_t)write(outfd, text, (int)strlen(text)); if(written <= 0) break; // sorry, I cannot do anything about this error - without an output text += written; diff --git a/sys_sdl.c b/sys_sdl.c index cd769979..228c0a49 100644 --- a/sys_sdl.c +++ b/sys_sdl.c @@ -86,7 +86,7 @@ void Sys_PrintToTerminal(const char *text) #endif while(*text) { - fs_offset_t written = (fs_offset_t)write(outfd, text, strlen(text)); + fs_offset_t written = (fs_offset_t)write(outfd, text, (int)strlen(text)); if(written <= 0) break; // sorry, I cannot do anything about this error - without an output text += written; diff --git a/utf8lib.c b/utf8lib.c index 76cc8137..255c44f5 100644 --- a/utf8lib.c +++ b/utf8lib.c @@ -445,7 +445,7 @@ int u8_byteofs(const char *_s, size_t i, size_t *len) } if (len) *len = 1; - return i; + return (int)i; } st = ln = 0; @@ -458,7 +458,7 @@ int u8_byteofs(const char *_s, size_t i, size_t *len) } while(i-- > 0); if (len) *len = ln; - return ofs; + return (int)ofs; } /** Get the char-index for a byte-index. @@ -478,7 +478,7 @@ int u8_charidx(const char *_s, size_t i, size_t *len) if (!utf8_enable.integer) { if (len) *len = 0; - return i; + return (int)i; } while (ofs < i && s[ofs]) @@ -896,8 +896,8 @@ size_t u8_strpad(char *out, size_t outsize, const char *in, qboolean leftalign, { size_t l = u8_bytelen(in, maxwidth); size_t actual_width = u8_strnlen(in, l); - int pad = (actual_width >= minwidth) ? 0 : (minwidth - actual_width); - int prec = l; + int pad = (int)((actual_width >= minwidth) ? 0 : (minwidth - actual_width)); + int prec = (int)l; int lpad = leftalign ? 0 : pad; int rpad = leftalign ? pad : 0; return dpsnprintf(out, outsize, "%*s%.*s%*s", lpad, "", prec, in, rpad, ""); @@ -908,8 +908,8 @@ size_t u8_strpad_colorcodes(char *out, size_t outsize, const char *in, qboolean { size_t l = u8_bytelen_colorcodes(in, maxwidth); size_t actual_width = u8_strnlen_colorcodes(in, l); - int pad = (actual_width >= minwidth) ? 0 : (minwidth - actual_width); - int prec = l; + int pad = (int)((actual_width >= minwidth) ? 0 : (minwidth - actual_width)); + int prec = (int)l; int lpad = leftalign ? 0 : pad; int rpad = leftalign ? pad : 0; return dpsnprintf(out, outsize, "%*s%.*s%*s", lpad, "", prec, in, rpad, ""); diff --git a/vid_sdl.c b/vid_sdl.c index ea1ab82f..003f1ba8 100644 --- a/vid_sdl.c +++ b/vid_sdl.c @@ -2921,8 +2921,13 @@ size_t VID_ListModes(vid_mode_t *modes, size_t maxcount) #if SDL_MAJOR_VERSION == 1 SDL_Rect **vidmodes; int bpp = SDL_GetVideoInfo()->vfmt->BitsPerPixel; +#ifdef WIN64 + SDL_Rect **ENDRECT = (SDL_Rect**)-1LL; +#else + SDL_Rect **ENDRECT = (SDL_Rect**)-1; +#endif - for(vidmodes = SDL_ListModes(NULL, SDL_FULLSCREEN|SDL_HWSURFACE); vidmodes && vidmodes != (SDL_Rect**)(-1) && *vidmodes; ++vidmodes) + for(vidmodes = SDL_ListModes(NULL, SDL_FULLSCREEN|SDL_HWSURFACE); vidmodes && vidmodes != ENDRECT && *vidmodes; ++vidmodes) { if(k >= maxcount) break; -- 2.39.2