out_ptr[3] = (unsigned char)(n1 >> 8);
}
- x = length*4;
+ x = (int)length*4;
if(format->canseek)
{
SCR_CaptureVideo_RIFF_OverflowCheck(8 + x);
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)
{
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]));
{
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
{
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);
}
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] == '\\')
{
// 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();
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;
}
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;
}
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);
}
}
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);
}
}
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
}
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
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];
// 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;
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') ||
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
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;
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;
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);
{
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];
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;
}
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();
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
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;
}
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;
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
}
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;
}
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;
}
}
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)
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;
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;)
*/
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)
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;
}
}
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)
}
strm.next_out = tmp;
- strm.avail_out = size;
+ strm.avail_out = (unsigned int)size;
if(qz_deflate(&strm, Z_FINISH) != Z_STREAM_END)
{
}
strm.next_in = (unsigned char*)data;
- strm.avail_in = size;
+ strm.avail_in = (unsigned int)size;
do
{
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
IDirect3DSurface9 *d3drt_backbuffercolorsurface;
void *d3dvertexbuffer;
void *d3dvertexdata;
- size_t d3dvertexsize;
+ int d3dvertexsize;
#endif
}
gl_state_t;
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);
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;
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;
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;
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);
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;
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:
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
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
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
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
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);
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);
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
{
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)))
{
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)))
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
{
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);
{
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);
#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
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);
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)) )
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
}
#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
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)
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;
}
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);
}
}
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)
{
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);
}
}
{
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);
}
}
// 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)
{
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;
}
// 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;
}
{
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;
}
// 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)
key_linepos = pos;
}
else
- key_linepos += u8_bytelen(key_line + key_linepos, 1);
+ key_linepos += (int)u8_bytelen(key_line + key_linepos, 1);
return;
}
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;
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;
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)
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])
{
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);
{
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);
{
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);
{
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);
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);
{
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);
{
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);
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);
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);
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);
{
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);
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;
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);
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++)
{
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++)
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])
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++)
{
// 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");
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);
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");
// 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);
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
// 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);
{
// 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] == '_')
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] == '_')
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
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
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
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;
}
}
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];
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;
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;
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;
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++;
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;
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 );
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;
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;
}
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;
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);
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))
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;
}
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))
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;
}
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);
}
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;
}
if (!s[0])
continue;
separators[numseparators] = s;
- separatorlen[numseparators] = strlen(s);
+ separatorlen[numseparators] = (int)strlen(s);
numseparators++;
}
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);
{
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);
}
char *ppos, *qpos;
int patternlength;
- patternlength = strlen(pattern);
+ patternlength = (int)strlen(pattern);
ppos = strchr(pattern, '*');
qpos = strchr(pattern, '?');
// has ? - pattern
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;
}
// 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));
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)))
{
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))
{
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?
{
if(!digest)
digest = "";
VM_VarString(prog, 1, s, sizeof(s));
- len = strlen(s);
+ len = (int)strlen(s);
outlen = 0;
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);
// 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;
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);
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);
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;
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);
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);
{
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' : ' ',
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))
}
}
- sb->nbframes += outcount;
+ sb->nbframes += (unsigned int)outcount;
return true;
}
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:
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
{
#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;
#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;
}
if (len) *len = 1;
- return i;
+ return (int)i;
}
st = ln = 0;
} while(i-- > 0);
if (len)
*len = ln;
- return ofs;
+ return (int)ofs;
}
/** Get the char-index for a byte-index.
if (!utf8_enable.integer)
{
if (len) *len = 0;
- return i;
+ return (int)i;
}
while (ofs < i && s[ofs])
{
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, "");
{
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, "");
#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;