Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed some integer conversion warnings. #1094

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions code/Rufl/hstring.cpp
Expand Up @@ -154,7 +154,7 @@ const char* hstring::operator *(void) const
////////////////////////////////////////////////////////////////////////////////////
int hstring::length() const
{
return strlen(c_str());
return static_cast<int>(strlen(c_str()));
}

////////////////////////////////////////////////////////////////////////////////////
Expand All @@ -178,7 +178,7 @@ void hstring::init(const char *str)
}
else
{
mHandle = Pool().get_handle(str, strlen(str)+1); // +1 for null character
mHandle = Pool().get_handle(str, static_cast<int>(strlen(str)+1)); // +1 for null character
}
#ifdef _DEBUG
mStr = (char*)Pool()[mHandle];
Expand Down
6 changes: 3 additions & 3 deletions code/cgame/FxTemplate.cpp
Expand Up @@ -196,7 +196,7 @@ void CPrimitiveTemplate::operator=(const CPrimitiveTemplate &that)
bool CPrimitiveTemplate::ParseFloat( const gsl::cstring_view& val, float& min, float& max )
{
// attempt to read out the values
int v = Q::sscanf( val, min, max );
int v = static_cast<int>(Q::sscanf( val, min, max ));

if ( v == 0 )
{ // nothing was there, failure
Expand Down Expand Up @@ -233,7 +233,7 @@ bool CPrimitiveTemplate::ParseVector( const gsl::cstring_view& val, vec3_t min,
}

// attempt to read out our values
int v = Q::sscanf( val, min[0], min[1], min[2], max[0], max[1], max[2] );
int v = static_cast<int>(Q::sscanf( val, min[0], min[1], min[2], max[0], max[1], max[2] ));

// Check for completeness
if ( v < 3 || v == 4 || v == 5 )
Expand Down Expand Up @@ -268,7 +268,7 @@ namespace detail
template< std::size_t count, typename... Args >
static int call( const gsl::cstring_view& val, std::array< gsl::cstring_view, count >& arr, Args&... args )
{
return Q::sscanf( val, args... );
return static_cast<int>(Q::sscanf( val, args... ));
}
};
}
Expand Down
4 changes: 2 additions & 2 deletions code/cgame/cg_credits.cpp
Expand Up @@ -438,7 +438,7 @@ void CG_Credits_Init( const char *psStripReference, vec4_t *pv4Color)
std::sort( CreditLine.vstrText.begin(), CreditLine.vstrText.end(), SortBySurname );

CreditData.CreditLines.push_back( CreditLine );
iLineNumber += CreditLine.vstrText.size();
iLineNumber += static_cast<int>(CreditLine.vstrText.size());
}
}
break;
Expand Down Expand Up @@ -555,7 +555,7 @@ qboolean CG_Credits_Draw( void )
//
// how many lines is it?
//
int iLines = CreditCard.vstrText.size() + 2; // +2 for title itself & one seperator line
int iLines = static_cast<int>(CreditCard.vstrText.size() + 2); // +2 for title itself & one seperator line
//
int iYpos = (SCREEN_HEIGHT - (iLines * iFontHeight))/2;
//
Expand Down
2 changes: 1 addition & 1 deletion code/cgame/cg_drawtools.cpp
Expand Up @@ -407,7 +407,7 @@ void CG_DrawNumField (int x, int y, int width, int value,int charWidth,int charH
}

Com_sprintf (num, sizeof(num), "%i", value);
l = strlen(num);
l = static_cast<int>(strlen(num));
if (l > width)
l = width;

Expand Down
2 changes: 1 addition & 1 deletion code/cgame/cg_lights.cpp
Expand Up @@ -96,7 +96,7 @@ void CG_SetLightstyle (int i)
int j, k;

s = CG_ConfigString( i+CS_LIGHT_STYLES );
j = strlen (s);
j = static_cast<int>(strlen(s));
if (j >= MAX_QPATH)
{
Com_Error (ERR_DROP, "svc_lightstyle length=%i", j);
Expand Down
14 changes: 7 additions & 7 deletions code/cgame/cg_text.cpp
Expand Up @@ -276,13 +276,13 @@ void CG_CaptionText( const char *str, int sound)

s=(const char*)&text;
// tai...
// s="�ɨ������դh�w�g�w���F�A�ڤ]��Ҧ��o�{���i���u�ө��v�C�ܤ����a�A��hĵ�����ǥ�è�o�{�F�@�Ǫ��p�A�dzƦb�����e���Ⱦ���E�ǧJ��o�C�L���˦��~��ϸ`�A��L�F�h�h���ơC�{�b�L�����H��A�åB�¯٭n�����f�r�C�ھڳ̷s�����i�A�ǧJ��o�H�ΥL���ҦФw�g�������ڤF�����C�ڨ��R�Ӱl���ǧJ��o�H�αϥX�Ҧ��H��C�o�ä��e���C";
// s="�ɨ������դh�w�g�w���F�A�ڤ]��Ҧ��o�{���i���u�ө��v�C�ܤ����a�A��hĵ�����ǥ�è�o�{�F�@�Ǫ��p�A�dzƦb�����e���Ⱦ���E�ǧJ��o�C�L���˦��~��ϸ`�A��L�F�h�h���ơC�{�b�L�����H��A�åB�¯٭n�����f�r�C�ھڳ̷s�����i�A�ǧJ��o�H�ΥL���ҦФw�g�������ڤF�����C�ڨ��R�Ӱl���ǧJ��o�H�αϥX�Ҧ��H��C�o�ä��e���C";
// kor...
// s="Wp:��Ÿ���̴� �ָ�. �׵��� ���Ѵ�� �װ� ������ ����ϰڴ�.��Ÿ���̴� �ָ�. �׵��� ���Ѵ�� �װ� ������ ����ϰڴ�.";
// s="Wp:��Ÿ���̴� �ָ�. �׵��� ���Ѵ�� �װ� ������ ����ϰڴ�.��Ÿ���̴� �ָ�. �׵��� ���Ѵ�� �װ� ������ ����ϰڴ�.";
holds = s;

int iPlayingTimeMS = cgi_S_GetSampleLength(sound);
int iLengthInChars = strlen(s);//cgi_R_Font_StrLenChars(s); // strlen is also good for MBCS in this instance, since it's for timing
int iLengthInChars = static_cast<int>(strlen(s)); //cgi_R_Font_StrLenChars(s); // strlen is also good for MBCS in this instance, since it's for timing
if (iLengthInChars == 0)
{
iLengthInChars = 1;
Expand Down Expand Up @@ -372,10 +372,10 @@ void CG_CaptionText( const char *str, int sound)

// calc the length of time to hold each 2 lines of text on the screen.... presumably this works?
//
holdTime = strlen(cg.captionText[0]);
holdTime = static_cast<int>(strlen(cg.captionText[0]));
if (cg.scrollTextLines > 1)
{
holdTime += strlen(cg.captionText[1]); // strlen is also good for MBCS in this instance, since it's for timing
holdTime += static_cast<int>(strlen(cg.captionText[1])); // strlen is also good for MBCS in this instance, since it's for timing
}
cg.captionNextTextTime = cg.time + (holdTime * cg.captionLetterTime);

Expand Down Expand Up @@ -419,12 +419,12 @@ void CG_DrawCaptionText(void)
}
else
{
holdTime = strlen(cg.captionText[cg.captionTextCurrentLine]);
holdTime = static_cast<int>(strlen(cg.captionText[cg.captionTextCurrentLine]));
if (cg.scrollTextLines >= cg.captionTextCurrentLine)
{
// ( strlen is also good for MBCS in this instance, since it's for timing -ste)
//
holdTime += strlen(cg.captionText[cg.captionTextCurrentLine + 1]);
holdTime += static_cast<int>(strlen(cg.captionText[cg.captionTextCurrentLine + 1]));
}

cg.captionNextTextTime = cg.time + (holdTime * cg.captionLetterTime);//50);
Expand Down
2 changes: 1 addition & 1 deletion code/client/cl_cgame.cpp
Expand Up @@ -313,7 +313,7 @@ void CL_ConfigstringModified( void ) {
continue; // leave with the default empty string
}

len = strlen( dup );
len = static_cast<int>(strlen( dup ));

if ( len + 1 + cl.gameState.dataCount > MAX_GAMESTATE_CHARS ) {
Com_Error( ERR_DROP, "MAX_GAMESTATE_CHARS exceeded" );
Expand Down
4 changes: 2 additions & 2 deletions code/client/cl_console.cpp
Expand Up @@ -166,7 +166,7 @@ void Con_Dump_f (void)
#else
Q_strcat(buffer, bufferlen, "\n");
#endif
FS_Write(buffer, strlen(buffer), f);
FS_Write(buffer, static_cast<int>(strlen(buffer)), f);
}

Z_Free( buffer );
Expand Down Expand Up @@ -567,7 +567,7 @@ void Con_DrawSolidConsole( float frac )
re.SetColor( console_color );
re.DrawStretchPic( 0, y, SCREEN_WIDTH, 2, 0, 0, 0, 0, cls.whiteShader );

i = strlen( Q3_VERSION );
i = static_cast<int>(strlen( Q3_VERSION ));

for (x=0 ; x<i ; x++) {
SCR_DrawSmallChar( cls.glconfig.vidWidth - ( i - x + 1 ) * SMALLCHAR_WIDTH,
Expand Down
12 changes: 6 additions & 6 deletions code/client/cl_keys.cpp
Expand Up @@ -407,7 +407,7 @@ void Field_VariableSizeDraw( field_t *edit, int x, int y, int width, int size, q
int i;

drawLen = edit->widthInChars - 1; // - 1 so there is always a space for the cursor
len = strlen( edit->buffer );
len = static_cast<int>(strlen( edit->buffer ));

// guarantee that cursor will be visible
if ( len <= drawLen ) {
Expand Down Expand Up @@ -456,7 +456,7 @@ void Field_VariableSizeDraw( field_t *edit, int x, int y, int width, int size, q
cursorChar = 10;
}

i = drawLen - strlen( str );
i = drawLen - static_cast<int>(strlen( str ));

if ( size == SMALLCHAR_WIDTH ) {
SCR_DrawSmallChar( x + ( edit->cursor - prestep - i ) * size, y, cursorChar );
Expand Down Expand Up @@ -523,7 +523,7 @@ void Field_KeyDownEvent( field_t *edit, int key ) {
return;
}

len = strlen( edit->buffer );
len = static_cast<int>(strlen( edit->buffer ));

if ( key == A_DELETE ) {
if ( edit->cursor < len ) {
Expand Down Expand Up @@ -594,7 +594,7 @@ void Field_CharEvent( field_t *edit, int ch ) {
return;
}

len = strlen( edit->buffer );
len = static_cast<int>(strlen( edit->buffer ));

if ( ch == 'h' - 'a' + 1 ) { // ctrl-h is backspace
if ( edit->cursor > 0 ) {
Expand Down Expand Up @@ -1046,7 +1046,7 @@ void Key_WriteBindings( fileHandle_t f ) {
FS_Printf( f, "unbindall\n" );
for ( size_t i=0; i<MAX_KEYS; i++ ) {
if ( kg.keys[i].binding && kg.keys[i].binding[0] ) {
const char *name = Key_KeynumToString( i );
const char *name = Key_KeynumToString( static_cast<int>(i) );

// handle the escape character nicely
if ( !strcmp( name, "\\" ) )
Expand All @@ -1066,7 +1066,7 @@ Key_Bindlist_f
void Key_Bindlist_f( void ) {
for ( size_t i=0; i<MAX_KEYS; i++ ) {
if ( kg.keys[i].binding && kg.keys[i].binding[0] )
Com_Printf( S_COLOR_GREY "Key " S_COLOR_WHITE "%s (%s) = " S_COLOR_GREY "\"" S_COLOR_WHITE "%s" S_COLOR_GREY "\"" S_COLOR_WHITE "\n", Key_KeynumToAscii( i ), Key_KeynumToString( i ), kg.keys[i].binding );
Com_Printf( S_COLOR_GREY "Key " S_COLOR_WHITE "%s (%s) = " S_COLOR_GREY "\"" S_COLOR_WHITE "%s" S_COLOR_GREY "\"" S_COLOR_WHITE "\n", Key_KeynumToAscii( static_cast<int>(i) ), Key_KeynumToString( static_cast<int>(i) ), kg.keys[i].binding );
}
}

Expand Down
2 changes: 1 addition & 1 deletion code/client/cl_parse.cpp
Expand Up @@ -395,7 +395,7 @@ void CL_ParseGamestate( msg_t *msg ) {
Com_Error( ERR_DROP, "configstring > MAX_CONFIGSTRINGS" );
}
s = MSG_ReadString( msg );
len = strlen( s );
len = static_cast<int>(strlen( s ));

if ( len + 1 + cl.gameState.dataCount > MAX_GAMESTATE_CHARS ) {
Com_Error( ERR_DROP, "MAX_GAMESTATE_CHARS exceeded" );
Expand Down
8 changes: 4 additions & 4 deletions code/client/snd_ambient.cpp
Expand Up @@ -320,7 +320,7 @@ static void AS_GetSubWaves( ambientSet_t &set )
sscanf( parseBuffer+parsePos, "%s %s", tempBuffer, dirBuffer );

//Move the pointer past these two strings
parsePos += ((strlen(keywordNames[SET_KEYWORD_SUBWAVES])+1) + (strlen(dirBuffer)+1));
parsePos += static_cast<int>((strlen(keywordNames[SET_KEYWORD_SUBWAVES])+1) + (strlen(dirBuffer)+1));

//Get all the subwaves
while ( parsePos <= parseSize )
Expand Down Expand Up @@ -351,7 +351,7 @@ static void AS_GetSubWaves( ambientSet_t &set )
}

//Move the pointer past this string
parsePos += strlen(waveBuffer)+1;
parsePos += static_cast<int>(strlen(waveBuffer)+1);

if ( ( (parseBuffer+parsePos)[0] == '\n') || ( (parseBuffer+parsePos)[0] == '\r') )
break;
Expand Down Expand Up @@ -630,13 +630,13 @@ static qboolean AS_ParseSet( int setID, CSetGroup *sg )
while ( parsePos <= parseSize )
{
//Check for a valid set group
if ( Q_strncmp( parseBuffer+parsePos, name, strlen(name) ) == 0 )
if ( Q_strncmp( parseBuffer+parsePos, name, static_cast<int>(strlen(name)) ) == 0 )
{
//Update the debug info
numSets++;

//Push past the set specifier and on to the name
parsePos+=strlen(name)+1; //Also take the following space out
parsePos+=static_cast<int>(strlen(name)+1); //Also take the following space out

//Get the set name (this MUST be first)
sscanf( parseBuffer+parsePos, "%s", tempBuffer );
Expand Down
2 changes: 1 addition & 1 deletion code/client/snd_dma.cpp
Expand Up @@ -3872,7 +3872,7 @@ void S_SoundList_f( void ) {
qboolean bDumpThisOne = qtrue;
if (iVariantCap >= 1 && iVariantCap <= 3)
{
int iStrLen = strlen(sfx->sSoundName);
int iStrLen = static_cast<int>(strlen(sfx->sSoundName));
if (iStrLen > 2) // crash-safety, jic.
{
char c = sfx->sSoundName[iStrLen-1];
Expand Down
4 changes: 2 additions & 2 deletions code/client/snd_mem.cpp
Expand Up @@ -740,7 +740,7 @@ static qboolean S_LoadSound_Actual( sfx_t *sfx )
char *psExt;
char sLoadName[MAX_QPATH];

int len = strlen(sfx->sSoundName);
int len = static_cast<int>(strlen(sfx->sSoundName));
if (len<5)
{
return qfalse;
Expand All @@ -764,7 +764,7 @@ static qboolean S_LoadSound_Actual( sfx_t *sfx )
//Com_Printf( "WARNING: soundname '%s' does not have 3-letter extension\n",sLoadName);
COM_DefaultExtension(sLoadName,sizeof(sLoadName),".wav"); // so psExt below is always valid
psExt = &sLoadName[strlen(sLoadName)-4];
len = strlen(sLoadName);
len = static_cast<int>(strlen(sLoadName));
}

if (!S_LoadSound_FileLoadAndNameAdjuster(sLoadName, &data, &size, len))
Expand Down
4 changes: 2 additions & 2 deletions code/client/snd_music.cpp
Expand Up @@ -245,7 +245,7 @@ static qboolean Music_ParseMusic( gsl::czstring filename, const CGenericParser2&
}
else if( groupName == sKEY_EXIT )
{
int iThisExitPointIndex = MusicFile.MusicExitPoints.size(); // must eval this first, so unaffected by push_back etc
int iThisExitPointIndex = static_cast<int>(MusicFile.MusicExitPoints.size()); // must eval this first, so unaffected by push_back etc
//
// read this set of exit points...
//
Expand Down Expand Up @@ -291,7 +291,7 @@ static qboolean Music_ParseMusic( gsl::czstring filename, const CGenericParser2&
}

MusicFile.MusicExitPoints.push_back( MusicExitPoint );
int iNumExitPoints = MusicFile.MusicExitPoints.size();
int iNumExitPoints = static_cast<int>(MusicFile.MusicExitPoints.size());

// error checking...
//
Expand Down
2 changes: 1 addition & 1 deletion code/game/G_Timer.cpp
Expand Up @@ -186,7 +186,7 @@ void TIMER_Save( void )
while(p)
{
const char *timerID = p->id.c_str();
const int length = strlen(timerID) + 1;
const int length = static_cast<int>(strlen(timerID) + 1);
const int time = p->time - level.time; //convert this back to delta so we can use SET after loading

assert( length < 1024 );//This will cause problems when loading the timer if longer
Expand Down
2 changes: 1 addition & 1 deletion code/game/NPC_combat.cpp
Expand Up @@ -2704,7 +2704,7 @@ static int NPC_CollectCombatPoints( const vec3_t origin, const float radius, com
}
}

return points.size();
return static_cast<int>(points.size());
}

/*
Expand Down
2 changes: 1 addition & 1 deletion code/game/NPC_stats.cpp
Expand Up @@ -4096,7 +4096,7 @@ void NPC_LoadParms( void )
holdChar = npcExtensionListBuf;
for ( i = 0; i < fileCnt; i++, holdChar += npcExtFNLen + 1 )
{
npcExtFNLen = strlen( holdChar );
npcExtFNLen = static_cast<int>(strlen( holdChar ));

//gi.Printf( "Parsing %s\n", holdChar );

Expand Down
16 changes: 8 additions & 8 deletions code/game/Q3_Interface.cpp
Expand Up @@ -7206,7 +7206,7 @@ VariableSaveFloats

void CQuake3GameInterface::VariableSaveFloats( varFloat_m &fmap )
{
int numFloats = fmap.size();
int numFloats = static_cast<int>(fmap.size());

ojk::SavedGameHelper saved_game(
::gi.saved_game);
Expand All @@ -7219,7 +7219,7 @@ void CQuake3GameInterface::VariableSaveFloats( varFloat_m &fmap )
STL_ITERATE( vfi, fmap )
{
//Save out the map id
int idSize = strlen( ((*vfi).first).c_str() );
int idSize = static_cast<int>(strlen( ((*vfi).first).c_str() ));

//Save out the real data
saved_game.write_chunk<int32_t>(
Expand All @@ -7246,7 +7246,7 @@ VariableSaveStrings

void CQuake3GameInterface::VariableSaveStrings( varString_m &smap )
{
int numStrings = smap.size();
int numStrings = static_cast<int>(smap.size());

ojk::SavedGameHelper saved_game(
::gi.saved_game);
Expand All @@ -7259,7 +7259,7 @@ void CQuake3GameInterface::VariableSaveStrings( varString_m &smap )
STL_ITERATE( vsi, smap )
{
//Save out the map id
int idSize = strlen( ((*vsi).first).c_str() );
int idSize = static_cast<int>(strlen( ((*vsi).first).c_str() ));

//Save out the real data
saved_game.write_chunk<int32_t>(
Expand All @@ -7272,7 +7272,7 @@ void CQuake3GameInterface::VariableSaveStrings( varString_m &smap )
idSize);

//Save out the string value
idSize = strlen( ((*vsi).second).c_str() );
idSize = static_cast<int>(strlen( ((*vsi).second).c_str() ));

saved_game.write_chunk<int32_t>(
INT_ID('S', 'V', 'S', 'Z'),
Expand Down Expand Up @@ -7613,7 +7613,7 @@ int CQuake3GameInterface::MakeValidScriptName( char **strScriptName )
// MAX_FILENAME_LENGTH should really be MAX_QPATH (and 64 bytes instead of 1024), but this fits the rest of the code
char sFilename[MAX_FILENAME_LENGTH];

if ( !Q_stricmpn( *strScriptName, Q3_SCRIPT_DIR, strlen( Q3_SCRIPT_DIR ) ) )
if ( !Q_stricmpn( *strScriptName, Q3_SCRIPT_DIR, static_cast<int>(strlen( Q3_SCRIPT_DIR )) ) )
{
Q_strncpyz( sFilename, *strScriptName, sizeof( sFilename ) );
}
Expand All @@ -7638,7 +7638,7 @@ int CQuake3GameInterface::RegisterScript( const char *strFileName, void **ppBuf,
// MAX_FILENAME_LENGTH should really be MAX_QPATH (and 64 bytes instead of 1024), but this fits the rest of the code
char sFilename[MAX_FILENAME_LENGTH];

if ( !Q_stricmpn( strFileName, Q3_SCRIPT_DIR, strlen( Q3_SCRIPT_DIR ) ) )
if ( !Q_stricmpn( strFileName, Q3_SCRIPT_DIR, static_cast<int>(strlen( Q3_SCRIPT_DIR )) ) )
{
Q_strncpyz( sFilename, strFileName, sizeof( sFilename ) );
}
Expand Down Expand Up @@ -10571,7 +10571,7 @@ int CQuake3GameInterface::GetString( int entID, const char *name, char **value
if( !Q_stricmpn(name, "cvar_", 5) &&
strlen(name) > 5 )
{
gi.Cvar_VariableStringBuffer(name+5, *value, strlen(*value));
gi.Cvar_VariableStringBuffer(name+5, *value, static_cast<int>(strlen(*value)));
return true;
}

Expand Down