From bd79a62804330a1f25ee74bfa172d471bb083b8e Mon Sep 17 00:00:00 2001 From: Jonathan Horner Date: Tue, 18 May 2021 19:37:45 +0100 Subject: [PATCH 01/10] Fixed some integer conversion warnings. Warnings present when compiling with clang-cl 11.0 --- code/game/g_weaponLoad.cpp | 36 ++++---- codemp/botlib/be_ai_chat.cpp | 96 ++++++++++----------- codemp/game/g_log.c | 162 +++++++++++++++++------------------ shared/qcommon/q_string.c | 10 +-- shared/sys/sys_win32.cpp | 14 +-- 5 files changed, 159 insertions(+), 159 deletions(-) diff --git a/code/game/g_weaponLoad.cpp b/code/game/g_weaponLoad.cpp index 75f1e82c69..7fe42661fe 100644 --- a/code/game/g_weaponLoad.cpp +++ b/code/game/g_weaponLoad.cpp @@ -545,7 +545,7 @@ void WPN_WeaponClass(const char **holdBuf) return; } - len = strlen(tokenStr); + len = static_cast(strlen(tokenStr)); len++; if (len > 32) { @@ -568,7 +568,7 @@ void WPN_WeaponModel(const char **holdBuf) return; } - len = strlen(tokenStr); + len = static_cast(strlen(tokenStr)); len++; if (len > 64) { @@ -590,7 +590,7 @@ void WPN_WeaponIcon(const char **holdBuf) return; } - len = strlen(tokenStr); + len = static_cast(strlen(tokenStr)); len++; if (len > 64) { @@ -652,7 +652,7 @@ void WPN_FiringSnd(const char **holdBuf) return; } - len = strlen(tokenStr); + len = static_cast(strlen(tokenStr)); len++; if (len > 64) { @@ -674,7 +674,7 @@ void WPN_AltFiringSnd( const char **holdBuf ) return; } - len = strlen(tokenStr); + len = static_cast(strlen(tokenStr)); len++; if (len > 64) { @@ -696,7 +696,7 @@ void WPN_StopSnd( const char **holdBuf ) return; } - len = strlen(tokenStr); + len = static_cast(strlen(tokenStr)); len++; if (len > 64) { @@ -718,7 +718,7 @@ void WPN_ChargeSnd(const char **holdBuf) return; } - len = strlen(tokenStr); + len = static_cast(strlen(tokenStr)); len++; if (len > 64) { @@ -740,7 +740,7 @@ void WPN_AltChargeSnd(const char **holdBuf) return; } - len = strlen(tokenStr); + len = static_cast(strlen(tokenStr)); len++; if (len > 64) { @@ -762,7 +762,7 @@ void WPN_SelectSnd( const char **holdBuf ) return; } - len = strlen( tokenStr ); + len = static_cast(strlen( tokenStr )); len++; if (len > 64) @@ -938,7 +938,7 @@ void WPN_AmmoIcon(const char **holdBuf) return; } - len = strlen(tokenStr); + len = static_cast(strlen(tokenStr)); len++; if (len > 64) { @@ -1032,7 +1032,7 @@ void WPN_MissileName(const char **holdBuf) return; } - len = strlen(tokenStr); + len = static_cast(strlen(tokenStr)); len++; if (len > 64) { @@ -1055,7 +1055,7 @@ void WPN_AltMissileName(const char **holdBuf) return; } - len = strlen(tokenStr); + len = static_cast(strlen(tokenStr)); len++; if (len > 64) { @@ -1079,7 +1079,7 @@ void WPN_MissileHitSound(const char **holdBuf) return; } - len = strlen(tokenStr); + len = static_cast(strlen(tokenStr)); len++; if (len > 64) { @@ -1101,7 +1101,7 @@ void WPN_AltMissileHitSound(const char **holdBuf) return; } - len = strlen(tokenStr); + len = static_cast(strlen(tokenStr)); len++; if (len > 64) { @@ -1123,7 +1123,7 @@ void WPN_MissileSound(const char **holdBuf) return; } - len = strlen(tokenStr); + len = static_cast(strlen(tokenStr)); len++; if (len > 64) { @@ -1147,7 +1147,7 @@ void WPN_AltMissileSound(const char **holdBuf) return; } - len = strlen(tokenStr); + len = static_cast(strlen(tokenStr)); len++; if (len > 64) { @@ -1319,7 +1319,7 @@ void WPN_MuzzleEffect(const char **holdBuf) } G_EffectIndex( tokenStr ); - Q_strncpyz(weaponData[wpnParms.weaponNum].mMuzzleEffect,tokenStr,len); + Q_strncpyz(weaponData[wpnParms.weaponNum].mMuzzleEffect,tokenStr,static_cast(len)); } //-------------------------------------------- @@ -1341,7 +1341,7 @@ void WPN_AltMuzzleEffect(const char **holdBuf) } G_EffectIndex( tokenStr ); - Q_strncpyz(weaponData[wpnParms.weaponNum].mAltMuzzleEffect,tokenStr,len); + Q_strncpyz(weaponData[wpnParms.weaponNum].mAltMuzzleEffect,tokenStr,static_cast(len)); } //-------------------------------------------- diff --git a/codemp/botlib/be_ai_chat.cpp b/codemp/botlib/be_ai_chat.cpp index fb29c53660..d8b0ddae13 100644 --- a/codemp/botlib/be_ai_chat.cpp +++ b/codemp/botlib/be_ai_chat.cpp @@ -485,7 +485,7 @@ int StringContains(char *str1, char *str2, int casesensitive) if (str1 == NULL || str2 == NULL) return -1; - len = strlen(str1) - strlen(str2); + len = static_cast(strlen(str1)) - static_cast(strlen(str2)); index = 0; for (i = 0; i <= len; i++, str1++, index++) { @@ -514,7 +514,7 @@ char *StringContainsWord(char *str1, char *str2, int casesensitive) { int len, i, j; - len = strlen(str1) - strlen(str2); + len = static_cast(strlen(str1)) - static_cast(strlen(str2)); for (i = 0; i <= len; i++, str1++) { //if not at the start of the string @@ -709,7 +709,7 @@ bot_synonymlist_t *BotLoadSynonyms(char *filename) } //end if len = strlen(token.string) + 1; len = PAD(len, sizeof(long)); - size += sizeof(bot_synonym_t) + len; + size += static_cast(sizeof(bot_synonym_t) + len); if (pass) { synonym = (bot_synonym_t *) ptr; @@ -1007,7 +1007,7 @@ bot_randomlist_t *BotLoadRandomStrings(char *filename) } //end if len = strlen(token.string) + 1; len = PAD(len, sizeof(long)); - size += sizeof(bot_randomlist_t) + len; + size += static_cast(sizeof(bot_randomlist_t) + len); if (pass) { random = (bot_randomlist_t *) ptr; @@ -1038,7 +1038,7 @@ bot_randomlist_t *BotLoadRandomStrings(char *filename) } //end if len = strlen(chatmessagestring) + 1; len = PAD(len, sizeof(long)); - size += sizeof(bot_randomstring_t) + len; + size += static_cast(sizeof(bot_randomstring_t) + len); if (pass) { randomstring = (bot_randomstring_t *) ptr; @@ -1229,7 +1229,7 @@ bot_matchpiece_t *BotLoadMatchPieces(source_t *source, char *endtoken) } //end if } //end if StripDoubleQuotes(token.string); - matchstring = (bot_matchstring_t *) GetClearedHunkMemory(sizeof(bot_matchstring_t) + strlen(token.string) + 1); + matchstring = (bot_matchstring_t *) GetClearedHunkMemory(static_cast(sizeof(bot_matchstring_t) + strlen(token.string) + 1)); matchstring->string = (char *) matchstring + sizeof(bot_matchstring_t); strcpy(matchstring->string, token.string); if (!strlen(token.string)) emptystring = qtrue; @@ -1445,7 +1445,7 @@ int StringsMatch(bot_matchpiece_t *pieces, bot_match_t *match) { assert( match->variables[lastvariable].offset >= 0 ); // bk001204 match->variables[lastvariable].length = - strlen(&match->string[ (int) match->variables[lastvariable].offset]); + static_cast(strlen(&match->string[ (int) match->variables[lastvariable].offset])); } //end if return qtrue; } //end if @@ -1578,7 +1578,7 @@ bot_stringlist_t *BotCheckChatMessageIntegrety(char *message, bot_stringlist_t * if (!BotFindStringInList(stringlist, temp)) { Log_Write("%s = {\"%s\"} //MISSING RANDOM\r\n", temp, temp); - s = (struct bot_stringlist_s *)GetClearedMemory(sizeof(bot_stringlist_t) + strlen(temp) + 1); + s = (struct bot_stringlist_s *)GetClearedMemory(static_cast(sizeof(bot_stringlist_t) + strlen(temp) + 1)); s->string = (char *) s + sizeof(bot_stringlist_t); strcpy(s->string, temp); s->next = stringlist; @@ -1935,7 +1935,7 @@ bot_replychat_t *BotLoadReplyChat(char *filename) FreeSource(source); return NULL; } //end if - key->string = (char *) GetClearedHunkMemory(strlen(namebuffer) + 1); + key->string = (char *) GetClearedHunkMemory(static_cast(strlen(namebuffer) + 1)); strcpy(key->string, namebuffer); } //end else if else //normal string key @@ -1948,7 +1948,7 @@ bot_replychat_t *BotLoadReplyChat(char *filename) return NULL; } //end if StripDoubleQuotes(token.string); - key->string = (char *) GetClearedHunkMemory(strlen(token.string) + 1); + key->string = (char *) GetClearedHunkMemory(static_cast(strlen(token.string) + 1)); strcpy(key->string, token.string); } //end else // @@ -1982,7 +1982,7 @@ bot_replychat_t *BotLoadReplyChat(char *filename) FreeSource(source); return NULL; } //end if - chatmessage = (bot_chatmessage_t *) GetClearedHunkMemory(sizeof(bot_chatmessage_t) + strlen(chatmessagestring) + 1); + chatmessage = (bot_chatmessage_t *) GetClearedHunkMemory(static_cast(sizeof(bot_chatmessage_t) + strlen(chatmessagestring) + 1)); chatmessage->chatmessage = (char *) chatmessage + sizeof(bot_chatmessage_t); strcpy(chatmessage->chatmessage, chatmessagestring); chatmessage->time = -2*CHATMESSAGE_RECENTTIME; @@ -2156,7 +2156,7 @@ bot_chat_t *BotLoadInitialChat(char *chatfile, char *chatname) //the number of chat messages increased chattype->numchatmessages++; } //end if - size += sizeof(bot_chatmessage_t) + len; + size += static_cast(sizeof(bot_chatmessage_t) + len); } //end if } //end while } //end if @@ -2345,7 +2345,7 @@ int BotExpandChatMessage(char *outmessage, char *message, unsigned long mcontext return qfalse; } //end if strcpy(&outputbuf[len], temp); - len += strlen(temp); + len += static_cast(strlen(temp)); } //end if break; } //end case @@ -2372,7 +2372,7 @@ int BotExpandChatMessage(char *outmessage, char *message, unsigned long mcontext return qfalse; } //end if strcpy(&outputbuf[len], ptr); - len += strlen(ptr); + len += static_cast(strlen(ptr)); expansion = qtrue; break; } //end case @@ -2545,50 +2545,50 @@ void BotInitialChat(int chatstate, char *type, int mcontext, char *var0, char *v if( var0 ) { strcat(match.string, var0); match.variables[0].offset = index; - match.variables[0].length = strlen(var0); - index += strlen(var0); + match.variables[0].length = static_cast(strlen(var0)); + index += static_cast(strlen(var0)); } if( var1 ) { strcat(match.string, var1); match.variables[1].offset = index; - match.variables[1].length = strlen(var1); - index += strlen(var1); + match.variables[1].length = static_cast(strlen(var1)); + index += static_cast(strlen(var1)); } if( var2 ) { strcat(match.string, var2); match.variables[2].offset = index; - match.variables[2].length = strlen(var2); - index += strlen(var2); + match.variables[2].length = static_cast(strlen(var2)); + index += static_cast(strlen(var2)); } if( var3 ) { strcat(match.string, var3); match.variables[3].offset = index; - match.variables[3].length = strlen(var3); - index += strlen(var3); + match.variables[3].length = static_cast(strlen(var3)); + index += static_cast(strlen(var3)); } if( var4 ) { strcat(match.string, var4); match.variables[4].offset = index; - match.variables[4].length = strlen(var4); - index += strlen(var4); + match.variables[4].length = static_cast(strlen(var4)); + index += static_cast(strlen(var4)); } if( var5 ) { strcat(match.string, var5); match.variables[5].offset = index; - match.variables[5].length = strlen(var5); - index += strlen(var5); + match.variables[5].length = static_cast(strlen(var5)); + index += static_cast(strlen(var5)); } if( var6 ) { strcat(match.string, var6); match.variables[6].offset = index; - match.variables[6].length = strlen(var6); - index += strlen(var6); + match.variables[6].length = static_cast(strlen(var6)); + index += static_cast(strlen(var6)); } if( var7 ) { strcat(match.string, var7); match.variables[7].offset = index; - match.variables[7].length = strlen(var7); - index += strlen(var7); + match.variables[7].length = static_cast(strlen(var7)); + index += static_cast(strlen(var7)); } // BotConstructChatMessage(cs, message, mcontext, &match, 0, qfalse); @@ -2724,54 +2724,54 @@ int BotReplyChat(int chatstate, char *message, int mcontext, int vcontext, char } //end for if (bestchatmessage) { - index = strlen(bestmatch.string); + index = static_cast(strlen(bestmatch.string)); if( var0 ) { strcat(bestmatch.string, var0); bestmatch.variables[0].offset = index; - bestmatch.variables[0].length = strlen(var0); - index += strlen(var0); + bestmatch.variables[0].length = static_cast(strlen(var0)); + index += static_cast(strlen(var0)); } if( var1 ) { strcat(bestmatch.string, var1); bestmatch.variables[1].offset = index; - bestmatch.variables[1].length = strlen(var1); - index += strlen(var1); + bestmatch.variables[1].length = static_cast(strlen(var1)); + index += static_cast(strlen(var1)); } if( var2 ) { strcat(bestmatch.string, var2); bestmatch.variables[2].offset = index; - bestmatch.variables[2].length = strlen(var2); - index += strlen(var2); + bestmatch.variables[2].length = static_cast(strlen(var2)); + index += static_cast(strlen(var2)); } if( var3 ) { strcat(bestmatch.string, var3); bestmatch.variables[3].offset = index; - bestmatch.variables[3].length = strlen(var3); - index += strlen(var3); + bestmatch.variables[3].length = static_cast(strlen(var3)); + index += static_cast(strlen(var3)); } if( var4 ) { strcat(bestmatch.string, var4); bestmatch.variables[4].offset = index; - bestmatch.variables[4].length = strlen(var4); - index += strlen(var4); + bestmatch.variables[4].length = static_cast(strlen(var4)); + index += static_cast(strlen(var4)); } if( var5 ) { strcat(bestmatch.string, var5); bestmatch.variables[5].offset = index; - bestmatch.variables[5].length = strlen(var5); - index += strlen(var5); + bestmatch.variables[5].length = static_cast(strlen(var5)); + index += static_cast(strlen(var5)); } if( var6 ) { strcat(bestmatch.string, var6); bestmatch.variables[6].offset = index; - bestmatch.variables[6].length = strlen(var6); - index += strlen(var6); + bestmatch.variables[6].length = static_cast(strlen(var6)); + index += static_cast(strlen(var6)); } if( var7 ) { strcat(bestmatch.string, var7); bestmatch.variables[7].offset = index; - bestmatch.variables[7].length = strlen(var7); - index += strlen(var7); + bestmatch.variables[7].length = static_cast(strlen(var7)); + index += static_cast(strlen(var7)); } if (LibVarGetValue("bot_testrchat")) { @@ -2803,7 +2803,7 @@ int BotChatLength(int chatstate) cs = BotChatStateFromHandle(chatstate); if (!cs) return 0; - return strlen(cs->chatmessage); + return static_cast(strlen(cs->chatmessage)); } //end of the function BotChatLength //=========================================================================== // diff --git a/codemp/game/g_log.c b/codemp/game/g_log.c index e789b363c5..f431793b91 100644 --- a/codemp/game/g_log.c +++ b/codemp/game/g_log.c @@ -358,25 +358,25 @@ void G_LogWeaponOutput(void) Q_strncpyz(mapname, Info_ValueForKey( info, "mapname" ), sizeof(mapname)); Com_sprintf(string, sizeof(string), "\n\n\nLevel:\t%s\n\n\n", mapname); - trap->FS_Write( string, strlen( string ), weaponfile); + trap->FS_Write( string, (int)strlen( string ), weaponfile); // Combat data per character // Start with Pickups per character Com_sprintf(string, sizeof(string), "Weapon Pickups per Player:\n\n"); - trap->FS_Write( string, strlen( string ), weaponfile); + trap->FS_Write( string, (int)strlen( string ), weaponfile); Com_sprintf(string, sizeof(string), "Player"); - trap->FS_Write(string, strlen(string), weaponfile); + trap->FS_Write(string, (int)strlen(string), weaponfile); for (j=0; jFS_Write(string, strlen(string), weaponfile); + trap->FS_Write(string, (int)strlen(string), weaponfile); } Com_sprintf(string, sizeof(string), "\n"); - trap->FS_Write(string, strlen(string), weaponfile); + trap->FS_Write(string, (int)strlen(string), weaponfile); // Cycle through each player, give their name and the number of times they picked up each weapon. for (i=0; iFS_Write(nameptr, strlen(nameptr), weaponfile); + trap->FS_Write(nameptr, (int)strlen(nameptr), weaponfile); for (j=0;jFS_Write(string, strlen(string), weaponfile); + trap->FS_Write(string, (int)strlen(string), weaponfile); } Com_sprintf(string, sizeof(string), "\n"); - trap->FS_Write(string, strlen(string), weaponfile); + trap->FS_Write(string, (int)strlen(string), weaponfile); } } // Sum up the totals. Com_sprintf(string, sizeof(string), "\n***TOTAL:"); - trap->FS_Write(string, strlen(string), weaponfile); + trap->FS_Write(string, (int)strlen(string), weaponfile); for (j=0;jFS_Write(string, strlen(string), weaponfile); + trap->FS_Write(string, (int)strlen(string), weaponfile); } Com_sprintf(string, sizeof(string), "\n\n\n"); - trap->FS_Write(string, strlen(string), weaponfile); + trap->FS_Write(string, (int)strlen(string), weaponfile); // Weapon fires per character Com_sprintf(string, sizeof(string), "Weapon Shots per Player:\n\n"); - trap->FS_Write( string, strlen( string ), weaponfile); + trap->FS_Write( string, (int)strlen( string ), weaponfile); Com_sprintf(string, sizeof(string), "Player"); - trap->FS_Write(string, strlen(string), weaponfile); + trap->FS_Write(string, (int)strlen(string), weaponfile); for (j=0; jFS_Write(string, strlen(string), weaponfile); + trap->FS_Write(string, (int)strlen(string), weaponfile); } Com_sprintf(string, sizeof(string), "\n"); - trap->FS_Write(string, strlen(string), weaponfile); + trap->FS_Write(string, (int)strlen(string), weaponfile); // Cycle through each player, give their name and the number of times they picked up each weapon. for (i=0; iFS_Write(nameptr, strlen(nameptr), weaponfile); + trap->FS_Write(nameptr, (int)strlen(nameptr), weaponfile); for (j=0;jFS_Write(string, strlen(string), weaponfile); + trap->FS_Write(string, (int)strlen(string), weaponfile); } Com_sprintf(string, sizeof(string), "\n"); - trap->FS_Write(string, strlen(string), weaponfile); + trap->FS_Write(string, (int)strlen(string), weaponfile); } } // Sum up the totals. Com_sprintf(string, sizeof(string), "\n***TOTAL:"); - trap->FS_Write(string, strlen(string), weaponfile); + trap->FS_Write(string, (int)strlen(string), weaponfile); for (j=0;jFS_Write(string, strlen(string), weaponfile); + trap->FS_Write(string, (int)strlen(string), weaponfile); } Com_sprintf(string, sizeof(string), "\n\n\n"); - trap->FS_Write(string, strlen(string), weaponfile); + trap->FS_Write(string, (int)strlen(string), weaponfile); // Weapon time per character Com_sprintf(string, sizeof(string), "Weapon Use Time per Player:\n\n"); - trap->FS_Write( string, strlen( string ), weaponfile); + trap->FS_Write( string, (int)strlen( string ), weaponfile); Com_sprintf(string, sizeof(string), "Player"); - trap->FS_Write(string, strlen(string), weaponfile); + trap->FS_Write(string, (int)strlen(string), weaponfile); for (j=0; jFS_Write(string, strlen(string), weaponfile); + trap->FS_Write(string, (int)strlen(string), weaponfile); } Com_sprintf(string, sizeof(string), "\n"); - trap->FS_Write(string, strlen(string), weaponfile); + trap->FS_Write(string, (int)strlen(string), weaponfile); // Cycle through each player, give their name and the number of times they picked up each weapon. for (i=0; iFS_Write(nameptr, strlen(nameptr), weaponfile); + trap->FS_Write(nameptr, (int)strlen(nameptr), weaponfile); for (j=0;jFS_Write(string, strlen(string), weaponfile); + trap->FS_Write(string, (int)strlen(string), weaponfile); } Com_sprintf(string, sizeof(string), "\n"); - trap->FS_Write(string, strlen(string), weaponfile); + trap->FS_Write(string, (int)strlen(string), weaponfile); } } // Sum up the totals. Com_sprintf(string, sizeof(string), "\n***TOTAL:"); - trap->FS_Write(string, strlen(string), weaponfile); + trap->FS_Write(string, (int)strlen(string), weaponfile); for (j=0;jFS_Write(string, strlen(string), weaponfile); + trap->FS_Write(string, (int)strlen(string), weaponfile); } Com_sprintf(string, sizeof(string), "\n\n\n"); - trap->FS_Write(string, strlen(string), weaponfile); + trap->FS_Write(string, (int)strlen(string), weaponfile); // Weapon deaths per character Com_sprintf(string, sizeof(string), "Weapon Deaths per Player:\n\n"); - trap->FS_Write( string, strlen( string ), weaponfile); + trap->FS_Write( string, (int)strlen( string ), weaponfile); Com_sprintf(string, sizeof(string), "Player"); - trap->FS_Write(string, strlen(string), weaponfile); + trap->FS_Write(string, (int)strlen(string), weaponfile); for (j=0; jFS_Write(string, strlen(string), weaponfile); + trap->FS_Write(string, (int)strlen(string), weaponfile); } Com_sprintf(string, sizeof(string), "\n"); - trap->FS_Write(string, strlen(string), weaponfile); + trap->FS_Write(string, (int)strlen(string), weaponfile); // Cycle through each player, give their name and the number of times they picked up each weapon. for (i=0; iFS_Write(nameptr, strlen(nameptr), weaponfile); + trap->FS_Write(nameptr, (int)strlen(nameptr), weaponfile); for (j=0;jFS_Write(string, strlen(string), weaponfile); + trap->FS_Write(string, (int)strlen(string), weaponfile); } Com_sprintf(string, sizeof(string), "\n"); - trap->FS_Write(string, strlen(string), weaponfile); + trap->FS_Write(string, (int)strlen(string), weaponfile); } } // Sum up the totals. Com_sprintf(string, sizeof(string), "\n***TOTAL:"); - trap->FS_Write(string, strlen(string), weaponfile); + trap->FS_Write(string, (int)strlen(string), weaponfile); for (j=0;jFS_Write(string, strlen(string), weaponfile); + trap->FS_Write(string, (int)strlen(string), weaponfile); } Com_sprintf(string, sizeof(string), "\n\n\n"); - trap->FS_Write(string, strlen(string), weaponfile); + trap->FS_Write(string, (int)strlen(string), weaponfile); @@ -589,18 +589,18 @@ void G_LogWeaponOutput(void) // Weapon damage per character Com_sprintf(string, sizeof(string), "Weapon Damage per Player:\n\n"); - trap->FS_Write( string, strlen( string ), weaponfile); + trap->FS_Write( string, (int)strlen( string ), weaponfile); Com_sprintf(string, sizeof(string), "Player"); - trap->FS_Write(string, strlen(string), weaponfile); + trap->FS_Write(string, (int)strlen(string), weaponfile); for (j=0; jFS_Write(string, strlen(string), weaponfile); + trap->FS_Write(string, (int)strlen(string), weaponfile); } Com_sprintf(string, sizeof(string), "\n"); - trap->FS_Write(string, strlen(string), weaponfile); + trap->FS_Write(string, (int)strlen(string), weaponfile); // Cycle through each player, give their name and the number of times they picked up each weapon. for (i=0; iFS_Write(nameptr, strlen(nameptr), weaponfile); + trap->FS_Write(nameptr, (int)strlen(nameptr), weaponfile); for (j=0;jFS_Write(string, strlen(string), weaponfile); + trap->FS_Write(string, (int)strlen(string), weaponfile); } Com_sprintf(string, sizeof(string), "\n"); - trap->FS_Write(string, strlen(string), weaponfile); + trap->FS_Write(string, (int)strlen(string), weaponfile); } } // Sum up the totals. Com_sprintf(string, sizeof(string), "\n***TOTAL:"); - trap->FS_Write(string, strlen(string), weaponfile); + trap->FS_Write(string, (int)strlen(string), weaponfile); for (j=0;jFS_Write(string, strlen(string), weaponfile); + trap->FS_Write(string, (int)strlen(string), weaponfile); } Com_sprintf(string, sizeof(string), "\n\n\n"); - trap->FS_Write(string, strlen(string), weaponfile); + trap->FS_Write(string, (int)strlen(string), weaponfile); // Weapon kills per character Com_sprintf(string, sizeof(string), "Weapon Kills per Player:\n\n"); - trap->FS_Write( string, strlen( string ), weaponfile); + trap->FS_Write( string, (int)strlen( string ), weaponfile); Com_sprintf(string, sizeof(string), "Player"); - trap->FS_Write(string, strlen(string), weaponfile); + trap->FS_Write(string, (int)strlen(string), weaponfile); for (j=0; jFS_Write(string, strlen(string), weaponfile); + trap->FS_Write(string, (int)strlen(string), weaponfile); } Com_sprintf(string, sizeof(string), "\n"); - trap->FS_Write(string, strlen(string), weaponfile); + trap->FS_Write(string, (int)strlen(string), weaponfile); // Cycle through each player, give their name and the number of times they picked up each weapon. for (i=0; iFS_Write(nameptr, strlen(nameptr), weaponfile); + trap->FS_Write(nameptr, (int)strlen(nameptr), weaponfile); for (j=0;jFS_Write(string, strlen(string), weaponfile); + trap->FS_Write(string, (int)strlen(string), weaponfile); } Com_sprintf(string, sizeof(string), "\n"); - trap->FS_Write(string, strlen(string), weaponfile); + trap->FS_Write(string, (int)strlen(string), weaponfile); } } // Sum up the totals. Com_sprintf(string, sizeof(string), "\n***TOTAL:"); - trap->FS_Write(string, strlen(string), weaponfile); + trap->FS_Write(string, (int)strlen(string), weaponfile); for (j=0;jFS_Write(string, strlen(string), weaponfile); + trap->FS_Write(string, (int)strlen(string), weaponfile); } Com_sprintf(string, sizeof(string), "\n\n\n"); - trap->FS_Write(string, strlen(string), weaponfile); + trap->FS_Write(string, (int)strlen(string), weaponfile); // Damage type damage per character Com_sprintf(string, sizeof(string), "Typed Damage per Player:\n\n"); - trap->FS_Write( string, strlen( string ), weaponfile); + trap->FS_Write( string, (int)strlen( string ), weaponfile); Com_sprintf(string, sizeof(string), "Player"); - trap->FS_Write(string, strlen(string), weaponfile); + trap->FS_Write(string, (int)strlen(string), weaponfile); for (j=0; jFS_Write(string, strlen(string), weaponfile); + trap->FS_Write(string, (int)strlen(string), weaponfile); } Com_sprintf(string, sizeof(string), "\n"); - trap->FS_Write(string, strlen(string), weaponfile); + trap->FS_Write(string, (int)strlen(string), weaponfile); // Cycle through each player, give their name and the number of times they picked up each weapon. for (i=0; iFS_Write(nameptr, strlen(nameptr), weaponfile); + trap->FS_Write(nameptr, (int)strlen(nameptr), weaponfile); for (j=0;jFS_Write(string, strlen(string), weaponfile); + trap->FS_Write(string, (int)strlen(string), weaponfile); } Com_sprintf(string, sizeof(string), "\n"); - trap->FS_Write(string, strlen(string), weaponfile); + trap->FS_Write(string, (int)strlen(string), weaponfile); } } // Sum up the totals. Com_sprintf(string, sizeof(string), "\n***TOTAL:"); - trap->FS_Write(string, strlen(string), weaponfile); + trap->FS_Write(string, (int)strlen(string), weaponfile); for (j=0;jFS_Write(string, strlen(string), weaponfile); + trap->FS_Write(string, (int)strlen(string), weaponfile); } Com_sprintf(string, sizeof(string), "\n\n\n"); - trap->FS_Write(string, strlen(string), weaponfile); + trap->FS_Write(string, (int)strlen(string), weaponfile); // Damage type kills per character Com_sprintf(string, sizeof(string), "Damage-Typed Kills per Player:\n\n"); - trap->FS_Write( string, strlen( string ), weaponfile); + trap->FS_Write( string, (int)strlen( string ), weaponfile); Com_sprintf(string, sizeof(string), "Player"); - trap->FS_Write(string, strlen(string), weaponfile); + trap->FS_Write(string, (int)strlen(string), weaponfile); for (j=0; jFS_Write(string, strlen(string), weaponfile); + trap->FS_Write(string, (int)strlen(string), weaponfile); } Com_sprintf(string, sizeof(string), "\n"); - trap->FS_Write(string, strlen(string), weaponfile); + trap->FS_Write(string, (int)strlen(string), weaponfile); // Cycle through each player, give their name and the number of times they picked up each weapon. for (i=0; iFS_Write(nameptr, strlen(nameptr), weaponfile); + trap->FS_Write(nameptr, (int)strlen(nameptr), weaponfile); for (j=0;jFS_Write(string, strlen(string), weaponfile); + trap->FS_Write(string, (int)strlen(string), weaponfile); } Com_sprintf(string, sizeof(string), "\n"); - trap->FS_Write(string, strlen(string), weaponfile); + trap->FS_Write(string, (int)strlen(string), weaponfile); } } // Sum up the totals. Com_sprintf(string, sizeof(string), "\n***TOTAL:"); - trap->FS_Write(string, strlen(string), weaponfile); + trap->FS_Write(string, (int)strlen(string), weaponfile); for (j=0;jFS_Write(string, strlen(string), weaponfile); + trap->FS_Write(string, (int)strlen(string), weaponfile); } Com_sprintf(string, sizeof(string), "\n\n\n"); - trap->FS_Write(string, strlen(string), weaponfile); + trap->FS_Write(string, (int)strlen(string), weaponfile); trap->FS_Close(weaponfile); diff --git a/shared/qcommon/q_string.c b/shared/qcommon/q_string.c index a936fe2864..4f2d034cf2 100644 --- a/shared/qcommon/q_string.c +++ b/shared/qcommon/q_string.c @@ -199,7 +199,7 @@ char *Q_strupr( char *s1 ) { void Q_strcat( char *dest, int size, const char *src ) { int l1; - l1 = strlen( dest ); + l1 = (int)strlen( dest ); if ( l1 >= size ) { //Com_Error( ERR_FATAL, "Q_strcat: already overflowed" ); return; @@ -238,7 +238,7 @@ const char *Q_stristr( const char *s, const char *find ) sc -= ('a' - 'A'); } } while (sc != c); - } while (Q_stricmpn(s, find, len) != 0); + } while (Q_stricmpn(s, find, (int)len) != 0); s--; } return s; @@ -351,7 +351,7 @@ void Q_strstrip( char *string, const char *strip, const char *repl ) { char *out=string, *p=string, c; const char *s=strip; - int replaceLen = repl?strlen( repl ):0, offset=0; + int replaceLen = repl ? (int)strlen( repl ) : 0, offset=0; qboolean recordChar = qtrue; while ( (c = *p++) != '\0' ) @@ -359,7 +359,7 @@ void Q_strstrip( char *string, const char *strip, const char *repl ) recordChar = qtrue; for ( s=strip; *s; s++ ) { - offset = s-strip; + offset = (int)(s-strip); if ( c == *s ) { if ( !repl || offset >= replaceLen ) @@ -427,7 +427,7 @@ int Q_vsnprintf(char *str, size_t size, const char *format, va_list ap) // implementation, so we have no choice but to return size. str[size - 1] = '\0'; - return size; + return (int)size; } return retval; diff --git a/shared/sys/sys_win32.cpp b/shared/sys/sys_win32.cpp index 5b6c234cf5..737645ea94 100644 --- a/shared/sys/sys_win32.cpp +++ b/shared/sys/sys_win32.cpp @@ -43,7 +43,7 @@ const char *Sys_Basename( char *path ) static char base[ MAX_OSPATH ] = { 0 }; int length; - length = strlen( path ) - 1; + length = static_cast(strlen( path ) - 1u); // Skip trailing slashes while( length > 0 && path[ length ] == '\\' ) @@ -54,7 +54,7 @@ const char *Sys_Basename( char *path ) Q_strncpyz( base, &path[ length ], sizeof( base ) ); - length = strlen( base ) - 1; + length = static_cast(strlen( base ) - 1u); // Strip trailing slashes while( length > 0 && base[ length ] == '\\' ) @@ -74,7 +74,7 @@ const char *Sys_Dirname( char *path ) int length; Q_strncpyz( dir, path, sizeof( dir ) ); - length = strlen( dir ) - 1; + length = static_cast(strlen( dir ) - 1u); while( length > 0 && dir[ length ] != '\\' ) length--; @@ -192,7 +192,7 @@ static const char *GetErrorString( DWORD error ) { NULL, error, MAKELANGID( LANG_NEUTRAL, SUBLANG_DEFAULT ), (LPTSTR)&lpMsgBuf, 0, NULL ); if ( bufLen ) { LPCSTR lpMsgStr = (LPCSTR)lpMsgBuf; - Q_strncpyz( buf, lpMsgStr, Q_min( (size_t)(lpMsgStr + bufLen), sizeof(buf) ) ); + Q_strncpyz( buf, lpMsgStr, static_cast(Q_min( (size_t)(lpMsgStr + bufLen), sizeof(buf) )) ); LocalFree( lpMsgBuf ); } } @@ -353,8 +353,8 @@ void Sys_ListFilteredFiles( const char *basedir, char *subdirs, char *filter, ch static qboolean strgtr(const char *s0, const char *s1) { int l0, l1, i; - l0 = strlen(s0); - l1 = strlen(s1); + l0 = static_cast(strlen(s0)); + l1 = static_cast(strlen(s1)); if (l1(strlen( extension )); Com_sprintf( search, sizeof(search), "%s\\*%s", directory, extension ); From 74189038ee17d82b91a487f3689f826590572633 Mon Sep 17 00:00:00 2001 From: Jonathan Horner Date: Tue, 18 May 2021 20:43:24 +0100 Subject: [PATCH 02/10] Fixed more integer conversion warnings. --- code/icarus/IcarusImplementation.h | 2 +- code/icarus/Sequencer.cpp | 4 ++-- code/icarus/blockstream.h | 6 +++--- code/icarus/sequence.h | 4 ++-- code/icarus/sequencer.h | 2 +- code/icarus/taskmanager.h | 6 +++--- code/qcommon/safe/memory.h | 2 +- codemp/game/bg_misc.c | 14 +++++++------- codemp/ghoul2/g2_local.h | 2 +- codemp/icarus/blockstream.h | 2 +- codemp/icarus/sequence.h | 2 +- codemp/icarus/sequencer.h | 2 +- 12 files changed, 24 insertions(+), 24 deletions(-) diff --git a/code/icarus/IcarusImplementation.h b/code/icarus/IcarusImplementation.h index 832d689d9a..fa59d6f58f 100644 --- a/code/icarus/IcarusImplementation.h +++ b/code/icarus/IcarusImplementation.h @@ -134,7 +134,7 @@ class CIcarus : public IIcarusInterface // Overloaded new operator. inline void *operator new( size_t size ) { - return IGameInterface::GetGame()->Malloc( size ); + return IGameInterface::GetGame()->Malloc( static_cast(size) ); } // Overloaded delete operator. diff --git a/code/icarus/Sequencer.cpp b/code/icarus/Sequencer.cpp index 91e506f62e..d564e8efe9 100644 --- a/code/icarus/Sequencer.cpp +++ b/code/icarus/Sequencer.cpp @@ -2463,7 +2463,7 @@ int CSequencer::Save() CIcarus *pIcarus = (CIcarus *)IIcarusInterface::GetIcarus(); //Get the number of sequences to save out - numSequences = /*m_sequenceMap.size();*/ m_sequences.size(); + numSequences = /*m_sequenceMap.size();*/ static_cast(m_sequences.size()); //Save out the owner sequence pIcarus->BufferWrite( &m_ownerID, sizeof( m_ownerID ) ); @@ -2483,7 +2483,7 @@ int CSequencer::Save() m_taskManager->Save(); //Save out the task sequences mapping the name to the GUIDs - numTasks = m_taskSequences.size(); + numTasks = static_cast(m_taskSequences.size()); pIcarus->BufferWrite( &numTasks, sizeof( numTasks ) ); STL_ITERATE( ti, m_taskSequences ) diff --git a/code/icarus/blockstream.h b/code/icarus/blockstream.h index ec83804a47..e406bc7530 100644 --- a/code/icarus/blockstream.h +++ b/code/icarus/blockstream.h @@ -65,7 +65,7 @@ class CBlockMember // Overloaded new operator. inline void *operator new( size_t size ) { // Allocate the memory. - return IGameInterface::GetGame()->Malloc( size ); + return IGameInterface::GetGame()->Malloc( static_cast(size) ); } // Overloaded delete operator. @@ -159,7 +159,7 @@ class CBlock // Overloaded new operator. inline void *operator new( size_t size ) { // Allocate the memory. - return IGameInterface::GetGame()->Malloc( size ); + return IGameInterface::GetGame()->Malloc( static_cast(size) ); } // Overloaded delete operator. @@ -210,7 +210,7 @@ class CBlockStream // Overloaded new operator. static void *operator new( size_t size ) { // Allocate the memory. - return IGameInterface::GetGame()->Malloc( size ); + return IGameInterface::GetGame()->Malloc( static_cast(size) ); } // Overloaded delete operator. diff --git a/code/icarus/sequence.h b/code/icarus/sequence.h index d6c0390228..c0f9c89541 100644 --- a/code/icarus/sequence.h +++ b/code/icarus/sequence.h @@ -72,7 +72,7 @@ class CSequence void SetReturn ( CSequence *sequence ); int GetNumCommands( void ) const { return m_numCommands; } - int GetNumChildren( void ) const { return m_children.size(); } + int GetNumChildren( void ) const { return static_cast(m_children.size()); } CSequence *GetChildByID( int id ); CSequence *GetChildByIndex( int iIndex ); @@ -84,7 +84,7 @@ class CSequence // Overloaded new operator. inline void *operator new( size_t size ) { // Allocate the memory. - return IGameInterface::GetGame()->Malloc( size ); + return IGameInterface::GetGame()->Malloc( static_cast(size) ); } // Overloaded delete operator. diff --git a/code/icarus/sequencer.h b/code/icarus/sequencer.h index 9a44f427ca..9e45769bb7 100644 --- a/code/icarus/sequencer.h +++ b/code/icarus/sequencer.h @@ -95,7 +95,7 @@ class CSequencer // Overloaded new operator. inline void *operator new( size_t size ) { // Allocate the memory. - return IGameInterface::GetGame()->Malloc( size ); + return IGameInterface::GetGame()->Malloc( static_cast(size) ); } // Overloaded delete operator. diff --git a/code/icarus/taskmanager.h b/code/icarus/taskmanager.h index 367ab04f67..e836ed1c63 100644 --- a/code/icarus/taskmanager.h +++ b/code/icarus/taskmanager.h @@ -70,7 +70,7 @@ class CTask // Overloaded new operator. inline void *operator new( size_t size ) { // Allocate the memory. - return IGameInterface::GetGame()->Malloc( size ); + return IGameInterface::GetGame()->Malloc( static_cast(size) ); } // Overloaded delete operator. @@ -114,7 +114,7 @@ class CTaskGroup // Overloaded new operator. static void *operator new( size_t size ) { // Allocate the memory. - return IGameInterface::GetGame()->Malloc( size ); + return IGameInterface::GetGame()->Malloc( static_cast(size) ); } // Overloaded delete operator. static void operator delete( void *pRawData ) @@ -180,7 +180,7 @@ class CTaskManager // Overloaded new operator. inline void* operator new( size_t size ) { // Allocate the memory. - return IGameInterface::GetGame()->Malloc( size ); + return IGameInterface::GetGame()->Malloc( static_cast(size) ); } // Overloaded delete operator. diff --git a/code/qcommon/safe/memory.h b/code/qcommon/safe/memory.h index 1299509102..b5dc476280 100644 --- a/code/qcommon/safe/memory.h +++ b/code/qcommon/safe/memory.h @@ -56,7 +56,7 @@ namespace Zone using is_always_equal = std::true_type; T* allocate( std::size_t n ) const { - void* mem = detail::Malloc( n * sizeof( T ), tag ); + void* mem = detail::Malloc( static_cast(n * sizeof( T )), tag ); return static_cast< T* >( mem ); } void deallocate( T* mem, std::size_t n ) const NOEXCEPT diff --git a/codemp/game/bg_misc.c b/codemp/game/bg_misc.c index b7fc7ba955..5f306ca86f 100644 --- a/codemp/game/bg_misc.c +++ b/codemp/game/bg_misc.c @@ -394,7 +394,7 @@ qboolean BG_LegalizedForcePowers(char *powerOut, size_t powerOutSize, int maxRan char powerBuf[128]; char readBuf[128]; qboolean maintainsValidity = qtrue; - int powerLen = strlen(powerOut); + int powerLen = (int)strlen(powerOut); int i = 0; int c = 0; int allowedPoints = 0; @@ -414,7 +414,7 @@ qboolean BG_LegalizedForcePowers(char *powerOut, size_t powerOutSize, int maxRan Q_strncpyz( powerBuf, powerOut, sizeof( powerBuf ) ); //copy it as the original //first of all, print the max rank into the string as the rank - Q_strncpyz( powerOut, va( "%i-", maxRank ), powerOutSize ); + Q_strncpyz( powerOut, va( "%i-", maxRank ), (int)powerOutSize ); while (i < sizeof( powerBuf ) && powerBuf[i] && powerBuf[i] != '-') { @@ -651,9 +651,9 @@ qboolean BG_LegalizedForcePowers(char *powerOut, size_t powerOutSize, int maxRan //We finally have all the force powers legalized and stored locally. //Put them all into the string and return the result. We already have //the rank there, so print the side and the powers now. - Q_strcat(powerOut, powerOutSize, va("%i-", final_Side)); + Q_strcat(powerOut, (int)powerOutSize, va("%i-", final_Side)); - i = strlen(powerOut); + i = (int)strlen(powerOut); c = 0; while (c < NUM_FORCE_POWERS) { @@ -2652,7 +2652,7 @@ qboolean BG_ValidateSkinForTeam( const char *modelName, char *skinName, int team } else {//need to set it to red - int len = strlen( skinName ); + int len = (int)strlen( skinName ); if ( len < 3 ) {//too short to be "red" Q_strcat(skinName, MAX_QPATH, "_red"); @@ -2697,7 +2697,7 @@ qboolean BG_ValidateSkinForTeam( const char *modelName, char *skinName, int team } else {//need to set it to blue - int len = strlen( skinName ); + int len = (int)strlen( skinName ); if ( len < 4 ) {//too short to be "blue" Q_strcat(skinName, MAX_QPATH, "_blue"); @@ -3146,7 +3146,7 @@ void BG_TempFree( int size ) char *BG_StringAlloc ( const char *source ) { - char *dest = (char*)BG_Alloc( strlen ( source ) + 1 ); + char *dest = (char*)BG_Alloc( (int)(strlen ( source ) + 1) ); strcpy( dest, source ); return dest; } diff --git a/codemp/ghoul2/g2_local.h b/codemp/ghoul2/g2_local.h index ac8e6753a4..f852f61843 100644 --- a/codemp/ghoul2/g2_local.h +++ b/codemp/ghoul2/g2_local.h @@ -165,7 +165,7 @@ class CGhoul2Info_v { return 0; } - return Array().size(); + return static_cast(Array().size()); } bool IsValid() const { diff --git a/codemp/icarus/blockstream.h b/codemp/icarus/blockstream.h index afcba7050a..d368a52a1c 100644 --- a/codemp/icarus/blockstream.h +++ b/codemp/icarus/blockstream.h @@ -78,7 +78,7 @@ class CBlockMember inline void *operator new( size_t size ) { // Allocate the memory. - return Z_Malloc( size, TAG_ICARUS4, qtrue ); + return Z_Malloc( (int)size, TAG_ICARUS4, qtrue ); } // Overloaded delete operator. inline void operator delete( void *pRawData ) diff --git a/codemp/icarus/sequence.h b/codemp/icarus/sequence.h index 19c80f23e0..8d28ef8e0d 100644 --- a/codemp/icarus/sequence.h +++ b/codemp/icarus/sequence.h @@ -89,7 +89,7 @@ class CSequence inline void *operator new( size_t size ) { // Allocate the memory. - return Z_Malloc( size, TAG_ICARUS3, qtrue ); + return Z_Malloc( (int)size, TAG_ICARUS3, qtrue ); } // Overloaded delete operator. inline void operator delete( void *pRawData ) diff --git a/codemp/icarus/sequencer.h b/codemp/icarus/sequencer.h index 608ebe91ac..5724eee48d 100644 --- a/codemp/icarus/sequencer.h +++ b/codemp/icarus/sequencer.h @@ -110,7 +110,7 @@ class CSequencer // Overloaded new operator. inline void *operator new( size_t size ) { // Allocate the memory. - return Z_Malloc( size, TAG_ICARUS2, qtrue ); + return Z_Malloc( (int)size, TAG_ICARUS2, qtrue ); } // Overloaded delete operator. inline void operator delete( void *pRawData ) From 7bf681d860d3be1b8a8291f6a75349c194ca02bb Mon Sep 17 00:00:00 2001 From: Jonathan Horner Date: Sat, 22 May 2021 22:06:10 +0100 Subject: [PATCH 03/10] More warnings. --- code/cgame/FxTemplate.cpp | 6 +++--- code/cgame/cg_credits.cpp | 4 ++-- code/cgame/cg_drawtools.cpp | 2 +- code/cgame/cg_lights.cpp | 2 +- code/cgame/cg_text.cpp | 14 +++++++------- code/client/cl_cgame.cpp | 2 +- code/client/cl_console.cpp | 4 ++-- code/client/cl_keys.cpp | 12 ++++++------ code/client/cl_parse.cpp | 2 +- code/client/snd_ambient.cpp | 8 ++++---- code/client/snd_dma.cpp | 2 +- code/client/snd_mem.cpp | 4 ++-- code/client/snd_music.cpp | 4 ++-- code/game/G_Timer.cpp | 2 +- code/game/NPC_combat.cpp | 2 +- code/game/NPC_stats.cpp | 2 +- code/game/Q3_Interface.cpp | 16 ++++++++-------- code/game/bg_vehicleLoad.cpp | 4 ++-- code/game/g_breakable.cpp | 2 +- code/game/g_cmds.cpp | 4 ++-- code/game/g_itemLoad.cpp | 8 ++++---- code/game/g_misc_model.cpp | 2 +- code/game/g_roff.cpp | 4 ++-- code/game/g_savegame.cpp | 2 +- code/game/g_spawn.cpp | 10 +++++----- code/game/wp_saberLoad.cpp | 2 +- 26 files changed, 63 insertions(+), 63 deletions(-) diff --git a/code/cgame/FxTemplate.cpp b/code/cgame/FxTemplate.cpp index dc8efc6dbc..63b79c585b 100644 --- a/code/cgame/FxTemplate.cpp +++ b/code/cgame/FxTemplate.cpp @@ -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(Q::sscanf( val, min, max )); if ( v == 0 ) { // nothing was there, failure @@ -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(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 ) @@ -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(Q::sscanf( val, args... )); } }; } diff --git a/code/cgame/cg_credits.cpp b/code/cgame/cg_credits.cpp index 68ff647634..d7acec0386 100644 --- a/code/cgame/cg_credits.cpp +++ b/code/cgame/cg_credits.cpp @@ -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(CreditLine.vstrText.size()); } } break; @@ -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(CreditCard.vstrText.size() + 2); // +2 for title itself & one seperator line // int iYpos = (SCREEN_HEIGHT - (iLines * iFontHeight))/2; // diff --git a/code/cgame/cg_drawtools.cpp b/code/cgame/cg_drawtools.cpp index a49607c12f..5dd9d09522 100644 --- a/code/cgame/cg_drawtools.cpp +++ b/code/cgame/cg_drawtools.cpp @@ -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(strlen(num)); if (l > width) l = width; diff --git a/code/cgame/cg_lights.cpp b/code/cgame/cg_lights.cpp index 4891e135af..aa1f0636eb 100644 --- a/code/cgame/cg_lights.cpp +++ b/code/cgame/cg_lights.cpp @@ -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(strlen(s)); if (j >= MAX_QPATH) { Com_Error (ERR_DROP, "svc_lightstyle length=%i", j); diff --git a/code/cgame/cg_text.cpp b/code/cgame/cg_text.cpp index d535bcec2c..7a6776f5b8 100644 --- a/code/cgame/cg_text.cpp +++ b/code/cgame/cg_text.cpp @@ -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·Ç³Æ¦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(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; @@ -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(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(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); @@ -419,12 +419,12 @@ void CG_DrawCaptionText(void) } else { - holdTime = strlen(cg.captionText[cg.captionTextCurrentLine]); + holdTime = static_cast(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(strlen(cg.captionText[cg.captionTextCurrentLine + 1])); } cg.captionNextTextTime = cg.time + (holdTime * cg.captionLetterTime);//50); diff --git a/code/client/cl_cgame.cpp b/code/client/cl_cgame.cpp index 70b6534353..3cc572cd98 100644 --- a/code/client/cl_cgame.cpp +++ b/code/client/cl_cgame.cpp @@ -313,7 +313,7 @@ void CL_ConfigstringModified( void ) { continue; // leave with the default empty string } - len = strlen( dup ); + len = static_cast(strlen( dup )); if ( len + 1 + cl.gameState.dataCount > MAX_GAMESTATE_CHARS ) { Com_Error( ERR_DROP, "MAX_GAMESTATE_CHARS exceeded" ); diff --git a/code/client/cl_console.cpp b/code/client/cl_console.cpp index 19c50fd3e2..b860df5a70 100644 --- a/code/client/cl_console.cpp +++ b/code/client/cl_console.cpp @@ -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(strlen(buffer)), f); } Z_Free( buffer ); @@ -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(strlen( Q3_VERSION )); for (x=0 ; xwidthInChars - 1; // - 1 so there is always a space for the cursor - len = strlen( edit->buffer ); + len = static_cast(strlen( edit->buffer )); // guarantee that cursor will be visible if ( len <= drawLen ) { @@ -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(strlen( str )); if ( size == SMALLCHAR_WIDTH ) { SCR_DrawSmallChar( x + ( edit->cursor - prestep - i ) * size, y, cursorChar ); @@ -523,7 +523,7 @@ void Field_KeyDownEvent( field_t *edit, int key ) { return; } - len = strlen( edit->buffer ); + len = static_cast(strlen( edit->buffer )); if ( key == A_DELETE ) { if ( edit->cursor < len ) { @@ -594,7 +594,7 @@ void Field_CharEvent( field_t *edit, int ch ) { return; } - len = strlen( edit->buffer ); + len = static_cast(strlen( edit->buffer )); if ( ch == 'h' - 'a' + 1 ) { // ctrl-h is backspace if ( edit->cursor > 0 ) { @@ -1046,7 +1046,7 @@ void Key_WriteBindings( fileHandle_t f ) { FS_Printf( f, "unbindall\n" ); for ( size_t i=0; i(i) ); // handle the escape character nicely if ( !strcmp( name, "\\" ) ) @@ -1066,7 +1066,7 @@ Key_Bindlist_f void Key_Bindlist_f( void ) { for ( size_t i=0; i(i) ), Key_KeynumToString( static_cast(i) ), kg.keys[i].binding ); } } diff --git a/code/client/cl_parse.cpp b/code/client/cl_parse.cpp index 81c702dc8e..e919c24812 100644 --- a/code/client/cl_parse.cpp +++ b/code/client/cl_parse.cpp @@ -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(strlen( s )); if ( len + 1 + cl.gameState.dataCount > MAX_GAMESTATE_CHARS ) { Com_Error( ERR_DROP, "MAX_GAMESTATE_CHARS exceeded" ); diff --git a/code/client/snd_ambient.cpp b/code/client/snd_ambient.cpp index 66143fbe75..19f32bf12f 100644 --- a/code/client/snd_ambient.cpp +++ b/code/client/snd_ambient.cpp @@ -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((strlen(keywordNames[SET_KEYWORD_SUBWAVES])+1) + (strlen(dirBuffer)+1)); //Get all the subwaves while ( parsePos <= parseSize ) @@ -351,7 +351,7 @@ static void AS_GetSubWaves( ambientSet_t &set ) } //Move the pointer past this string - parsePos += strlen(waveBuffer)+1; + parsePos += static_cast(strlen(waveBuffer)+1); if ( ( (parseBuffer+parsePos)[0] == '\n') || ( (parseBuffer+parsePos)[0] == '\r') ) break; @@ -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(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(strlen(name)+1); //Also take the following space out //Get the set name (this MUST be first) sscanf( parseBuffer+parsePos, "%s", tempBuffer ); diff --git a/code/client/snd_dma.cpp b/code/client/snd_dma.cpp index 5e9a5e36f9..a2509a97d7 100644 --- a/code/client/snd_dma.cpp +++ b/code/client/snd_dma.cpp @@ -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(strlen(sfx->sSoundName)); if (iStrLen > 2) // crash-safety, jic. { char c = sfx->sSoundName[iStrLen-1]; diff --git a/code/client/snd_mem.cpp b/code/client/snd_mem.cpp index f2a003edab..c4149deffb 100644 --- a/code/client/snd_mem.cpp +++ b/code/client/snd_mem.cpp @@ -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(strlen(sfx->sSoundName)); if (len<5) { return qfalse; @@ -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(strlen(sLoadName)); } if (!S_LoadSound_FileLoadAndNameAdjuster(sLoadName, &data, &size, len)) diff --git a/code/client/snd_music.cpp b/code/client/snd_music.cpp index 8c8eec9332..781b1300ad 100644 --- a/code/client/snd_music.cpp +++ b/code/client/snd_music.cpp @@ -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(MusicFile.MusicExitPoints.size()); // must eval this first, so unaffected by push_back etc // // read this set of exit points... // @@ -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(MusicFile.MusicExitPoints.size()); // error checking... // diff --git a/code/game/G_Timer.cpp b/code/game/G_Timer.cpp index 028613a4bd..e296f636da 100644 --- a/code/game/G_Timer.cpp +++ b/code/game/G_Timer.cpp @@ -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(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 diff --git a/code/game/NPC_combat.cpp b/code/game/NPC_combat.cpp index fc60f59f76..7b71572f0b 100644 --- a/code/game/NPC_combat.cpp +++ b/code/game/NPC_combat.cpp @@ -2704,7 +2704,7 @@ static int NPC_CollectCombatPoints( const vec3_t origin, const float radius, com } } - return points.size(); + return static_cast(points.size()); } /* diff --git a/code/game/NPC_stats.cpp b/code/game/NPC_stats.cpp index 1e3ea43cbb..842c6451a5 100644 --- a/code/game/NPC_stats.cpp +++ b/code/game/NPC_stats.cpp @@ -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(strlen( holdChar )); //gi.Printf( "Parsing %s\n", holdChar ); diff --git a/code/game/Q3_Interface.cpp b/code/game/Q3_Interface.cpp index 310dd28882..db7daf9427 100644 --- a/code/game/Q3_Interface.cpp +++ b/code/game/Q3_Interface.cpp @@ -7206,7 +7206,7 @@ VariableSaveFloats void CQuake3GameInterface::VariableSaveFloats( varFloat_m &fmap ) { - int numFloats = fmap.size(); + int numFloats = static_cast(fmap.size()); ojk::SavedGameHelper saved_game( ::gi.saved_game); @@ -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(strlen( ((*vfi).first).c_str() )); //Save out the real data saved_game.write_chunk( @@ -7246,7 +7246,7 @@ VariableSaveStrings void CQuake3GameInterface::VariableSaveStrings( varString_m &smap ) { - int numStrings = smap.size(); + int numStrings = static_cast(smap.size()); ojk::SavedGameHelper saved_game( ::gi.saved_game); @@ -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(strlen( ((*vsi).first).c_str() )); //Save out the real data saved_game.write_chunk( @@ -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(strlen( ((*vsi).second).c_str() )); saved_game.write_chunk( INT_ID('S', 'V', 'S', 'Z'), @@ -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(strlen( Q3_SCRIPT_DIR )) ) ) { Q_strncpyz( sFilename, *strScriptName, sizeof( sFilename ) ); } @@ -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(strlen( Q3_SCRIPT_DIR )) ) ) { Q_strncpyz( sFilename, strFileName, sizeof( sFilename ) ); } @@ -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(strlen(*value))); return true; } diff --git a/code/game/bg_vehicleLoad.cpp b/code/game/bg_vehicleLoad.cpp index 3251fad821..d06e81784d 100644 --- a/code/game/bg_vehicleLoad.cpp +++ b/code/game/bg_vehicleLoad.cpp @@ -1474,7 +1474,7 @@ void BG_VehWeaponLoadParms( void ) for ( i = 0; i < fileCnt; i++, holdChar += vehExtFNLen + 1 ) { - vehExtFNLen = strlen( holdChar ); + vehExtFNLen = static_cast(strlen( holdChar )); // Com_Printf( "Parsing %s\n", holdChar ); @@ -1566,7 +1566,7 @@ void BG_VehicleLoadParms( void ) for ( i = 0; i < fileCnt; i++, holdChar += vehExtFNLen + 1 ) { - vehExtFNLen = strlen( holdChar ); + vehExtFNLen = static_cast(strlen( holdChar )); // Com_Printf( "Parsing %s\n", holdChar ); diff --git a/code/game/g_breakable.cpp b/code/game/g_breakable.cpp index ae7c860e44..ae3ffeeaa3 100644 --- a/code/game/g_breakable.cpp +++ b/code/game/g_breakable.cpp @@ -1184,7 +1184,7 @@ void SP_misc_model_breakable( gentity_t *ent ) CacheChunkEffects( ent->material ); misc_model_breakable_init( ent ); - len = strlen( ent->model ) - 4; + len = static_cast(strlen( ent->model )) - 4; assert(ent->model[len]=='.');//we're expecting ".md3" strncpy( damageModel, ent->model, sizeof(damageModel) ); damageModel[len] = 0; //chop extension diff --git a/code/game/g_cmds.cpp b/code/game/g_cmds.cpp index f0a7a62a5a..31979cfe4c 100644 --- a/code/game/g_cmds.cpp +++ b/code/game/g_cmds.cpp @@ -77,7 +77,7 @@ char *ConcatArgs( int start ) { c = gi.argc(); for ( i = start ; i < c ; i++ ) { arg = gi.argv( i ); - tlen = strlen( arg ); + tlen = static_cast(strlen( arg )); if ( len + tlen >= MAX_STRING_CHARS - 1 ) { break; } @@ -582,7 +582,7 @@ Cmd_Where_f */ void Cmd_Where_f( gentity_t *ent ) { const char *s = gi.argv(1); - const int len = strlen(s); + const int len = static_cast(strlen(s)); gentity_t *check; if ( gi.argc () < 2 ) { diff --git a/code/game/g_itemLoad.cpp b/code/game/g_itemLoad.cpp index d0cca821d5..19ad1ba0b0 100644 --- a/code/game/g_itemLoad.cpp +++ b/code/game/g_itemLoad.cpp @@ -266,7 +266,7 @@ static void IT_ClassName(const char **holdBuf) return; } - len = strlen(tokenStr); + len = static_cast(strlen(tokenStr)); len++; if (len > 32) { @@ -290,7 +290,7 @@ static void IT_WorldModel(const char **holdBuf) return; } - len = strlen(tokenStr); + len = static_cast(strlen(tokenStr)); len++; if (len > 64) { @@ -541,7 +541,7 @@ static void IT_Icon(const char **holdBuf) return; } - len = strlen(tokenStr); + len = static_cast(strlen(tokenStr)); len++; if (len > 32) { @@ -618,7 +618,7 @@ static void IT_PickupSound(const char **holdBuf) return; } - len = strlen(tokenStr); + len = static_cast(strlen(tokenStr)); len++; if (len > 32) { diff --git a/code/game/g_misc_model.cpp b/code/game/g_misc_model.cpp index e73d224bf2..18a074cc58 100644 --- a/code/game/g_misc_model.cpp +++ b/code/game/g_misc_model.cpp @@ -41,7 +41,7 @@ void SetMiscModelModels( char *modelNameString, gentity_t *ent, qboolean damage_ if ( damage_model ) { - len = strlen( modelNameString ) - 4; // extract the extension + len = static_cast(strlen( modelNameString )) - 4; // extract the extension //Dead/damaged model strncpy( damageModel, modelNameString, len ); diff --git a/code/game/g_roff.cpp b/code/game/g_roff.cpp index 5dd6381f42..94ffabaef7 100644 --- a/code/game/g_roff.cpp +++ b/code/game/g_roff.cpp @@ -606,7 +606,7 @@ static qboolean G_InitRoff( char *file, unsigned char *data ) for( i = 0; i < LittleLong(hdr->mNumNotes); i++ ) { - size += strlen(ptr) + 1; + size += static_cast(strlen(ptr) + 1); ptr += strlen(ptr) + 1; } @@ -878,7 +878,7 @@ void G_SaveCachedRoffs() for ( i = 0; i < num_roffs; i++ ) { // Dump out the string length to make things a bit easier on the other end...heh heh. - len = strlen( roffs[i].fileName ) + 1; + len = static_cast(strlen( roffs[i].fileName ) + 1); saved_game.write_chunk( INT_ID('S', 'L', 'E', 'N'), diff --git a/code/game/g_savegame.cpp b/code/game/g_savegame.cpp index 0b3d0dbed4..cae2d89b1c 100644 --- a/code/game/g_savegame.cpp +++ b/code/game/g_savegame.cpp @@ -175,7 +175,7 @@ static int GetStringNum(const char *psString) } strList.push_back( psString ); - return strlen(psString) + 1; // this gives us the chunk length for the reader later + return static_cast(strlen(psString) + 1); // this gives us the chunk length for the reader later } static char *GetStringPtr(int iStrlen, char *psOriginal/*may be NULL*/) diff --git a/code/game/g_spawn.cpp b/code/game/g_spawn.cpp index d279621b0e..0d0fc99ebb 100644 --- a/code/game/g_spawn.cpp +++ b/code/game/g_spawn.cpp @@ -919,7 +919,7 @@ char *G_NewString( const char *string ) { return NULL; } - l = strlen(string) + 1; + l = static_cast(strlen(string) + 1); newb = (char *) G_Alloc( l ); @@ -1184,7 +1184,7 @@ char *G_AddSpawnVarToken( const char *string ) { int l; char *dest; - l = strlen( string ); + l = static_cast(strlen( string )); if ( numSpawnVarChars + l + 1 > MAX_SPAWN_VARS_CHARS ) { G_Error( "G_AddSpawnVarToken: MAX_SPAWN_VARS" ); } @@ -1509,17 +1509,17 @@ void SP_worldspawn( void ) { int lengthRed, lengthBlue, lengthGreen; Com_sprintf(temp, sizeof(temp), "ls_%dr", i); G_SpawnString( temp, defaultStyles[i][0], &s ); - lengthRed = strlen(s); + lengthRed = static_cast(strlen(s)); gi.SetConfigstring(CS_LIGHT_STYLES+((i+LS_STYLES_START)*3)+0, s); Com_sprintf(temp, sizeof(temp), "ls_%dg", i); G_SpawnString(temp, defaultStyles[i][1], &s); - lengthGreen = strlen(s); + lengthGreen = static_cast(strlen(s)); gi.SetConfigstring(CS_LIGHT_STYLES+((i+LS_STYLES_START)*3)+1, s); Com_sprintf(temp, sizeof(temp), "ls_%db", i); G_SpawnString(temp, defaultStyles[i][2], &s); - lengthBlue = strlen(s); + lengthBlue = static_cast(strlen(s)); gi.SetConfigstring(CS_LIGHT_STYLES+((i+LS_STYLES_START)*3)+2, s); if (lengthRed != lengthGreen || lengthGreen != lengthBlue) diff --git a/code/game/wp_saberLoad.cpp b/code/game/wp_saberLoad.cpp index 1b89f34b8f..efe0f741eb 100644 --- a/code/game/wp_saberLoad.cpp +++ b/code/game/wp_saberLoad.cpp @@ -2301,7 +2301,7 @@ void WP_SaberLoadParms( void ) holdChar = saberExtensionListBuf; for ( i = 0; i < fileCnt; i++, holdChar += saberExtFNLen + 1 ) { - saberExtFNLen = strlen( holdChar ); + saberExtFNLen = static_cast(strlen( holdChar )); len = gi.FS_ReadFile( va( "ext_data/sabers/%s", holdChar), (void **) &buffer ); From 6310a23df371f5e2d75abf2e64a75ea9468e6170 Mon Sep 17 00:00:00 2001 From: Jonathan Horner Date: Sat, 22 May 2021 22:06:34 +0100 Subject: [PATCH 04/10] More warnings --- code/icarus/BlockStream.cpp | 4 ++-- code/icarus/IcarusImplementation.cpp | 8 ++++---- code/icarus/Sequence.cpp | 2 +- code/icarus/TaskManager.cpp | 8 ++++---- code/mp3code/cupl3.c | 2 +- code/qcommon/cmd.cpp | 4 ++-- code/qcommon/common.cpp | 30 ++++++++++++++-------------- code/qcommon/cvar.cpp | 12 +++++------ code/qcommon/files.cpp | 28 +++++++++++++------------- code/qcommon/msg.cpp | 2 +- code/qcommon/net_chan.cpp | 2 +- code/qcommon/q_shared.cpp | 8 ++++---- code/qcommon/sstring.h | 2 +- code/qcommon/stringed_ingame.cpp | 16 +++++++-------- code/qcommon/z_memman_pc.cpp | 2 +- 15 files changed, 65 insertions(+), 65 deletions(-) diff --git a/code/icarus/BlockStream.cpp b/code/icarus/BlockStream.cpp index 3e94244c4e..c5c59314e8 100644 --- a/code/icarus/BlockStream.cpp +++ b/code/icarus/BlockStream.cpp @@ -94,7 +94,7 @@ SetData overloads void CBlockMember::SetData( const char *data , CIcarus* icarus) { - WriteDataPointer( data, strlen(data)+1, icarus ); + WriteDataPointer( data, static_cast(strlen(data)+1), icarus ); } void CBlockMember::SetData( vec3_t data , CIcarus* icarus) @@ -267,7 +267,7 @@ int CBlock::Write( int member_id, const char *member_data, CIcarus* icarus ) bMember->SetID( member_id ); bMember->SetData( member_data, icarus ); - bMember->SetSize( strlen(member_data) + 1 ); + bMember->SetSize( static_cast(strlen(member_data) + 1)); AddMember( bMember ); diff --git a/code/icarus/IcarusImplementation.cpp b/code/icarus/IcarusImplementation.cpp index ba17235ca1..ca6f357efe 100644 --- a/code/icarus/IcarusImplementation.cpp +++ b/code/icarus/IcarusImplementation.cpp @@ -440,7 +440,7 @@ int CIcarus::Run(int icarusID, char* buffer, long length) int CIcarus::SaveSequenceIDTable() { //Save out the number of sequences to follow - int numSequences = m_sequences.size(); + int numSequences = static_cast(m_sequences.size()); BufferWrite( &numSequences, sizeof( numSequences ) ); @@ -485,7 +485,7 @@ int CIcarus::SaveSequences() int CIcarus::SaveSequencers() { //Save out the number of sequences to follow - int numSequencers = m_sequencers.size(); + int numSequencers = static_cast(m_sequencers.size()); BufferWrite( &numSequencers, sizeof( numSequencers ) ); //The sequencers are then saved @@ -504,7 +504,7 @@ int CIcarus::SaveSequencers() int CIcarus::SaveSignals() { - int numSignals = m_signals.size(); + int numSignals = static_cast(m_signals.size()); //game->WriteSaveData( INT_ID('I','S','I','G'), &numSignals, sizeof( numSignals ) ); BufferWrite( &numSignals, sizeof( numSignals ) ); @@ -515,7 +515,7 @@ int CIcarus::SaveSignals() //game->WriteSaveData( INT_ID('I','S','I','G'), &numSignals, sizeof( numSignals ) ); const char *name = ((*si).first).c_str(); - int length = strlen( name ) + 1; + int length = static_cast(strlen( name ) + 1); //Save out the string size BufferWrite( &length, sizeof( length ) ); diff --git a/code/icarus/Sequence.cpp b/code/icarus/Sequence.cpp index bdfa249dc8..a9a09068d6 100644 --- a/code/icarus/Sequence.cpp +++ b/code/icarus/Sequence.cpp @@ -583,7 +583,7 @@ int CSequence::Save() pIcarus->BufferWrite( &id, sizeof( id ) ); //Save the number of children - int iNumChildren = m_children.size(); + int iNumChildren = static_cast(m_children.size()); pIcarus->BufferWrite( &iNumChildren, sizeof( iNumChildren ) ); //Save out the children (only by GUID) diff --git a/code/icarus/TaskManager.cpp b/code/icarus/TaskManager.cpp index 74f0b0494d..45d4033985 100644 --- a/code/icarus/TaskManager.cpp +++ b/code/icarus/TaskManager.cpp @@ -1715,7 +1715,7 @@ void CTaskManager::Save() pIcarus->BufferWrite( &m_GUID, sizeof( m_GUID ) ); //Save out the number of tasks that will follow - int iNumTasks = m_tasks.size(); + int iNumTasks = static_cast(m_tasks.size()); pIcarus->BufferWrite( &iNumTasks, sizeof( iNumTasks ) ); //Save out all the tasks @@ -1737,7 +1737,7 @@ void CTaskManager::Save() } //Save out the number of task groups - int numTaskGroups = m_taskGroups.size(); + int numTaskGroups = static_cast(m_taskGroups.size()); pIcarus->BufferWrite( &numTaskGroups, sizeof( numTaskGroups ) ); //Save out the IDs of all the task groups @@ -1760,7 +1760,7 @@ void CTaskManager::Save() pIcarus->BufferWrite( &id, sizeof( id ) ); //Save out the number of commands - numCommands = (*tgi)->m_completedTasks.size(); + numCommands = static_cast((*tgi)->m_completedTasks.size()); pIcarus->BufferWrite( &numCommands, sizeof( numCommands ) ); //Save out the command map @@ -1802,7 +1802,7 @@ void CTaskManager::Save() //Make sure this is a valid string assert( ( name != NULL ) && ( name[0] != '\0' ) ); - int length = strlen( name ) + 1; + int length = static_cast(strlen( name ) + 1); //Save out the string size //icarus->GetGame()->WriteSaveData( 'TGNL', &length, sizeof ( length ) ); diff --git a/code/mp3code/cupl3.c b/code/mp3code/cupl3.c index d3562f9eb4..2cb46f1b68 100644 --- a/code/mp3code/cupl3.c +++ b/code/mp3code/cupl3.c @@ -210,7 +210,7 @@ int bitget_bits_used() { int n; /* compute bits used from last init call */ - n = ((bitdat.bs_ptr - bitdat.bs_ptr0) << 3) - bitdat.bits; + n = (int)((bitdat.bs_ptr - bitdat.bs_ptr0) << 3) - bitdat.bits; return n; } /*------------- check for n bits in bitbuf -------------*/ diff --git a/code/qcommon/cmd.cpp b/code/qcommon/cmd.cpp index a918cd2633..175aaa6b46 100644 --- a/code/qcommon/cmd.cpp +++ b/code/qcommon/cmd.cpp @@ -92,7 +92,7 @@ Adds command text at the end of the buffer, does NOT add a final \n void Cbuf_AddText( const char *text ) { int l; - l = strlen (text); + l = static_cast(strlen (text)); if (cmd_text.cursize + l >= cmd_text.maxsize) { @@ -116,7 +116,7 @@ void Cbuf_InsertText( const char *text ) { int len; int i; - len = strlen( text ) + 1; + len = static_cast(strlen( text ) + 1); if ( len + cmd_text.cursize > cmd_text.maxsize ) { Com_Printf( "Cbuf_InsertText overflowed\n" ); return; diff --git a/code/qcommon/common.cpp b/code/qcommon/common.cpp index cb4fe06de2..27c272ff7c 100644 --- a/code/qcommon/common.cpp +++ b/code/qcommon/common.cpp @@ -147,7 +147,7 @@ void QDECL Com_Printf( const char *fmt, ... ) { rd_flush(rd_buffer); *rd_buffer = 0; } - Q_strcat (rd_buffer, strlen(rd_buffer), msg); + Q_strcat (rd_buffer, static_cast(strlen(rd_buffer)), msg); return; } @@ -172,7 +172,7 @@ void QDECL Com_Printf( const char *fmt, ... ) { } } if ( logfile ) { - FS_Write(msg, strlen(msg), logfile); + FS_Write(msg, static_cast(strlen(msg)), logfile); } } } @@ -522,7 +522,7 @@ Com_StringContains const char *Com_StringContains(const char *str1, const char *str2, int casesensitive) { int len, i, j; - len = strlen(str1) - strlen(str2); + len = static_cast(strlen(str1)) - static_cast(strlen(str2)); for (i = 0; i <= len; i++, str1++) { for (j = 0; str2[j]; j++) { if (casesensitive) { @@ -1473,7 +1473,7 @@ void Com_Frame( void ) { if(!speedslog) { speedslog = FS_FOpenFileWrite("speeds.log"); - FS_Write("data={\n", strlen("data={\n"), speedslog); + FS_Write("data={\n", static_cast(strlen("data={\n")), speedslog); bComma=false; if ( com_speedslog->integer > 1 ) { @@ -1488,17 +1488,17 @@ void Com_Frame( void ) { if(bComma) { - FS_Write(",\n", strlen(",\n"), speedslog); + FS_Write(",\n", static_cast(strlen(",\n")), speedslog); bComma=false; } - FS_Write("{", strlen("{"), speedslog); + FS_Write("{", static_cast(strlen("{")), speedslog); Com_sprintf(msg,sizeof(msg), "%8.4f,%8.4f,%8.4f,%8.4f,%8.4f,%8.4f,",corg[0],corg[1],corg[2],cangles[0],cangles[1],cangles[2]); - FS_Write(msg, strlen(msg), speedslog); + FS_Write(msg, static_cast(strlen(msg)), speedslog); Com_sprintf(msg,sizeof(msg), "%i,%3i,%3i,%3i,%3i,%3i,%3i,%3i,%3i,%3i}", com_frameNumber, all, sv, ev, cl, time_game, timeInTrace, timeInPVSCheck, time_frontend, time_backend); - FS_Write(msg, strlen(msg), speedslog); + FS_Write(msg, static_cast(strlen(msg)), speedslog); bComma=true; } } @@ -1566,7 +1566,7 @@ void Com_Shutdown (void) { } if (speedslog) { - FS_Write("\n};", strlen("\n};"), speedslog); + FS_Write("\n};", static_cast(strlen("\n};")), speedslog); FS_FCloseFile (speedslog); speedslog = 0; } @@ -1625,7 +1625,7 @@ FindMatches static void FindMatches( const char *s ) { int i; - if ( Q_stricmpn( s, completionString, strlen( completionString ) ) ) { + if ( Q_stricmpn( s, completionString, static_cast(strlen( completionString )) ) ) { return; } matchCount++; @@ -1654,7 +1654,7 @@ PrintMatches =============== */ static void PrintMatches( const char *s ) { - if ( !Q_stricmpn( s, shortestMatch, strlen( shortestMatch ) ) ) { + if ( !Q_stricmpn( s, shortestMatch, static_cast(strlen( shortestMatch )) ) ) { Com_Printf( S_COLOR_GREY "Cmd " S_COLOR_WHITE "%s\n", s ); } } @@ -1681,7 +1681,7 @@ PrintKeyMatches =============== */ static void PrintKeyMatches( const char *s ) { - if ( !Q_stricmpn( s, shortestMatch, strlen( shortestMatch ) ) ) { + if ( !Q_stricmpn( s, shortestMatch, static_cast(strlen( shortestMatch )) ) ) { Com_Printf( S_COLOR_GREY "Key " S_COLOR_WHITE "%s\n", s ); } } @@ -1693,7 +1693,7 @@ PrintFileMatches =============== */ static void PrintFileMatches( const char *s ) { - if ( !Q_stricmpn( s, shortestMatch, strlen( shortestMatch ) ) ) { + if ( !Q_stricmpn( s, shortestMatch, static_cast(strlen( shortestMatch )) ) ) { Com_Printf( S_COLOR_GREY "File " S_COLOR_WHITE "%s\n", s ); } } @@ -1738,11 +1738,11 @@ static qboolean Field_Complete( void ) { if ( matchCount == 0 ) return qtrue; - completionOffset = strlen( completionField->buffer ) - strlen( completionString ); + completionOffset = static_cast(strlen( completionField->buffer )) - static_cast(strlen( completionString )); Q_strncpyz( &completionField->buffer[completionOffset], shortestMatch, sizeof( completionField->buffer ) - completionOffset ); - completionField->cursor = strlen( completionField->buffer ); + completionField->cursor = static_cast(strlen( completionField->buffer )); if ( matchCount == 1 ) { Q_strcat( completionField->buffer, sizeof( completionField->buffer ), " " ); diff --git a/code/qcommon/cvar.cpp b/code/qcommon/cvar.cpp index 77d8e4b4a7..76f3f9b53b 100644 --- a/code/qcommon/cvar.cpp +++ b/code/qcommon/cvar.cpp @@ -998,7 +998,7 @@ void Cvar_WriteVariables( fileHandle_t f ) { } Com_sprintf (buffer, sizeof(buffer), "seta %s \"%s\"\n", var->name, var->string); } - FS_Write( buffer, strlen( buffer ), f ); + FS_Write( buffer, static_cast(strlen( buffer )), f ); } } } @@ -1396,7 +1396,7 @@ static void Cvar_Realloc(char **string, char *memPool, int &memPoolUsed) { char *temp = memPool + memPoolUsed; strcpy(temp, *string); - memPoolUsed += strlen(*string) + 1; + memPoolUsed += static_cast(strlen(*string) + 1); Cvar_FreeString(*string); *string = temp; } @@ -1413,16 +1413,16 @@ void Cvar_Defrag(void) for (var = cvar_vars; var; var = var->next) { if (var->name) { - totalMem += strlen(var->name) + 1; + totalMem += static_cast(strlen(var->name) + 1); } if (var->string) { - totalMem += strlen(var->string) + 1; + totalMem += static_cast(strlen(var->string) + 1); } if (var->resetString) { - totalMem += strlen(var->resetString) + 1; + totalMem += static_cast(strlen(var->resetString) + 1); } if (var->latchedString) { - totalMem += strlen(var->latchedString) + 1; + totalMem += static_cast(strlen(var->latchedString) + 1); } } diff --git a/code/qcommon/files.cpp b/code/qcommon/files.cpp index c35d0e00f5..45f5356b3b 100644 --- a/code/qcommon/files.cpp +++ b/code/qcommon/files.cpp @@ -1124,7 +1124,7 @@ qboolean FS_IsExt(const char *filename, const char *ext, int namelen) { int extlen; - extlen = strlen(ext); + extlen = static_cast(strlen(ext)); if(extlen > namelen) return qfalse; @@ -1500,7 +1500,7 @@ int FS_Read( void *buffer, int len, fileHandle_t f ) { tries = 0; while (remaining) { block = remaining; - read = fread (buf, 1, block, fsh[f].handleFiles.file.o); + read = static_cast(fread (buf, 1, block, fsh[f].handleFiles.file.o)); if (read == 0) { // we might have been trying to read from a CD, which // sometimes returns a 0 read on windows @@ -1551,7 +1551,7 @@ int FS_Write( const void *buffer, int len, fileHandle_t h ) { tries = 0; while (remaining) { block = remaining; - written = fwrite (buf, 1, block, f); + written = static_cast(fwrite (buf, 1, block, f)); if (written == 0) { if (!tries) { tries = 1; @@ -1584,7 +1584,7 @@ void QDECL FS_Printf( fileHandle_t h, const char *fmt, ... ) { Q_vsnprintf (msg, sizeof(msg), fmt, argptr); va_end (argptr); - FS_Write(msg, strlen(msg), h); + FS_Write(msg, static_cast(strlen(msg)), h); } #define PK3_SEEK_BUFFER_SIZE 65536 @@ -1891,7 +1891,7 @@ static pack_t *FS_LoadZipFile( const char *zipfile, const char *basename ) if (err != UNZ_OK) { break; } - len += strlen(filename_inzip) + 1; + len += static_cast(strlen(filename_inzip) + 1); unzGoToNextFile(uf); } @@ -1907,8 +1907,8 @@ static pack_t *FS_LoadZipFile( const char *zipfile, const char *basename ) } } - pack = (pack_t *)Z_Malloc( sizeof( pack_t ) + i * sizeof(fileInPack_t *), TAG_FILESYS, qtrue ); - pack->hashSize = i; + pack = (pack_t *)Z_Malloc( static_cast(sizeof( pack_t ) + i * sizeof(fileInPack_t *)), TAG_FILESYS, qtrue ); + pack->hashSize = static_cast(i); pack->hashTable = (fileInPack_t **) (((char *) pack) + sizeof( pack_t )); for(int j = 0; j < pack->hashSize; j++) { pack->hashTable[j] = NULL; @@ -2058,11 +2058,11 @@ char **FS_ListFilteredFiles( const char *path, const char *extension, char *filt extension = ""; } - pathLength = strlen( path ); + pathLength = static_cast(strlen( path )); if ( path[pathLength-1] == '\\' || path[pathLength-1] == '/' ) { pathLength--; } - extensionLength = strlen( extension ); + extensionLength = static_cast(strlen( extension )); nfiles = 0; FS_ReturnPath(path, zpath, &pathDepth); @@ -2098,7 +2098,7 @@ char **FS_ListFilteredFiles( const char *path, const char *extension, char *filt } // check for extension match - length = strlen( name ); + length = static_cast(strlen( name )); if ( length < extensionLength ) { continue; } @@ -2200,7 +2200,7 @@ int FS_GetFileList( const char *path, const char *extension, char *listbuf, int pFiles = FS_ListFiles(path, extension, &nFiles); for (i =0; i < nFiles; i++) { - nLen = strlen(pFiles[i]) + 1; + nLen = static_cast(strlen(pFiles[i]) + 1); if (nTotal + nLen + 1 < bufsize) { strcpy(listbuf, pFiles[i]); listbuf += nLen; @@ -2368,7 +2368,7 @@ int FS_GetModList( char *listbuf, int bufsize ) { if (nPaks > 0) { bool isBase = !Q_stricmp( name, BASEGAME ); - nLen = isBase ? 1 : strlen(name) + 1; + nLen = isBase ? 1 : static_cast(strlen(name) + 1); // nLen is the length of the mod path // we need to see if there is a description available descPath[0] = '\0'; @@ -2379,7 +2379,7 @@ int FS_GetModList( char *listbuf, int bufsize ) { FILE *file; file = FS_FileForHandle(descHandle); Com_Memset( descPath, 0, sizeof( descPath ) ); - nDescLen = fread(descPath, 1, 48, file); + nDescLen = static_cast(fread(descPath, 1, 48, file)); if (nDescLen >= 0) { descPath[nDescLen] = '\0'; } @@ -2389,7 +2389,7 @@ int FS_GetModList( char *listbuf, int bufsize ) { } else { strcpy(descPath, name); } - nDescLen = strlen(descPath) + 1; + nDescLen = static_cast(strlen(descPath) + 1); if (nTotal + nLen + 1 + nDescLen + 1 < bufsize) { if ( isBase ) diff --git a/code/qcommon/msg.cpp b/code/qcommon/msg.cpp index 8740abe380..a2671590f7 100644 --- a/code/qcommon/msg.cpp +++ b/code/qcommon/msg.cpp @@ -254,7 +254,7 @@ void MSG_WriteString( msg_t *sb, const char *s ) { int l, i; char string[MAX_STRING_CHARS]; - l = strlen( s ); + l = static_cast(strlen( s )); if ( l >= MAX_STRING_CHARS ) { Com_Printf( "MSG_WriteString: MAX_STRING_CHARS" ); MSG_WriteData (sb, "", 1); diff --git a/code/qcommon/net_chan.cpp b/code/qcommon/net_chan.cpp index 79bc3336ea..1c7c205010 100644 --- a/code/qcommon/net_chan.cpp +++ b/code/qcommon/net_chan.cpp @@ -567,7 +567,7 @@ void QDECL NET_OutOfBandPrint( netsrc_t sock, netadr_t adr, const char *format, va_end( argptr ); // send the datagram - NET_SendPacket( sock, strlen( string ), string, adr ); + NET_SendPacket( sock, static_cast(strlen( string )), string, adr ); } diff --git a/code/qcommon/q_shared.cpp b/code/qcommon/q_shared.cpp index 6eb1a67097..74250a57a9 100644 --- a/code/qcommon/q_shared.cpp +++ b/code/qcommon/q_shared.cpp @@ -87,8 +87,8 @@ qboolean COM_CompareExtension(const char *in, const char *ext) { int inlen, extlen; - inlen = strlen(in); - extlen = strlen(ext); + inlen = static_cast(strlen(in)); + extlen = static_cast(strlen(ext)); if(extlen <= inlen) { @@ -617,7 +617,7 @@ int Com_HexStrToInt( const char *str ) n += digit; } - return n; + return static_cast(n); } return -1; @@ -680,7 +680,7 @@ Assumes buffer is atleast TRUNCATE_LENGTH big ============ */ void Com_TruncateLongString( char *buffer, const char *s ) { - int length = strlen( s ); + int length = static_cast(strlen( s )); if ( length <= TRUNCATE_LENGTH ) Q_strncpyz( buffer, s, TRUNCATE_LENGTH ); diff --git a/code/qcommon/sstring.h b/code/qcommon/sstring.h index a3ca6695ae..aaff0ff8ec 100644 --- a/code/qcommon/sstring.h +++ b/code/qcommon/sstring.h @@ -110,7 +110,7 @@ class sstring } int length() const { - return strlen(mStorage.data); + return static_cast(strlen(mStorage.data)); } bool operator==(const sstring &o) const { diff --git a/code/qcommon/stringed_ingame.cpp b/code/qcommon/stringed_ingame.cpp index 145706fb96..3c898e9fd5 100644 --- a/code/qcommon/stringed_ingame.cpp +++ b/code/qcommon/stringed_ingame.cpp @@ -270,7 +270,7 @@ void CStringEdPackage::SetupNewFileParse( const char *psFileName, SE_BOOL bLoadD // SE_BOOL CStringEdPackage::CheckLineForKeyword( const char *psKeyword, const char *&psLine) { - if (!Q_stricmpn(psKeyword, psLine, strlen(psKeyword)) ) + if (!Q_stricmpn(psKeyword, psLine, static_cast(strlen(psKeyword))) ) { psLine += strlen(psKeyword); @@ -294,7 +294,7 @@ const char *CStringEdPackage::ConvertCRLiterals_Read( const char *psString ) static std::string str; str = psString; int iLoc; - while ( (iLoc = str.find("\\n")) != -1 ) + while ( (iLoc = static_cast(str.find("\\n"))) != -1 ) { str[iLoc ] = '\n'; str.erase( iLoc+1,1 ); @@ -337,7 +337,7 @@ void CStringEdPackage::REMKill( char *psBuffer ) // if (psScanPos[0]) // any strlen? (else access violation with -1 below) { - int iWhiteSpaceScanPos = strlen(psScanPos)-1; + int iWhiteSpaceScanPos = static_cast(strlen(psScanPos))-1; while (iWhiteSpaceScanPos>=0 && isspace(psScanPos[iWhiteSpaceScanPos])) { psScanPos[iWhiteSpaceScanPos--] = '\0'; @@ -386,7 +386,7 @@ SE_BOOL CStringEdPackage::ReadLine( const char *&psParsePos, char *psDest ) // if (psDest[0]) { - int iWhiteSpaceScanPos = strlen(psDest)-1; + int iWhiteSpaceScanPos = static_cast(strlen(psDest))-1; while (iWhiteSpaceScanPos>=0 && isspace(psDest[iWhiteSpaceScanPos])) { psDest[iWhiteSpaceScanPos--] = '\0'; @@ -499,7 +499,7 @@ void CStringEdPackage::AddFlagReference( const char *psLocalReference, const cha // static char *CopeWithDumbStringData( const char *psSentence, const char *psThisLanguage ) { - const int iBufferSize = strlen(psSentence)*3; // *3 to allow for expansion of anything even stupid string consisting entirely of elipsis chars + const int iBufferSize = static_cast(strlen(psSentence)*3); // *3 to allow for expansion of anything even stupid string consisting entirely of elipsis chars char *psNewString = (char *) Z_Malloc(iBufferSize, TAG_TEMP_WORKSPACE, qfalse); Q_strncpyz(psNewString, psSentence, iBufferSize); @@ -663,7 +663,7 @@ const char *CStringEdPackage::ParseLine( const char *psLine ) m_bEndMarkerFound_ParseOnly = SE_TRUE; // the only major error checking I bother to do (for file truncation) } else - if (!Q_stricmpn(sSE_KEYWORD_LANG, psLine, strlen(sSE_KEYWORD_LANG))) + if (!Q_stricmpn(sSE_KEYWORD_LANG, psLine, static_cast(strlen(sSE_KEYWORD_LANG)))) { // LANG_ENGLISH "GUARD: Good to see you, sir. Taylor is waiting for you in the clean tent. We need to get you suited up. " // @@ -1061,7 +1061,7 @@ int SE_GetFlags ( const char *psPackageAndStringReference ) int SE_GetNumFlags( void ) { - return TheStringPackage.m_vstrFlagNames.size(); + return static_cast(TheStringPackage.m_vstrFlagNames.size()); } const char *SE_GetFlagName( int iFlagIndex ) @@ -1135,7 +1135,7 @@ int SE_GetNumLanguages(void) } } - return gvLanguagesAvailable.size(); + return static_cast(gvLanguagesAvailable.size()); } // SE_GetNumLanguages() must have been called before this... diff --git a/code/qcommon/z_memman_pc.cpp b/code/qcommon/z_memman_pc.cpp index b2cab8b793..d9a1596ee2 100644 --- a/code/qcommon/z_memman_pc.cpp +++ b/code/qcommon/z_memman_pc.cpp @@ -974,7 +974,7 @@ char *CopyString( const char *in ) { } } - out = (char *) S_Malloc (strlen(in)+1); + out = (char *) S_Malloc (static_cast(strlen(in)+1)); strcpy (out, in); Z_Label(out,in); From 5202f66ae637514db522222580047e42d1641315 Mon Sep 17 00:00:00 2001 From: Jonathan Horner Date: Sat, 22 May 2021 22:07:06 +0100 Subject: [PATCH 05/10] More warnings. --- code/Rufl/hstring.cpp | 4 ++-- code/rd-common/tr_image_jpg.cpp | 6 +++--- code/rd-common/tr_image_png.cpp | 6 +++--- code/rd-vanilla/G2_API.cpp | 22 +++++++++++----------- code/rd-vanilla/G2_bolts.cpp | 22 +++++++++++----------- code/rd-vanilla/G2_bones.cpp | 16 ++++++++-------- code/rd-vanilla/G2_surfaces.cpp | 6 +++--- code/rd-vanilla/tr_draw.cpp | 2 +- code/rd-vanilla/tr_image.cpp | 2 +- code/rd-vanilla/tr_init.cpp | 10 +++++----- code/rd-vanilla/tr_model.cpp | 6 +++--- code/rd-vanilla/tr_shade_calc.cpp | 2 +- code/rd-vanilla/tr_skin.cpp | 2 +- code/rd-vanilla/tr_stl.cpp | 2 +- code/server/sv_main.cpp | 2 +- 15 files changed, 55 insertions(+), 55 deletions(-) diff --git a/code/Rufl/hstring.cpp b/code/Rufl/hstring.cpp index 0c328e8cf7..c996344f2d 100644 --- a/code/Rufl/hstring.cpp +++ b/code/Rufl/hstring.cpp @@ -154,7 +154,7 @@ const char* hstring::operator *(void) const //////////////////////////////////////////////////////////////////////////////////// int hstring::length() const { - return strlen(c_str()); + return static_cast(strlen(c_str())); } //////////////////////////////////////////////////////////////////////////////////// @@ -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(strlen(str)+1)); // +1 for null character } #ifdef _DEBUG mStr = (char*)Pool()[mHandle]; diff --git a/code/rd-common/tr_image_jpg.cpp b/code/rd-common/tr_image_jpg.cpp index a3ddb84a16..50b006a34f 100644 --- a/code/rd-common/tr_image_jpg.cpp +++ b/code/rd-common/tr_image_jpg.cpp @@ -513,7 +513,7 @@ size_t RE_SaveJPGToBuffer(byte *buffer, size_t bufSize, int quality, /* Step 2: specify data destination (eg, a file) */ /* Note: steps 2 and 3 can be done in either order. */ - jpegDest(&cinfo, buffer, bufSize); + jpegDest(&cinfo, buffer, static_cast(bufSize)); /* Step 3: set parameters for compression */ cinfo.image_width = image_width; /* image width and height, in pixels */ @@ -575,10 +575,10 @@ void RE_SaveJPG(const char * filename, int quality, int image_width, int image_h size_t bufSize; bufSize = image_width * image_height * 3; - out = (byte *) R_Malloc( bufSize, TAG_TEMP_WORKSPACE, qfalse ); + out = (byte *) R_Malloc( static_cast(bufSize), TAG_TEMP_WORKSPACE, qfalse ); bufSize = RE_SaveJPGToBuffer(out, bufSize, quality, image_width, image_height, image_buffer, padding, false); - ri.FS_WriteFile(filename, out, bufSize); + ri.FS_WriteFile(filename, out, static_cast(bufSize)); R_Free(out); } diff --git a/code/rd-common/tr_image_png.cpp b/code/rd-common/tr_image_png.cpp index 9d07a26d73..f72057138b 100644 --- a/code/rd-common/tr_image_png.cpp +++ b/code/rd-common/tr_image_png.cpp @@ -29,7 +29,7 @@ along with this program; if not, see . void user_write_data( png_structp png_ptr, png_bytep data, png_size_t length ) { fileHandle_t fp = *(fileHandle_t*)png_get_io_ptr( png_ptr ); - ri.FS_Write( data, length, fp ); + ri.FS_Write( data, static_cast(length), fp ); } void user_flush_data( png_structp png_ptr ) { //TODO: ri->FS_Flush? @@ -76,8 +76,8 @@ int RE_SavePNG( const char *filename, byte *buf, size_t width, size_t height, in png_set_IHDR (png_ptr, info_ptr, - width, - height, + static_cast(width), + static_cast(height), depth, PNG_COLOR_TYPE_RGB, PNG_INTERLACE_NONE, diff --git a/code/rd-vanilla/G2_API.cpp b/code/rd-vanilla/G2_API.cpp index 09bc27edc2..92d93c7a17 100644 --- a/code/rd-vanilla/G2_API.cpp +++ b/code/rd-vanilla/G2_API.cpp @@ -90,7 +90,7 @@ class ErrorReporter Com_DPrintf(mess); } - sprintf(mess,"****** %s Error Report End %d errors of %ld kinds******\n",mName.c_str(),total,mErrors.size()); + sprintf(mess,"****** %s Error Report End %d errors of %ld kinds******\n",mName.c_str(),total,static_cast(mErrors.size())); Com_DPrintf(mess); } int AnimTest(CGhoul2Info_v &ghoul2,const char *m,const char *, int line) @@ -373,7 +373,7 @@ static size_t SerializeGhoul2Info ( char *buffer, const CGhoul2Info& g2Info ) buffer += blockSize; // Surfaces vector + size - *(int *)buffer = g2Info.mSlist.size(); + *(int *)buffer = static_cast(g2Info.mSlist.size()); buffer += sizeof (int); blockSize = g2Info.mSlist.size() * sizeof (surfaceInfo_t); @@ -381,7 +381,7 @@ static size_t SerializeGhoul2Info ( char *buffer, const CGhoul2Info& g2Info ) buffer += blockSize; // Bones vector + size - *(int *)buffer = g2Info.mBlist.size(); + *(int *)buffer = static_cast(g2Info.mBlist.size()); buffer += sizeof (int); blockSize = g2Info.mBlist.size() * sizeof (boneInfo_t); @@ -389,7 +389,7 @@ static size_t SerializeGhoul2Info ( char *buffer, const CGhoul2Info& g2Info ) buffer += blockSize; // Bolts vector + size - *(int *)buffer = g2Info.mBltlist.size(); + *(int *)buffer = static_cast(g2Info.mBltlist.size()); buffer += sizeof (int); blockSize = g2Info.mBltlist.size() * sizeof (boltInfo_t); @@ -466,8 +466,8 @@ class Ghoul2InfoArray : public IGhoul2InfoArray size_t i; for (i=0;i(MAX_G2_MODELS+i); + mFreeIndecies.push_back(static_cast(i)); } } @@ -498,7 +498,7 @@ class Ghoul2InfoArray : public IGhoul2InfoArray char *base = buffer; // Free indices - *(int *)buffer = mFreeIndecies.size(); + *(int *)buffer = static_cast(mFreeIndecies.size()); buffer += sizeof (int); std::copy (mFreeIndecies.begin(), mFreeIndecies.end(), (int *)buffer); @@ -511,7 +511,7 @@ class Ghoul2InfoArray : public IGhoul2InfoArray // Ghoul2 infos for ( size_t i = 0; i < MAX_G2_MODELS; i++ ) { - *(int *)buffer = mInfos[i].size(); + *(int *)buffer = static_cast(mInfos[i].size()); buffer += sizeof (int); for ( size_t j = 0; j < mInfos[i].size(); j++ ) @@ -564,7 +564,7 @@ class Ghoul2InfoArray : public IGhoul2InfoArray { #if G2API_DEBUG char mess[1000]; - sprintf(mess,"************************\nLeaked %ld ghoul2info slots\n", MAX_G2_MODELS - mFreeIndecies.size()); + sprintf(mess,"************************\nLeaked %ld ghoul2info slots\n", MAX_G2_MODELS - static_cast(mFreeIndecies.size())); Com_DPrintf(mess); #endif int i; @@ -579,7 +579,7 @@ class Ghoul2InfoArray : public IGhoul2InfoArray if (j==mFreeIndecies.end()) { #if G2API_DEBUG - sprintf(mess,"Leaked Info idx=%d id=%d sz=%ld\n", i, mIds[i], mInfos[i].size()); + sprintf(mess,"Leaked Info idx=%d id=%d sz=%ld\n", i, mIds[i], static_cast(mInfos[i].size())); Com_DPrintf(mess); if (mInfos[i].size()) { @@ -739,7 +739,7 @@ void RestoreGhoul2InfoArray() void SaveGhoul2InfoArray() { size_t size = singleton->GetSerializedSize(); - void *data = R_Malloc (size, TAG_GHOUL2, qfalse); + void *data = R_Malloc (static_cast(size), TAG_GHOUL2, qfalse); #ifdef _DEBUG size_t written = #endif // _DEBUG diff --git a/code/rd-vanilla/G2_bolts.cpp b/code/rd-vanilla/G2_bolts.cpp index 24852190d9..887088ea58 100644 --- a/code/rd-vanilla/G2_bolts.cpp +++ b/code/rd-vanilla/G2_bolts.cpp @@ -47,7 +47,7 @@ int G2_Find_Bolt_Bone_Num(boltInfo_v &bltlist, const int boneNum) { if (bltlist[i].boneNumber == boneNum) { - return i; + return static_cast(i); } } @@ -63,7 +63,7 @@ int G2_Find_Bolt_Surface_Num(boltInfo_v &bltlist, const int surfaceNum, const in { if ((bltlist[i].surfaceNumber == surfaceNum) && ((bltlist[i].surfaceType & flags) == flags)) { - return i; + return static_cast(i); } } @@ -93,7 +93,7 @@ int G2_Add_Bolt_Surf_Num(CGhoul2Info *ghlInfo, boltInfo_v &bltlist, surfaceInfo_ { // increment the usage count bltlist[i].boltUsed++; - return i; + return static_cast(i); } } @@ -108,7 +108,7 @@ int G2_Add_Bolt_Surf_Num(CGhoul2Info *ghlInfo, boltInfo_v &bltlist, surfaceInfo_ bltlist[i].surfaceNumber = surfNum; bltlist[i].surfaceType = G2SURFACEFLAG_GENERATED; bltlist[i].boltUsed = 1; - return i; + return static_cast(i); } } @@ -118,7 +118,7 @@ int G2_Add_Bolt_Surf_Num(CGhoul2Info *ghlInfo, boltInfo_v &bltlist, surfaceInfo_ tempBolt.boneNumber = -1; tempBolt.boltUsed = 1; bltlist.push_back(tempBolt); - return bltlist.size()-1; + return static_cast(bltlist.size())-1; } @@ -148,7 +148,7 @@ int G2_Add_Bolt(CGhoul2Info *ghlInfo, boltInfo_v &bltlist, surfaceInfo_v &slist, { // increment the usage count bltlist[i].boltUsed++; - return i; + return static_cast(i); } } @@ -162,7 +162,7 @@ int G2_Add_Bolt(CGhoul2Info *ghlInfo, boltInfo_v &bltlist, surfaceInfo_v &slist, bltlist[i].surfaceNumber = surfNum; bltlist[i].boltUsed = 1; bltlist[i].surfaceType = 0; - return i; + return static_cast(i); } } @@ -172,7 +172,7 @@ int G2_Add_Bolt(CGhoul2Info *ghlInfo, boltInfo_v &bltlist, surfaceInfo_v &slist, tempBolt.boltUsed = 1; tempBolt.surfaceType = 0; bltlist.push_back(tempBolt); - return bltlist.size()-1; + return static_cast(bltlist.size())-1; } // no, check to see if it's a bone then @@ -210,7 +210,7 @@ int G2_Add_Bolt(CGhoul2Info *ghlInfo, boltInfo_v &bltlist, surfaceInfo_v &slist, { // increment the usage count bltlist[i].boltUsed++; - return i; + return static_cast(i); } } @@ -224,7 +224,7 @@ int G2_Add_Bolt(CGhoul2Info *ghlInfo, boltInfo_v &bltlist, surfaceInfo_v &slist, bltlist[i].boneNumber = x; bltlist[i].boltUsed = 1; bltlist[i].surfaceType = 0; - return i; + return static_cast(i); } } @@ -234,7 +234,7 @@ int G2_Add_Bolt(CGhoul2Info *ghlInfo, boltInfo_v &bltlist, surfaceInfo_v &slist, tempBolt.boltUsed = 1; tempBolt.surfaceType = 0; bltlist.push_back(tempBolt); - return bltlist.size()-1; + return static_cast(bltlist.size())-1; } diff --git a/code/rd-vanilla/G2_bones.cpp b/code/rd-vanilla/G2_bones.cpp index beb4bb309f..806ba5868a 100644 --- a/code/rd-vanilla/G2_bones.cpp +++ b/code/rd-vanilla/G2_bones.cpp @@ -75,7 +75,7 @@ int G2_Find_Bone(CGhoul2Info *ghlInfo, boneInfo_v &blist, const char *boneName) // if name is the same, we found it if (!Q_stricmp(skel->name, boneName)) { - return i; + return static_cast(i); } } #if _DEBUG @@ -141,7 +141,7 @@ int G2_Add_Bone (const model_t *mod, boneInfo_v &blist, const char *boneName) OutputDebugString(mess); } #endif - return i; + return static_cast(i); } } else @@ -159,7 +159,7 @@ int G2_Add_Bone (const model_t *mod, boneInfo_v &blist, const char *boneName) OutputDebugString(mess); } #endif - return i; + return static_cast(i); } } @@ -177,7 +177,7 @@ int G2_Add_Bone (const model_t *mod, boneInfo_v &blist, const char *boneName) OutputDebugString(mess); } #endif - return blist.size()-1; + return static_cast(blist.size())-1; } @@ -206,7 +206,7 @@ int G2_Find_Bone_In_List(boneInfo_v &blist, const int boneNum) { if (blist[i].boneNumber == boneNum) { - return i; + return static_cast(i); } } return -1; @@ -1208,7 +1208,7 @@ int G2_Find_Bone_Rag(CGhoul2Info *ghlInfo, boneInfo_v &blist, const char *boneNa // if name is the same, we found it if (!Q_stricmp(skel->name, boneName)) { - return i; + return static_cast(i); } } #if _DEBUG @@ -2050,7 +2050,7 @@ void G2_SetRagDollBullet(CGhoul2Info &ghoul2,const vec3_t rayStart,const vec3_t int i; int magicFactor13=150.0f; // squared radius multiplier for shot effects boneInfo_v &blist = ghoul2.mBlist; - for(i=blist.size()-1;i>=0;i--) + for(i=static_cast(blist.size())-1;i>=0;i--) { boneInfo_t &bone=blist[i]; if ((bone.flags & BONE_ANGLES_TOTAL)) @@ -2322,7 +2322,7 @@ static bool G2_RagDollSetup(CGhoul2Info &ghoul2,int frameNum,bool resetOrigin,co rag->resize(bone.boneNumber+1,0); } (*rag)[bone.boneNumber]=&bone; - ragBlistIndex[bone.boneNumber]=i; + ragBlistIndex[bone.boneNumber]=static_cast(i); bone.lastTimeUpdated=frameNum; if (resetOrigin) diff --git a/code/rd-vanilla/G2_surfaces.cpp b/code/rd-vanilla/G2_surfaces.cpp index e387baaedc..c57969ca71 100644 --- a/code/rd-vanilla/G2_surfaces.cpp +++ b/code/rd-vanilla/G2_surfaces.cpp @@ -94,7 +94,7 @@ const surfaceInfo_t *G2_FindOverrideSurface(int surfaceNum,const surfaceInfo_v & { if (surfaceList[i].surface>=0) { - QuickOverride.Set(surfaceList[i].surface,i); + QuickOverride.Set(surfaceList[i].surface,static_cast(i)); } } return NULL; @@ -178,7 +178,7 @@ const mdxmSurface_t *G2_FindSurface(CGhoul2Info *ghlInfo, surfaceInfo_v &slist, const mdxmHierarchyOffsets_t *surfIndexes = (mdxmHierarchyOffsets_t *)((byte *)ghlInfo->currentModel->mdxm + sizeof(mdxmHeader_t)); // first find if we already have this surface in the list - for (i = slist.size() - 1; i >= 0; i--) + for (i = static_cast(slist.size()) - 1; i >= 0; i--) { if ((slist[i].surface != 10000) && (slist[i].surface != -1)) { @@ -337,7 +337,7 @@ int G2_AddSurface(CGhoul2Info *ghoul2, int surfaceNumber, int polyNumber, float ghoul2->mSlist[i].genBarycentricJ = BarycentricJ; ghoul2->mSlist[i].genPolySurfaceIndex = ((polyNumber & 0xffff) << 16) | (surfaceNumber & 0xffff); ghoul2->mSlist[i].genLod = lod; - return i; + return static_cast(i); } qboolean G2_RemoveSurface(surfaceInfo_v &slist, const int index) diff --git a/code/rd-vanilla/tr_draw.cpp b/code/rd-vanilla/tr_draw.cpp index 9543a81e0d..5346b7a554 100644 --- a/code/rd-vanilla/tr_draw.cpp +++ b/code/rd-vanilla/tr_draw.cpp @@ -182,7 +182,7 @@ void RE_GetScreenShot(byte *buffer, int w, int h) // gamma correct if(glConfig.deviceSupportsGamma) - R_GammaCorrect(source + offset, memcount); + R_GammaCorrect(source + offset, static_cast(memcount)); // resample from source xScale = glConfig.vidWidth / (4.0*w); diff --git a/code/rd-vanilla/tr_image.cpp b/code/rd-vanilla/tr_image.cpp index 276698ec0b..40da2758f2 100644 --- a/code/rd-vanilla/tr_image.cpp +++ b/code/rd-vanilla/tr_image.cpp @@ -768,7 +768,7 @@ int giTextureBindNum = 1024; // will be set to this anyway at runtime, but wtf? int R_Images_StartIteration(void) { itAllocatedImages = AllocatedImages.begin(); - return AllocatedImages.size(); + return static_cast(AllocatedImages.size()); } image_t *R_Images_GetNextIteration(void) diff --git a/code/rd-vanilla/tr_init.cpp b/code/rd-vanilla/tr_init.cpp index 13c72e66ee..4d2854b8cd 100644 --- a/code/rd-vanilla/tr_init.cpp +++ b/code/rd-vanilla/tr_init.cpp @@ -819,7 +819,7 @@ byte *RB_ReadPixels(int x, int y, int width, int height, size_t *offset, int *pa padwidth = PAD(linelen, packAlign); // Allocate a few more bytes so that we can choose an alignment we like - buffer = (byte *) R_Malloc(padwidth * height + *offset + packAlign - 1, TAG_TEMP_WORKSPACE, qfalse); + buffer = (byte *) R_Malloc(static_cast(padwidth * height + *offset + packAlign) - 1, TAG_TEMP_WORKSPACE, qfalse); bufstart = (byte *)PADP((intptr_t) buffer + *offset, packAlign); qglReadPixels(x, y, width, height, GL_RGB, GL_UNSIGNED_BYTE, bufstart); @@ -883,9 +883,9 @@ void R_TakeScreenshot( int x, int y, int width, int height, char *fileName ) { // gamma correct if(glConfig.deviceSupportsGamma) - R_GammaCorrect(allbuf + offset, memcount); + R_GammaCorrect(allbuf + offset, static_cast(memcount)); - ri.FS_WriteFile(fileName, buffer, memcount + 18); + ri.FS_WriteFile(fileName, buffer, static_cast(memcount + 18)); R_Free(allbuf); } @@ -920,7 +920,7 @@ void R_TakeScreenshotJPEG( int x, int y, int width, int height, char *fileName ) // gamma correct if(glConfig.deviceSupportsGamma) - R_GammaCorrect(buffer + offset, memcount); + R_GammaCorrect(buffer + offset, static_cast(memcount)); RE_SaveJPG(fileName, r_screenshotJpegQuality->integer, width, height, buffer + offset, padlen); R_Free(buffer); @@ -1190,7 +1190,7 @@ void R_PrintLongString(const char *string) { char buffer[1024]; const char *p = string; - int remainingLength = strlen(string); + int remainingLength = static_cast(strlen(string)); while (remainingLength > 0) { diff --git a/code/rd-vanilla/tr_model.cpp b/code/rd-vanilla/tr_model.cpp index 9b2d74fdaa..c0022ff977 100644 --- a/code/rd-vanilla/tr_model.cpp +++ b/code/rd-vanilla/tr_model.cpp @@ -214,7 +214,7 @@ void *RE_RegisterModels_Malloc(int iSize, void *pvDiskBufferIfJustLoaded, const { // if we already had this model entry, then re-register all the shaders it wanted... // - const int iEntries = ModelBin.ShaderRegisterData.size(); + const int iEntries = static_cast(ModelBin.ShaderRegisterData.size()); for (int i=0; isize(); + int iModels = static_cast(CachedModels->size()); int iModel = 0; for (CachedModels_t::iterator itModel = CachedModels->begin(); itModel != CachedModels->end(); ++itModel,iModel++) @@ -913,7 +913,7 @@ static qboolean R_LoadMD3 (model_t *mod, int lod, void *buffer, const char *mod_ // strip off a trailing _1 or _2 // this is a crutch for q3data being a mess - j = strlen( surf->name ); + j = static_cast(strlen( surf->name )); if ( j > 2 && surf->name[j-2] == '_' ) { surf->name[j-2] = 0; } diff --git a/code/rd-vanilla/tr_shade_calc.cpp b/code/rd-vanilla/tr_shade_calc.cpp index 5df2dbef44..e097157138 100644 --- a/code/rd-vanilla/tr_shade_calc.cpp +++ b/code/rd-vanilla/tr_shade_calc.cpp @@ -324,7 +324,7 @@ void DeformText( const char *text ) { VectorScale( width, height[2] * -0.75f, width ); // determine the starting position - len = strlen( text ); + len = static_cast(strlen( text )); VectorMA( origin, (len-1), width, origin ); // clear the shader indexes diff --git a/code/rd-vanilla/tr_skin.cpp b/code/rd-vanilla/tr_skin.cpp index 48e474a881..383b84d384 100644 --- a/code/rd-vanilla/tr_skin.cpp +++ b/code/rd-vanilla/tr_skin.cpp @@ -189,7 +189,7 @@ int RE_GetAnimationCFG(const char *psCFGFilename, char *psDest, int iDestSize) Q_strncpyz(psDest,psText,iDestSize); } - return strlen(psText); + return static_cast(strlen(psText)); } return 0; diff --git a/code/rd-vanilla/tr_stl.cpp b/code/rd-vanilla/tr_stl.cpp index f3648d1b37..582ecd21b2 100644 --- a/code/rd-vanilla/tr_stl.cpp +++ b/code/rd-vanilla/tr_stl.cpp @@ -46,7 +46,7 @@ void ShaderEntryPtrs_Clear(void) int ShaderEntryPtrs_Size(void) { - return ShaderEntryPtrs.size(); + return static_cast(ShaderEntryPtrs.size()); } void ShaderEntryPtrs_Insert(const char *token, const char *p) diff --git a/code/server/sv_main.cpp b/code/server/sv_main.cpp index 88d41de144..19737db8b3 100644 --- a/code/server/sv_main.cpp +++ b/code/server/sv_main.cpp @@ -201,7 +201,7 @@ void SVC_Status( netadr_t from ) { score = 0; } Com_sprintf( player, sizeof( player ), "%i %i \"%s\"\n", score, cl->name ); - playerLength = strlen(player); + playerLength = static_cast(strlen(player)); if (statusLength + playerLength >= (int)sizeof(status) ) { break; // can't hold any more } From b45912fe47a3ef6a48ed8def28a26179b9a6dfc2 Mon Sep 17 00:00:00 2001 From: Jonathan Horner Date: Sat, 22 May 2021 22:07:30 +0100 Subject: [PATCH 06/10] More warnings. --- code/ui/ui_main.cpp | 10 +++++----- code/ui/ui_saber.cpp | 2 +- code/ui/ui_shared.cpp | 6 +++--- codemp/botlib/be_aas_bspq3.cpp | 6 +++--- codemp/botlib/be_ai_char.cpp | 6 +++--- codemp/botlib/be_ai_weight.cpp | 2 +- codemp/botlib/l_libvar.cpp | 6 +++--- codemp/game/bg_saga.c | 8 ++++---- codemp/qcommon/common.cpp | 14 +++++++------- 9 files changed, 30 insertions(+), 30 deletions(-) diff --git a/code/ui/ui_main.cpp b/code/ui/ui_main.cpp index d22926109d..5f392dab2d 100644 --- a/code/ui/ui_main.cpp +++ b/code/ui/ui_main.cpp @@ -566,7 +566,7 @@ static void UI_LoadMods() { numdirs = FS_GetFileList( "$modlist", "", dirlist, sizeof(dirlist) ); dirptr = dirlist; for( i = 0; i < numdirs; i++ ) { - dirlen = strlen( dirptr ) + 1; + dirlen = static_cast(strlen( dirptr ) + 1); descptr = dirptr + dirlen; uiInfo.modList[uiInfo.modCount].modName = String_Alloc(dirptr); uiInfo.modList[uiInfo.modCount].modDescr = String_Alloc(descptr); @@ -2469,7 +2469,7 @@ static void UI_BuildPlayerModel_List( qboolean inGameLoad ) uiInfo.playerSpecies = (playerSpeciesInfo_t *)malloc(uiInfo.playerSpeciesMax * sizeof(playerSpeciesInfo_t)); // iterate directory of all player models - numdirs = ui.FS_GetFileList("models/players", "/", dirlist, dirListSize ); + numdirs = ui.FS_GetFileList("models/players", "/", dirlist, static_cast(dirListSize) ); dirptr = dirlist; for (i=0; i(strlen(dirptr)); if (dirlen) { @@ -2549,7 +2549,7 @@ static void UI_BuildPlayerModel_List( qboolean inGameLoad ) if (f) ui.FS_FCloseFile(f); } - filelen = strlen(fileptr); + filelen = static_cast(strlen(fileptr)); COM_StripExtension(fileptr,skinname, sizeof(skinname)); if (IsImageFile(dirptr, skinname, (qboolean)(building != 0))) @@ -6495,7 +6495,7 @@ void ReadSaveDirectory (void) for ( i = 0; i < fileCnt; i++ ) { // strip extension - len = strlen( holdChar ); + len = static_cast(strlen( holdChar )); holdChar[len-4] = '\0'; if ( Q_stricmp("current",holdChar)!=0 ) diff --git a/code/ui/ui_saber.cpp b/code/ui/ui_saber.cpp index 9da09ca3cb..e25e4c058f 100644 --- a/code/ui/ui_saber.cpp +++ b/code/ui/ui_saber.cpp @@ -308,7 +308,7 @@ void UI_SaberLoadParms( void ) holdChar = saberExtensionListBuf; for ( i = 0; i < fileCnt; i++, holdChar += saberExtFNLen + 1 ) { - saberExtFNLen = strlen( holdChar ); + saberExtFNLen = static_cast(strlen( holdChar )); len = ui.FS_ReadFile( va( "ext_data/sabers/%s", holdChar), (void **) &buffer ); diff --git a/code/ui/ui_shared.cpp b/code/ui/ui_shared.cpp index 885d0e9019..c5dc80bcbe 100644 --- a/code/ui/ui_shared.cpp +++ b/code/ui/ui_shared.cpp @@ -1325,7 +1325,7 @@ const char *String_Alloc(const char *p) str = str->next; } - len = strlen(p); + len = static_cast(strlen(p)); if (len + strPoolIndex + 1 < STRING_POOL_SIZE) { int ph = strPoolIndex; @@ -6862,7 +6862,7 @@ int BindingIDFromName( const char *name ) { // iterate each command, set its default binding for ( i = 0; i < g_bindCount; i++ ) { if ( !Q_stricmp( name, g_bindCommands[i] ) ) - return i; + return static_cast(i); } return -1; } @@ -9754,7 +9754,7 @@ qboolean Item_TextField_HandleKey(itemDef_t *item, int key) memset(buff, 0, sizeof(buff)); DC->getCVarString(item->cvar, buff, sizeof(buff)); - len = strlen(buff); + len = static_cast(strlen(buff)); if (editPtr->maxChars && len > editPtr->maxChars) { len = editPtr->maxChars; diff --git a/codemp/botlib/be_aas_bspq3.cpp b/codemp/botlib/be_aas_bspq3.cpp index 522b8250e2..86d5d055e1 100644 --- a/codemp/botlib/be_aas_bspq3.cpp +++ b/codemp/botlib/be_aas_bspq3.cpp @@ -423,7 +423,7 @@ void AAS_ParseBSPEntities(void) return; } //end if StripDoubleQuotes(token.string); - epair->key = (char *) GetHunkMemory(strlen(token.string) + 1); + epair->key = (char *) GetHunkMemory(static_cast(strlen(token.string) + 1)); strcpy(epair->key, token.string); if (!PS_ExpectTokenType(script, TT_STRING, 0, &token)) { @@ -432,7 +432,7 @@ void AAS_ParseBSPEntities(void) return; } //end if StripDoubleQuotes(token.string); - epair->value = (char *) GetHunkMemory(strlen(token.string) + 1); + epair->value = (char *) GetHunkMemory(static_cast(strlen(token.string) + 1)); strcpy(epair->value, token.string); } //end while if (strcmp(token.string, "}")) @@ -482,7 +482,7 @@ void AAS_DumpBSPData(void) int AAS_LoadBSPFile(void) { AAS_DumpBSPData(); - bspworld.entdatasize = strlen(botimport.BSPEntityData()) + 1; + bspworld.entdatasize = static_cast(strlen(botimport.BSPEntityData()) + 1); bspworld.dentdata = (char *) GetClearedHunkMemory(bspworld.entdatasize); Com_Memcpy(bspworld.dentdata, botimport.BSPEntityData(), bspworld.entdatasize); AAS_ParseBSPEntities(); diff --git a/codemp/botlib/be_ai_char.cpp b/codemp/botlib/be_ai_char.cpp index 413d83e29c..08f831cf6b 100644 --- a/codemp/botlib/be_ai_char.cpp +++ b/codemp/botlib/be_ai_char.cpp @@ -203,7 +203,7 @@ void BotDefaultCharacteristics(bot_character_t *ch, bot_character_t *defaultch) else if (defaultch->c[i].type == CT_STRING) { ch->c[i].type = CT_STRING; - ch->c[i].value.string = (char *) GetMemory(strlen(defaultch->c[i].value.string)+1); + ch->c[i].value.string = (char *) GetMemory(static_cast(strlen(defaultch->c[i].value.string)+1)); strcpy(ch->c[i].value.string, defaultch->c[i].value.string); } //end else if } //end for @@ -307,7 +307,7 @@ bot_character_t *BotLoadCharacterFromFile(char *charfile, int skill) else if (token.type == TT_STRING) { StripDoubleQuotes(token.string); - ch->c[index].value.string = (char *)GetMemory(strlen(token.string)+1); + ch->c[index].value.string = (char *)GetMemory(static_cast(strlen(token.string)+1)); strcpy(ch->c[index].value.string, token.string); ch->c[index].type = CT_STRING; } //end else if @@ -558,7 +558,7 @@ int BotInterpolateCharacters(int handle1, int handle2, float desiredskill) else if (ch1->c[i].type == CT_STRING) { out->c[i].type = CT_STRING; - out->c[i].value.string = (char *) GetMemory(strlen(ch1->c[i].value.string)+1); + out->c[i].value.string = (char *) GetMemory(static_cast(strlen(ch1->c[i].value.string)+1)); strcpy(out->c[i].value.string, ch1->c[i].value.string); } //end else if } //end for diff --git a/codemp/botlib/be_ai_weight.cpp b/codemp/botlib/be_ai_weight.cpp index 6f5d74d235..0919c4d89d 100644 --- a/codemp/botlib/be_ai_weight.cpp +++ b/codemp/botlib/be_ai_weight.cpp @@ -357,7 +357,7 @@ weightconfig_t *ReadWeightConfig(char *filename) return NULL; } //end if StripDoubleQuotes(token.string); - config->weights[config->numweights].name = (char *) GetClearedMemory(strlen(token.string) + 1); + config->weights[config->numweights].name = (char *) GetClearedMemory(static_cast(strlen(token.string) + 1)); strcpy(config->weights[config->numweights].name, token.string); if (!PC_ExpectAnyToken(source, &token)) { diff --git a/codemp/botlib/l_libvar.cpp b/codemp/botlib/l_libvar.cpp index a27e93a762..91d21885ae 100644 --- a/codemp/botlib/l_libvar.cpp +++ b/codemp/botlib/l_libvar.cpp @@ -91,7 +91,7 @@ libvar_t *LibVarAlloc(char *var_name) v = (libvar_t *) GetMemory(sizeof(libvar_t)); Com_Memset(v, 0, sizeof(libvar_t)); - v->name = (char *) GetMemory(strlen(var_name)+1); + v->name = (char *) GetMemory(static_cast(strlen(var_name)+1)); strcpy(v->name, var_name); //add the variable in the list v->next = libvarlist; @@ -200,7 +200,7 @@ libvar_t *LibVar(char *var_name, char *value) //create new variable v = LibVarAlloc(var_name); //variable string - v->string = (char *) GetMemory(strlen(value) + 1); + v->string = (char *) GetMemory(static_cast(strlen(value) + 1)); strcpy(v->string, value); //the value v->value = LibVarStringValue(v->string); @@ -255,7 +255,7 @@ void LibVarSet(char *var_name, char *value) v = LibVarAlloc(var_name); } //end else //variable string - v->string = (char *) GetMemory(strlen(value) + 1); + v->string = (char *) GetMemory(static_cast(strlen(value) + 1)); strcpy(v->string, value); //the value v->value = LibVarStringValue(v->string); diff --git a/codemp/game/bg_saga.c b/codemp/game/bg_saga.c index d67e339d80..ce400a66f1 100644 --- a/codemp/game/bg_saga.c +++ b/codemp/game/bg_saga.c @@ -1035,11 +1035,11 @@ void BG_SiegeParseClassFile(const char *filename, siegeClassDesc_t *descBuffer) int titleLength, arrayTitleLength; char *holdBuf; - titleLength = strlen(parseBuf); + titleLength = (int)strlen(parseBuf); for (i=0;ititleLength) // Too long { break; @@ -1218,7 +1218,7 @@ void BG_SiegeLoadClasses(siegeClassDesc_t *descBuffer) for (i = 0; i < numFiles; i++, fileptr += filelen+1) { - filelen = strlen(fileptr); + filelen = (int)strlen(fileptr); Q_strncpyz(filename, "ext_data/Siege/Classes/", sizeof(filename)); Q_strcat(filename, sizeof(filename), fileptr); @@ -1352,7 +1352,7 @@ void BG_SiegeLoadTeams(void) for (i = 0; i < numFiles; i++, fileptr += filelen+1) { - filelen = strlen(fileptr); + filelen = (int)strlen(fileptr); Q_strncpyz(filename, "ext_data/Siege/Teams/", sizeof(filename)); Q_strcat(filename, sizeof(filename), fileptr); BG_SiegeParseTeamFile(filename); diff --git a/codemp/qcommon/common.cpp b/codemp/qcommon/common.cpp index 8cceb640e9..6c44c05f2c 100644 --- a/codemp/qcommon/common.cpp +++ b/codemp/qcommon/common.cpp @@ -183,7 +183,7 @@ void QDECL Com_Printf( const char *fmt, ... ) { } opening_qconsole = qfalse; if ( logfile && FS_Initialized()) { - FS_Write(msg, strlen(msg), logfile); + FS_Write(msg, static_cast(strlen(msg)), logfile); } } @@ -509,7 +509,7 @@ Com_StringContains char *Com_StringContains(char *str1, char *str2, int casesensitive) { int len, i, j; - len = strlen(str1) - strlen(str2); + len = static_cast(strlen(str1)) - static_cast(strlen(str2)); for (i = 0; i <= len; i++, str1++) { for (j = 0; str2[j]; j++) { if (casesensitive) { @@ -1723,7 +1723,7 @@ FindMatches static void FindMatches( const char *s ) { int i; - if ( Q_stricmpn( s, completionString, strlen( completionString ) ) ) { + if ( Q_stricmpn( s, completionString, static_cast(strlen( completionString )) ) ) { return; } matchCount++; @@ -1784,7 +1784,7 @@ PrintKeyMatches =============== */ static void PrintKeyMatches( const char *s ) { - if ( !Q_stricmpn( s, shortestMatch, strlen( shortestMatch ) ) ) { + if ( !Q_stricmpn( s, shortestMatch, static_cast(strlen( shortestMatch )) ) ) { Com_Printf( S_COLOR_GREY "Key " S_COLOR_WHITE "%s\n", s ); } } @@ -1797,7 +1797,7 @@ PrintFileMatches =============== */ static void PrintFileMatches( const char *s ) { - if ( !Q_stricmpn( s, shortestMatch, strlen( shortestMatch ) ) ) { + if ( !Q_stricmpn( s, shortestMatch, static_cast(strlen( shortestMatch )) ) ) { Com_Printf( S_COLOR_GREY "File " S_COLOR_WHITE "%s\n", s ); } } @@ -1845,11 +1845,11 @@ static qboolean Field_Complete( void ) { if ( matchCount == 0 ) return qtrue; - completionOffset = strlen( completionField->buffer ) - strlen( completionString ); + completionOffset = static_cast(strlen( completionField->buffer )) - static_cast(strlen( completionString )); Q_strncpyz( &completionField->buffer[completionOffset], shortestMatch, sizeof( completionField->buffer ) - completionOffset ); - completionField->cursor = strlen( completionField->buffer ); + completionField->cursor = static_cast(strlen( completionField->buffer )); if ( matchCount == 1 ) { Q_strcat( completionField->buffer, sizeof( completionField->buffer ), " " ); From 2c3fd419881e39425e8006750c47bddad8816068 Mon Sep 17 00:00:00 2001 From: Jonathan Horner Date: Sun, 23 May 2021 22:28:27 +0100 Subject: [PATCH 07/10] More warnings. --- codemp/botlib/l_precomp.cpp | 14 +++++++------- codemp/botlib/l_script.cpp | 4 ++-- codemp/botlib/l_struct.cpp | 2 +- codemp/cgame/cg_draw.c | 4 ++-- codemp/cgame/cg_drawtools.c | 2 +- codemp/cgame/cg_ents.c | 2 +- codemp/cgame/cg_event.c | 4 ++-- codemp/cgame/cg_light.c | 2 +- codemp/cgame/cg_main.c | 2 +- codemp/cgame/cg_players.c | 2 +- codemp/cgame/cg_servercmds.c | 4 ++-- codemp/cgame/cg_spawn.c | 2 +- codemp/client/cl_avi.cpp | 2 +- codemp/client/cl_cgame.cpp | 6 +++--- codemp/client/cl_console.cpp | 8 ++++---- codemp/client/cl_keys.cpp | 12 ++++++------ codemp/client/cl_main.cpp | 18 +++++++++--------- codemp/client/cl_parse.cpp | 2 +- codemp/client/cl_scrn.cpp | 2 +- codemp/client/snd_ambient.cpp | 8 ++++---- codemp/client/snd_dma.cpp | 2 +- codemp/client/snd_mem.cpp | 4 ++-- codemp/client/snd_mp3.cpp | 4 ++-- codemp/client/snd_music.cpp | 10 +++++----- 24 files changed, 61 insertions(+), 61 deletions(-) diff --git a/codemp/botlib/l_precomp.cpp b/codemp/botlib/l_precomp.cpp index 8089a56c0a..0ed1044aa3 100644 --- a/codemp/botlib/l_precomp.cpp +++ b/codemp/botlib/l_precomp.cpp @@ -704,7 +704,7 @@ void PC_AddBuiltinDefines(source_t *source) { define = (define_t *) GetMemory(sizeof(define_t)); Com_Memset(define, 0, sizeof(define_t)); - define->name = (char *) GetMemory(strlen(builtin[i].string) + 1); + define->name = (char *) GetMemory(static_cast(strlen(builtin[i].string) + 1)); strcpy(define->name, builtin[i].string); define->flags |= DEFINE_FIXED; define->builtin = builtin[i].mBuiltin; @@ -750,7 +750,7 @@ int PC_ExpandBuiltinDefine(source_t *source, token_t *deftoken, define_t *define { strcpy(token->string, source->scriptstack->filename); token->type = TT_NAME; - token->subtype = strlen(token->string); + token->subtype = static_cast(strlen(token->string)); *firsttoken = token; *lasttoken = token; break; @@ -765,7 +765,7 @@ int PC_ExpandBuiltinDefine(source_t *source, token_t *deftoken, define_t *define strcat(token->string, "\""); free(curtime); token->type = TT_NAME; - token->subtype = strlen(token->string); + token->subtype = static_cast(strlen(token->string)); *firsttoken = token; *lasttoken = token; break; @@ -779,7 +779,7 @@ int PC_ExpandBuiltinDefine(source_t *source, token_t *deftoken, define_t *define strcat(token->string, "\""); free(curtime); token->type = TT_NAME; - token->subtype = strlen(token->string); + token->subtype = static_cast(strlen(token->string)); *firsttoken = token; *lasttoken = token; break; @@ -1243,7 +1243,7 @@ int PC_Directive_define(source_t *source) //allocate define define = (define_t *) GetMemory(sizeof(define_t)); Com_Memset(define, 0, sizeof(define_t)); - define->name = (char *) GetMemory(strlen(token.string) + 1); + define->name = (char *) GetMemory(static_cast(strlen(token.string) + 1)); strcpy(define->name, token.string); //add the define to the source #if DEFINEHASHING @@ -1351,7 +1351,7 @@ define_t *PC_DefineFromString(char *string) PC_InitTokenHeap(); - script = LoadScriptMemory(string, strlen(string), "*extern"); + script = LoadScriptMemory(string, static_cast(strlen(string)), "*extern"); //create a new source Com_Memset(&src, 0, sizeof(source_t)); strncpy(src.filename, "*extern", MAX_PATH); @@ -1504,7 +1504,7 @@ define_t *PC_CopyDefine(source_t *source, define_t *define) newdefine = (define_t *) GetMemory(sizeof(define_t)); //copy the define name - newdefine->name = (char *) GetMemory(strlen(define->name) + 1); + newdefine->name = (char *) GetMemory(static_cast(strlen(define->name) + 1)); strcpy(newdefine->name, define->name); newdefine->flags = define->flags; newdefine->builtin = define->builtin; diff --git a/codemp/botlib/l_script.cpp b/codemp/botlib/l_script.cpp index 8be425b0c8..16ac72e2a0 100644 --- a/codemp/botlib/l_script.cpp +++ b/codemp/botlib/l_script.cpp @@ -804,7 +804,7 @@ int PS_ReadPunctuation(script_t *script, token_t *token) punc = &script->punctuations[i]; #endif //PUNCTABLE p = punc->p; - len = strlen(p); + len = static_cast(strlen(p)); //if the script contains at least as much characters as the punctuation if (script->script_p + len <= script->end_p) { @@ -1290,7 +1290,7 @@ int ScriptSkipTo(script_t *script, char *value) char firstchar; firstchar = *value; - len = strlen(value); + len = static_cast(strlen(value)); do { if (!PS_ReadWhiteSpace(script)) return 0; diff --git a/codemp/botlib/l_struct.cpp b/codemp/botlib/l_struct.cpp index bd8e0bfcce..3d698099ec 100644 --- a/codemp/botlib/l_struct.cpp +++ b/codemp/botlib/l_struct.cpp @@ -352,7 +352,7 @@ int WriteFloat(FILE *fp, float value) int l; Com_sprintf(buf, sizeof(buf), "%f", value); - l = strlen(buf); + l = static_cast(strlen(buf)); //strip any trailing zeros while(l-- > 1) { diff --git a/codemp/cgame/cg_draw.c b/codemp/cgame/cg_draw.c index 8b793c1593..618a235f0a 100644 --- a/codemp/cgame/cg_draw.c +++ b/codemp/cgame/cg_draw.c @@ -7361,8 +7361,8 @@ chatbox functionality -rww //place (assuming this will not overflow the buffer) void CG_ChatBox_StrInsert(char *buffer, int place, char *str) { - int insLen = strlen(str); - int i = strlen(buffer); + int insLen = (int)strlen(str); + int i = (int)strlen(buffer); int k = 0; buffer[i+insLen+1] = 0; //terminate the string at its new length diff --git a/codemp/cgame/cg_drawtools.c b/codemp/cgame/cg_drawtools.c index 8e6b9a2b91..134764ab4d 100644 --- a/codemp/cgame/cg_drawtools.c +++ b/codemp/cgame/cg_drawtools.c @@ -538,7 +538,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 = (int)strlen(num); if (l > width) l = width; diff --git a/codemp/cgame/cg_ents.c b/codemp/cgame/cg_ents.c index 531dd40038..057fbdd9f4 100644 --- a/codemp/cgame/cg_ents.c +++ b/codemp/cgame/cg_ents.c @@ -1390,7 +1390,7 @@ Ghoul2 Insert End if (cent->ghoul2 && trap->G2API_SkinlessModel(cent->ghoul2, 0)) { //well, you'd never want a skinless model, so try to get his skin... Q_strncpyz(skinName, modelName, MAX_QPATH); - l = strlen(skinName); + l = (int)strlen(skinName); while (l > 0 && skinName[l] != '/') { //parse back to first / l--; diff --git a/codemp/cgame/cg_event.c b/codemp/cgame/cg_event.c index 98d3992a7c..5e9e4f4b69 100644 --- a/codemp/cgame/cg_event.c +++ b/codemp/cgame/cg_event.c @@ -843,7 +843,7 @@ void CG_PrintCTFMessage(clientInfo_t *ci, const char *teamName, int ctfMessage) if (ci) { Com_sprintf(printMsg, sizeof(printMsg), "%s^7 ", ci->name); - strLen = strlen(printMsg); + strLen = (int)strlen(printMsg); } while (psStringEDString[i] && i < 512) @@ -853,7 +853,7 @@ void CG_PrintCTFMessage(clientInfo_t *ci, const char *teamName, int ctfMessage) { printMsg[strLen] = '\0'; Q_strcat(printMsg, sizeof(printMsg), teamName); - strLen = strlen(printMsg); + strLen = (int)strlen(printMsg); i++; } diff --git a/codemp/cgame/cg_light.c b/codemp/cgame/cg_light.c index 976ae03918..900a4d24d4 100644 --- a/codemp/cgame/cg_light.c +++ b/codemp/cgame/cg_light.c @@ -92,7 +92,7 @@ void CG_SetLightstyle (int i) int j, k; s = CG_ConfigString( i+CS_LIGHT_STYLES ); - j = strlen (s); + j = (int)strlen(s); if (j >= MAX_QPATH) { Com_Error (ERR_DROP, "svc_lightstyle length=%i", j); diff --git a/codemp/cgame/cg_main.c b/codemp/cgame/cg_main.c index 91d0204ae5..0404714cbb 100644 --- a/codemp/cgame/cg_main.c +++ b/codemp/cgame/cg_main.c @@ -1579,7 +1579,7 @@ void CG_BuildSpectatorString(void) { Q_strcat(cg.spectatorList, sizeof(cg.spectatorList), va("%s ", cgs.clientinfo[i].name)); } } - i = strlen(cg.spectatorList); + i = (int)strlen(cg.spectatorList); if (i != cg.spectatorLen) { cg.spectatorLen = i; cg.spectatorWidth = -1; diff --git a/codemp/cgame/cg_players.c b/codemp/cgame/cg_players.c index d9262deb87..a67851d8fd 100644 --- a/codemp/cgame/cg_players.c +++ b/codemp/cgame/cg_players.c @@ -705,7 +705,7 @@ static qboolean CG_RegisterClientModelname( clientInfo_t *ci, const char *modelN int j; char iconName[1024]; strcpy(iconName, "icon_"); - j = strlen(iconName); + j = (int)strlen(iconName); while (skinName[i] && skinName[i] != '|' && j < 1024) { iconName[j] = skinName[i]; diff --git a/codemp/cgame/cg_servercmds.c b/codemp/cgame/cg_servercmds.c index 82f4e20254..8317a6760e 100644 --- a/codemp/cgame/cg_servercmds.c +++ b/codemp/cgame/cg_servercmds.c @@ -1130,7 +1130,7 @@ void CG_CheckSVStringEdRef(char *buf, const char *str) strcpy(buf, str); - strLen = strlen(str); + strLen = (int)strlen(str); if (strLen >= MAX_STRINGED_SV_STRING) { @@ -1165,7 +1165,7 @@ void CG_CheckSVStringEdRef(char *buf, const char *str) buf[b] = 0; Q_strcat(buf, MAX_STRINGED_SV_STRING, CG_GetStringEdString("MP_SVGAME", stringRef)); - b = strlen(buf); + b = (int)strlen(buf); } } } diff --git a/codemp/cgame/cg_spawn.c b/codemp/cgame/cg_spawn.c index c10886394a..cb8ef27b97 100644 --- a/codemp/cgame/cg_spawn.c +++ b/codemp/cgame/cg_spawn.c @@ -348,7 +348,7 @@ char *CG_AddSpawnVarToken( const char *string ) { int l; char *dest; - l = strlen( string ); + l = (int)strlen( string ); if( cg.numSpawnVarChars + l + 1 > MAX_SPAWN_VARS_CHARS ) { trap->Error( ERR_DROP, "CG_AddSpawnVarToken: MAX_SPAWN_VARS_CHARS" ); } diff --git a/codemp/client/cl_avi.cpp b/codemp/client/cl_avi.cpp index 2a8c268390..60d1103eee 100644 --- a/codemp/client/cl_avi.cpp +++ b/codemp/client/cl_avi.cpp @@ -93,7 +93,7 @@ WRITE_STRING static QINLINE void WRITE_STRING( const char *s ) { Com_Memcpy( &buffer[ bufIndex ], s, strlen( s ) ); - bufIndex += strlen( s ); + bufIndex += static_cast(strlen( s )); } /* diff --git a/codemp/client/cl_cgame.cpp b/codemp/client/cl_cgame.cpp index 8d228f19bc..d03a0982bb 100644 --- a/codemp/client/cl_cgame.cpp +++ b/codemp/client/cl_cgame.cpp @@ -244,7 +244,7 @@ void CL_ConfigstringModified( void ) { continue; // leave with the default empty string } - len = strlen( dup ); + len = static_cast(strlen( dup )); if ( len + 1 + cl.gameState.dataCount > MAX_GAMESTATE_CHARS ) { Com_Error( ERR_DROP, "MAX_GAMESTATE_CHARS exceeded" ); @@ -314,7 +314,7 @@ void CL_CheckSVStringEdRef(char *buf, const char *str) strcpy(buf, str); - strLen = strlen(str); + strLen = static_cast(strlen(str)); if (strLen >= MAX_STRINGED_SV_STRING) { @@ -349,7 +349,7 @@ void CL_CheckSVStringEdRef(char *buf, const char *str) buf[b] = 0; Q_strcat(buf, MAX_STRINGED_SV_STRING, SE_GetString("MP_SVGAME", stringRef)); - b = strlen(buf); + b = static_cast(strlen(buf)); } } } diff --git a/codemp/client/cl_console.cpp b/codemp/client/cl_console.cpp index fa9e170bec..798d07ea49 100644 --- a/codemp/client/cl_console.cpp +++ b/codemp/client/cl_console.cpp @@ -242,7 +242,7 @@ void Con_Dump_f (void) #else Q_strcat(buffer, bufferlen, "\n"); #endif - FS_Write(buffer, strlen(buffer), f); + FS_Write(buffer, static_cast(strlen(buffer)), f); } Hunk_FreeTempMemory( buffer ); @@ -671,13 +671,13 @@ void Con_DrawNotify (void) { chattext = SE_GetString("MP_SVGAME", "SAY_TEAM"); SCR_DrawBigString (8, v, chattext, 1.0f, qfalse ); - skip = strlen(chattext)+1; + skip = static_cast(strlen(chattext)+1); } else { chattext = SE_GetString("MP_SVGAME", "SAY"); SCR_DrawBigString (8, v, chattext, 1.0f, qfalse ); - skip = strlen(chattext)+1; + skip = static_cast(strlen(chattext)+1); } Field_BigDraw( &chatField, skip * BIGCHAR_WIDTH, v, @@ -736,7 +736,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( JK_VERSION ); + i = static_cast(strlen( JK_VERSION )); for (x=0 ; xwidthInChars - 1; // - 1 so there is always a space for the cursor - len = strlen( edit->buffer ); + len = static_cast(strlen( edit->buffer )); // guarantee that cursor will be visible if ( len <= drawLen ) { @@ -463,7 +463,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(strlen( str )); if ( size == SMALLCHAR_WIDTH ) { SCR_DrawSmallChar( x + ( edit->cursor - prestep - i ) * size, y, cursorChar ); @@ -529,7 +529,7 @@ void Field_KeyDownEvent( field_t *edit, int key ) { } key = tolower( key ); - len = strlen( edit->buffer ); + len = static_cast(strlen( edit->buffer )); switch ( key ) { case A_DELETE: @@ -593,7 +593,7 @@ void Field_CharEvent( field_t *edit, int ch ) { return; } - len = strlen( edit->buffer ); + len = static_cast(strlen( edit->buffer )); if ( ch == 'h' - 'a' + 1 ) { // ctrl-h is backspace if ( edit->cursor > 0 ) { @@ -1105,7 +1105,7 @@ void Key_WriteBindings( fileHandle_t f ) { FS_Printf( f, "unbindall\n" ); for ( size_t i=0; i(i) ); // handle the escape character nicely if ( !strcmp( name, "\\" ) ) @@ -1125,7 +1125,7 @@ Key_Bindlist_f void Key_Bindlist_f( void ) { for ( size_t i=0; i(i) ), Key_KeynumToString( static_cast(i) ), kg.keys[i].binding ); } } diff --git a/codemp/client/cl_main.cpp b/codemp/client/cl_main.cpp index e540fd210c..66aabd87e5 100644 --- a/codemp/client/cl_main.cpp +++ b/codemp/client/cl_main.cpp @@ -1047,7 +1047,7 @@ void CL_Connect_f( void ) { Com_Printf( "%s resolved to %s\n", cls.servername, serverString ); if( cl_guidServerUniq->integer ) - CL_UpdateGUID( serverString, strlen( serverString ) ); + CL_UpdateGUID( serverString, static_cast(strlen( serverString )) ); else CL_UpdateGUID( NULL, 0 ); @@ -1135,7 +1135,7 @@ void CL_Rcon_f( void ) { } } - NET_SendPacket (NS_CLIENT, strlen(message)+1, message, rcon_address); + NET_SendPacket (NS_CLIENT, static_cast(strlen(message)+1), message, rcon_address); } /* @@ -1566,7 +1566,7 @@ void CL_CheckForResend( void ) { Info_SetValueForKey( info, "challenge", va("%i", clc.challenge ) ); Com_sprintf(data, sizeof(data), "connect \"%s\"", info ); - NET_OutOfBandData( NS_CLIENT, clc.serverAddress, (byte *)data, strlen(data) ); + NET_OutOfBandData( NS_CLIENT, clc.serverAddress, (byte *)data, static_cast(strlen(data)) ); // the most current userinfo has been sent, so watch for any // newer changes to userinfo variables @@ -1795,7 +1795,7 @@ static void CL_CheckSVStringEdRef(char *buf, const char *str) strcpy(buf, str); - strLen = strlen(str); + strLen = static_cast(strlen(str)); if (strLen >= MAX_STRINGED_SV_STRING) { @@ -1830,7 +1830,7 @@ static void CL_CheckSVStringEdRef(char *buf, const char *str) buf[b] = 0; Q_strcat(buf, MAX_STRINGED_SV_STRING, SE_GetString(va("MP_SVGAME_%s", stripRef))); - b = strlen(buf); + b = static_cast(strlen(buf)); } } } @@ -3215,7 +3215,7 @@ void CL_ServerStatusResponse( netadr_t from, msg_t *msg ) { } } - len = strlen(serverStatus->string); + len = static_cast(strlen(serverStatus->string)); Com_sprintf(&serverStatus->string[len], sizeof(serverStatus->string)-len, "\\"); if (serverStatus->print) { @@ -3224,7 +3224,7 @@ void CL_ServerStatusResponse( netadr_t from, msg_t *msg ) { } for (i = 0, s = MSG_ReadStringLine( msg ); *s; s = MSG_ReadStringLine( msg ), i++) { - len = strlen(serverStatus->string); + len = static_cast(strlen(serverStatus->string)); Com_sprintf(&serverStatus->string[len], sizeof(serverStatus->string)-len, "\\%s", s); if (serverStatus->print) { @@ -3240,7 +3240,7 @@ void CL_ServerStatusResponse( netadr_t from, msg_t *msg ) { Com_Printf("%-2d %-3d %-3d %s\n", i, score, ping, s ); } } - len = strlen(serverStatus->string); + len = static_cast(strlen(serverStatus->string)); Com_sprintf(&serverStatus->string[len], sizeof(serverStatus->string)-len, "\\"); serverStatus->time = Com_Milliseconds(); @@ -3288,7 +3288,7 @@ void CL_LocalServers_f( void ) { to.port = BigShort( (short)(PORT_SERVER + j) ); to.type = NA_BROADCAST; - NET_SendPacket( NS_CLIENT, strlen( message ), message, to ); + NET_SendPacket( NS_CLIENT, static_cast(strlen( message )), message, to ); } } } diff --git a/codemp/client/cl_parse.cpp b/codemp/client/cl_parse.cpp index 379c458ee1..7d08fced51 100644 --- a/codemp/client/cl_parse.cpp +++ b/codemp/client/cl_parse.cpp @@ -571,7 +571,7 @@ void CL_ParseGamestate( msg_t *msg ) { } */ - len = strlen( s ); + len = static_cast(strlen( s )); if ( len + 1 + cl.gameState.dataCount > MAX_GAMESTATE_CHARS ) { Com_Error( ERR_DROP, "MAX_GAMESTATE_CHARS exceeded" ); diff --git a/codemp/client/cl_scrn.cpp b/codemp/client/cl_scrn.cpp index d82d6c7c8a..ec2c35c1a8 100644 --- a/codemp/client/cl_scrn.cpp +++ b/codemp/client/cl_scrn.cpp @@ -321,7 +321,7 @@ void SCR_DrawDemoRecording( void ) { pos = FS_FTell( clc.demofile ); Com_sprintf( string, sizeof(string), "RECORDING %s: %ik", clc.demoName, pos / 1024 ); - SCR_DrawStringExt( 320 - strlen( string ) * 4, 20, 8, string, g_color_table[7], qtrue, qfalse ); + SCR_DrawStringExt( 320 - static_cast(strlen( string ) * 4), 20, 8, string, g_color_table[7], qtrue, qfalse ); } diff --git a/codemp/client/snd_ambient.cpp b/codemp/client/snd_ambient.cpp index 58096d9404..06acf7a0ef 100644 --- a/codemp/client/snd_ambient.cpp +++ b/codemp/client/snd_ambient.cpp @@ -319,7 +319,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((strlen(keywordNames[SET_KEYWORD_SUBWAVES])+1) + (strlen(dirBuffer)+1)); //Get all the subwaves while ( parsePos <= parseSize ) @@ -350,7 +350,7 @@ static void AS_GetSubWaves( ambientSet_t &set ) } //Move the pointer past this string - parsePos += strlen(waveBuffer)+1; + parsePos += static_cast(strlen(waveBuffer)+1); if ( ( (parseBuffer+parsePos)[0] == '\n') || ( (parseBuffer+parsePos)[0] == '\r') ) break; @@ -629,13 +629,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(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(strlen(name)+1); //Also take the following space out //Get the set name (this MUST be first) sscanf( parseBuffer+parsePos, "%s", tempBuffer ); diff --git a/codemp/client/snd_dma.cpp b/codemp/client/snd_dma.cpp index 23e1b39f09..f2c07fda81 100644 --- a/codemp/client/snd_dma.cpp +++ b/codemp/client/snd_dma.cpp @@ -3885,7 +3885,7 @@ void S_SoundList_f( void ) { qboolean bDumpThisOne = qtrue; if (iVariantCap >= 1 && iVariantCap <= 3) { - int iStrLen = strlen(sfx->sSoundName); + int iStrLen = static_cast(strlen(sfx->sSoundName)); if (iStrLen > 2) // crash-safety, jic. { char c = sfx->sSoundName[iStrLen-1]; diff --git a/codemp/client/snd_mem.cpp b/codemp/client/snd_mem.cpp index ba07a3356d..8080277ced 100644 --- a/codemp/client/snd_mem.cpp +++ b/codemp/client/snd_mem.cpp @@ -738,7 +738,7 @@ static qboolean S_LoadSound_Actual( sfx_t *sfx ) char *psExt; char sLoadName[MAX_QPATH]; - int len = strlen(sfx->sSoundName); + int len = static_cast(strlen(sfx->sSoundName)); if (len<5) { return qfalse; @@ -762,7 +762,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(strlen(sLoadName)); } if (!S_LoadSound_FileLoadAndNameAdjuster(sLoadName, &data, &size, len)) diff --git a/codemp/client/snd_mp3.cpp b/codemp/client/snd_mp3.cpp index 452d21082a..b29d20c666 100644 --- a/codemp/client/snd_mp3.cpp +++ b/codemp/client/snd_mp3.cpp @@ -196,7 +196,7 @@ qboolean MP3_ReadSpecialTagInfo(byte *pbLoadedFile, int iLoadedFileLen, // read MAXVOL key... // - if (Q_strncmp(pTAG->comment, sKEY_MAXVOL, strlen(sKEY_MAXVOL))) + if (Q_strncmp(pTAG->comment, sKEY_MAXVOL, static_cast(strlen(sKEY_MAXVOL)))) { qbError = qtrue; } @@ -211,7 +211,7 @@ qboolean MP3_ReadSpecialTagInfo(byte *pbLoadedFile, int iLoadedFileLen, // // read UNCOMP key... // - if (Q_strncmp(pTAG->album, sKEY_UNCOMP, strlen(sKEY_UNCOMP))) + if (Q_strncmp(pTAG->album, sKEY_UNCOMP, static_cast(strlen(sKEY_UNCOMP)))) { qbError = qtrue; } diff --git a/codemp/client/snd_music.cpp b/codemp/client/snd_music.cpp index 499190448e..22405f0996 100644 --- a/codemp/client/snd_music.cpp +++ b/codemp/client/snd_music.cpp @@ -230,7 +230,7 @@ static qboolean Music_ParseMusic(CGenericParser2 &Parser, MusicData_t *MusicData else if (!strcmp(psGroupName,sKEY_EXIT)) { - int iThisExitPointIndex = MusicFile.MusicExitPoints.size(); // must eval this first, so unaffected by push_back etc + int iThisExitPointIndex = static_cast(MusicFile.MusicExitPoints.size()); // must eval this first, so unaffected by push_back etc // // read this set of exit points... // @@ -251,7 +251,7 @@ static qboolean Music_ParseMusic(CGenericParser2 &Parser, MusicData_t *MusicData MusicExitPoint.sNextMark = psValue; } else - if (!Q_strncmp(psKey,sKEY_TIME,strlen(sKEY_TIME))) + if (!Q_strncmp(psKey,sKEY_TIME,static_cast(strlen(sKEY_TIME)))) { MusicExitTime_t MusicExitTime; MusicExitTime.fTime = atof(psValue); @@ -278,7 +278,7 @@ static qboolean Music_ParseMusic(CGenericParser2 &Parser, MusicData_t *MusicData } MusicFile.MusicExitPoints.push_back(MusicExitPoint); - int iNumExitPoints = MusicFile.MusicExitPoints.size(); + int iNumExitPoints = static_cast(MusicFile.MusicExitPoints.size()); // error checking... // @@ -381,7 +381,7 @@ static char *StripTrailingWhiteSpaceOnEveryLine(char *pText) do { bTrimmed = qfalse; - int iStrLen = strlen(sOneLine); + int iStrLen = static_cast(strlen(sOneLine)); if (iStrLen) { @@ -398,7 +398,7 @@ static char *StripTrailingWhiteSpaceOnEveryLine(char *pText) strNewText += "\n"; } - char *pNewText = (char *) Z_Malloc( strlen(strNewText.c_str())+1, TAG_TEMP_WORKSPACE, qfalse); + char *pNewText = (char *) Z_Malloc( static_cast(strlen(strNewText.c_str())+1), TAG_TEMP_WORKSPACE, qfalse); strcpy(pNewText, strNewText.c_str()); return pNewText; } From 61083c183b10815a31978ec3cd2d861f91164e36 Mon Sep 17 00:00:00 2001 From: Jonathan Horner Date: Sun, 23 May 2021 22:29:07 +0100 Subject: [PATCH 08/10] More warnings. --- codemp/Ratl/ratl_common.h | 2 +- codemp/game/NPC_stats.c | 2 +- codemp/game/ai_util.c | 4 +-- codemp/game/ai_wpnav.c | 2 +- codemp/game/bg_saberLoad.c | 2 +- codemp/game/bg_vehicleLoad.c | 6 ++--- codemp/game/g_bot.c | 6 ++--- codemp/game/g_client.c | 2 +- codemp/game/g_cmds.c | 6 ++--- codemp/game/g_main.c | 8 +++--- codemp/game/g_nav.c | 2 +- codemp/game/g_spawn.c | 12 ++++----- codemp/game/g_team.c | 2 +- codemp/game/g_utils.c | 6 ++--- codemp/icarus/BlockStream.cpp | 4 +-- codemp/icarus/GameInterface.cpp | 2 +- codemp/icarus/Instance.cpp | 8 +++--- codemp/qcommon/GenericParser2.cpp | 4 +-- codemp/qcommon/cmd.cpp | 4 +-- codemp/qcommon/cvar.cpp | 14 +++++----- codemp/qcommon/files.cpp | 42 +++++++++++++++--------------- codemp/qcommon/msg.cpp | 4 +-- codemp/qcommon/net_chan.cpp | 2 +- codemp/qcommon/net_ip.cpp | 4 +-- codemp/qcommon/q_shared.c | 6 ++--- codemp/qcommon/stringed_ingame.cpp | 16 ++++++------ codemp/qcommon/z_memman_pc.cpp | 2 +- codemp/rd-common/tr_image_jpg.cpp | 6 ++--- codemp/rd-common/tr_image_png.cpp | 6 ++--- codemp/rd-dedicated/G2_API.cpp | 2 +- codemp/rd-dedicated/G2_bolts.cpp | 32 +++++++++++------------ 31 files changed, 110 insertions(+), 110 deletions(-) diff --git a/codemp/Ratl/ratl_common.h b/codemp/Ratl/ratl_common.h index 2a0a47cd0f..ab62804387 100644 --- a/codemp/Ratl/ratl_common.h +++ b/codemp/Ratl/ratl_common.h @@ -215,7 +215,7 @@ namespace str { inline int len(const char *src) { - return strlen(src); + return static_cast(strlen(src)); } inline void cpy(char *dest,const char *src) diff --git a/codemp/game/NPC_stats.c b/codemp/game/NPC_stats.c index 4920ad8a68..56d9a05844 100644 --- a/codemp/game/NPC_stats.c +++ b/codemp/game/NPC_stats.c @@ -3578,7 +3578,7 @@ void NPC_LoadParms( void ) holdChar = npcExtensionListBuf; for ( i = 0; i < fileCnt; i++, holdChar += npcExtFNLen + 1 ) { - npcExtFNLen = strlen( holdChar ); + npcExtFNLen = (int)strlen( holdChar ); // Com_Printf( "Parsing %s\n", holdChar ); diff --git a/codemp/game/ai_util.c b/codemp/game/ai_util.c index 03dc9bb30a..88dd37dfb3 100644 --- a/codemp/game/ai_util.c +++ b/codemp/game/ai_util.c @@ -197,7 +197,7 @@ int GetValueGroup(char *buf, char *group, char *outbuf) return 0; } - startpoint = place - buf + strlen(group) + 1; + startpoint = place - buf + (int)strlen(group) + 1; startletter = (place - buf) - 1; failure = 0; @@ -289,7 +289,7 @@ int GetPairedValue(char *buf, char *key, char *outbuf) return 0; } //tab == 9 - startpoint = place - buf + strlen(key); + startpoint = place - buf + (int)strlen(key); startletter = (place - buf) - 1; found = 0; diff --git a/codemp/game/ai_wpnav.c b/codemp/game/ai_wpnav.c index 562fe75ffd..e72a57d932 100644 --- a/codemp/game/ai_wpnav.c +++ b/codemp/game/ai_wpnav.c @@ -2498,7 +2498,7 @@ int SavePathData(const char *filename) i++; } - trap->FS_Write(fileString, strlen(fileString), f); + trap->FS_Write(fileString, (int)strlen(fileString), f); B_TempFree(524288); //fileString B_TempFree(4096); //storeString diff --git a/codemp/game/bg_saberLoad.c b/codemp/game/bg_saberLoad.c index ae7460dc1c..26bd744090 100644 --- a/codemp/game/bg_saberLoad.c +++ b/codemp/game/bg_saberLoad.c @@ -2277,7 +2277,7 @@ void WP_SaberLoadParms( void ) holdChar = saberExtensionListBuf; for ( i=0; iFS_Open( va( "ext_data/sabers/%s", holdChar ), &f, FS_READ ); diff --git a/codemp/game/bg_vehicleLoad.c b/codemp/game/bg_vehicleLoad.c index a77d3dea0e..8ae2be4711 100644 --- a/codemp/game/bg_vehicleLoad.c +++ b/codemp/game/bg_vehicleLoad.c @@ -1296,7 +1296,7 @@ void BG_VehWeaponLoadParms( void ) for ( i = 0; i < fileCnt; i++, holdChar += vehExtFNLen + 1 ) { - vehExtFNLen = strlen( holdChar ); + vehExtFNLen = (int)strlen( holdChar ); // Com_Printf( "Parsing %s\n", holdChar ); @@ -1363,7 +1363,7 @@ void BG_VehicleLoadParms( void ) for ( i = 0; i < fileCnt; i++, holdChar += vehExtFNLen + 1 ) { - vehExtFNLen = strlen( holdChar ); + vehExtFNLen = (int)strlen( holdChar ); // Com_Printf( "Parsing %s\n", holdChar ); @@ -1430,7 +1430,7 @@ void BG_GetVehicleModelName(char *modelName, const char *vehicleName, size_t len if (vIndex == VEHICLE_NONE) Com_Error(ERR_DROP, "BG_GetVehicleModelName: couldn't find vehicle %s", vehName); - Q_strncpyz( modelName, g_vehicleInfo[vIndex].model, len ); + Q_strncpyz( modelName, g_vehicleInfo[vIndex].model, (int)len ); } void BG_GetVehicleSkinName(char *skinname, int len) diff --git a/codemp/game/g_bot.c b/codemp/game/g_bot.c index 474370b3cb..366a3b4b30 100644 --- a/codemp/game/g_bot.c +++ b/codemp/game/g_bot.c @@ -92,7 +92,7 @@ int G_ParseInfos( char *buf, int max, char *infos[] ) { Info_SetValueForKey( info, key, token ); } //NOTE: extra space for arena number - infos[count] = (char *) G_Alloc(strlen(info) + strlen("\\num\\") + strlen(va("%d", MAX_ARENAS)) + 1); + infos[count] = (char *) G_Alloc((int)(strlen(info) + strlen("\\num\\") + strlen(va("%d", MAX_ARENAS)) + 1)); if (infos[count]) { strcpy(infos[count], info); count++; @@ -348,7 +348,7 @@ void G_LoadArenas( void ) { numFiles = MAX_MAPS; for(; i < numFiles; i++) { - len = strlen(fileptr); + len = (int)strlen(fileptr); Com_sprintf(filename, sizeof(filename), "scripts/%s", fileptr); G_LoadArenasFromFile(filename); fileptr += len + 1; @@ -1241,7 +1241,7 @@ static void G_LoadBots( void ) { numdirs = trap->FS_GetFileList("scripts", ".bot", dirlist, 1024 ); dirptr = dirlist; for (i = 0; i < numdirs; i++, dirptr += dirlen+1) { - dirlen = strlen(dirptr); + dirlen = (int)strlen(dirptr); strcpy(filename, "scripts/"); strcat(filename, dirptr); G_LoadBotsFromFile(filename); diff --git a/codemp/game/g_client.c b/codemp/game/g_client.c index 0558003fa0..d801fa7986 100644 --- a/codemp/game/g_client.c +++ b/codemp/game/g_client.c @@ -1460,7 +1460,7 @@ void G_DebugWrite(const char *path, const char *text) fileHandle_t f; trap->FS_Open( path, &f, FS_APPEND ); - trap->FS_Write(text, strlen(text), f); + trap->FS_Write(text, (int)(strlen(text)), f); trap->FS_Close(f); } #endif diff --git a/codemp/game/g_cmds.c b/codemp/game/g_cmds.c index a8125ab990..fa6236fff3 100644 --- a/codemp/game/g_cmds.c +++ b/codemp/game/g_cmds.c @@ -92,7 +92,7 @@ void DeathmatchScoreboardMessage( gentity_t *ent ) { cl->ps.persistant[PERS_ASSIST_COUNT], perfect, cl->ps.persistant[PERS_CAPTURES]); - j = strlen(entry); + j = (int)strlen(entry); if (stringlength + j > 1022) break; strcpy (string + stringlength, entry); @@ -134,7 +134,7 @@ char *ConcatArgs( int start ) { c = trap->Argc(); for ( i = start ; i < c ; i++ ) { trap->Argv( i, arg, sizeof( arg ) ); - tlen = strlen( arg ); + tlen = (int)strlen( arg ); if ( len + tlen >= MAX_STRING_CHARS - 1 ) { break; } @@ -160,7 +160,7 @@ qboolean StringIsInteger( const char *s ) { int i=0, len=0; qboolean foundDigit=qfalse; - for ( i=0, len=strlen( s ); iFS_Write( string, strlen( string ), level.logFile ); + trap->FS_Write( string, (int)strlen( string ), level.logFile ); } /* ================= @@ -1541,7 +1541,7 @@ void QDECL G_SecurityLogPrintf( const char *fmt, ... ) { time( &rawtime ); localtime( &rawtime ); strftime( string, sizeof( string ), "[%Y-%m-%d] [%H:%M:%S] ", gmtime( &rawtime ) ); - timeLen = strlen( string ); + timeLen = (int)strlen( string ); va_start( argptr, fmt ); Q_vsnprintf( string+timeLen, sizeof( string ) - timeLen, fmt, argptr ); @@ -1553,7 +1553,7 @@ void QDECL G_SecurityLogPrintf( const char *fmt, ... ) { if ( !level.security.log ) return; - trap->FS_Write( string, strlen( string ), level.security.log ); + trap->FS_Write( string, (int)strlen( string ), level.security.log ); } /* diff --git a/codemp/game/g_nav.c b/codemp/game/g_nav.c index 7302127f8a..e31e43c8cc 100644 --- a/codemp/game/g_nav.c +++ b/codemp/game/g_nav.c @@ -1660,7 +1660,7 @@ qboolean NAV_WaypointsTooFar( gentity_t *wp1, gentity_t *wp2 ) {//they both have valid targetnames Com_sprintf( temp, sizeof(temp), S_COLOR_RED"Waypoint conn %s->%s > 1024\n", wp1->targetname, wp2->targetname ); } - len = strlen( temp ); + len = (int)strlen( temp ); if ( (fatalErrorPointer-fatalErrorString)+len >= sizeof( fatalErrorString ) ) { Com_Error( ERR_DROP, "%s%s%dTOO MANY FATAL NAV ERRORS!!!\n", fatalErrorString, temp, fatalErrors ); diff --git a/codemp/game/g_spawn.c b/codemp/game/g_spawn.c index 44f991b073..d232f9baa2 100644 --- a/codemp/game/g_spawn.c +++ b/codemp/game/g_spawn.c @@ -743,7 +743,7 @@ char *G_NewString( const char *string ) char *newb=NULL, *new_p=NULL; int i=0, len=0; - len = strlen( string )+1; + len = (int)(strlen( string )+1); new_p = newb = (char *)G_Alloc( len ); for ( i=0; i MAX_SPAWN_VARS_CHARS ) { trap->Error( ERR_DROP, "G_AddSpawnVarToken: MAX_SPAWN_VARS_CHARS" ); } @@ -1496,17 +1496,17 @@ void SP_worldspawn( void ) { Com_sprintf(temp, sizeof(temp), "ls_%dr", i); G_SpawnString(temp, defaultStyles[i][0], &text); - lengthRed = strlen(text); + lengthRed = (int)strlen(text); trap->SetConfigstring(CS_LIGHT_STYLES+((i+LS_STYLES_START)*3)+0, text); Com_sprintf(temp, sizeof(temp), "ls_%dg", i); G_SpawnString(temp, defaultStyles[i][1], &text); - lengthGreen = strlen(text); + lengthGreen = (int)strlen(text); trap->SetConfigstring(CS_LIGHT_STYLES+((i+LS_STYLES_START)*3)+1, text); Com_sprintf(temp, sizeof(temp), "ls_%db", i); G_SpawnString(temp, defaultStyles[i][2], &text); - lengthBlue = strlen(text); + lengthBlue = (int)strlen(text); trap->SetConfigstring(CS_LIGHT_STYLES+((i+LS_STYLES_START)*3)+2, text); if (lengthRed != lengthGreen || lengthGreen != lengthBlue) diff --git a/codemp/game/g_team.c b/codemp/game/g_team.c index 80032eaef0..82fd49017c 100644 --- a/codemp/game/g_team.c +++ b/codemp/game/g_team.c @@ -1249,7 +1249,7 @@ void TeamplayInfoMessage( gentity_t *ent ) { i, player->client->pers.teamState.location, h, a, player->client->ps.weapon, player->s.powerups ); } - j = strlen(entry); + j = (int)strlen(entry); if (stringlength + j >= sizeof(string)) break; strcpy (string + stringlength, entry); diff --git a/codemp/game/g_utils.c b/codemp/game/g_utils.c index bbda55a4c6..6d33ffff8e 100644 --- a/codemp/game/g_utils.c +++ b/codemp/game/g_utils.c @@ -753,7 +753,7 @@ static void G_SpewEntList(void) #ifdef _DEBUG if (fh) { - trap->FS_Write(str, strlen(str), fh); + trap->FS_Write(str, (int)strlen(str), fh); } #endif } @@ -771,7 +771,7 @@ static void G_SpewEntList(void) #ifdef _DEBUG if (fh) { - trap->FS_Write(str, strlen(str), fh); + trap->FS_Write(str, (int)strlen(str), fh); } #endif } @@ -784,7 +784,7 @@ static void G_SpewEntList(void) #ifdef _DEBUG if (fh) { - trap->FS_Write(str, strlen(str), fh); + trap->FS_Write(str, (int)strlen(str), fh); trap->FS_Close(fh); } #endif diff --git a/codemp/icarus/BlockStream.cpp b/codemp/icarus/BlockStream.cpp index 2c0398186a..74c2d387ee 100644 --- a/codemp/icarus/BlockStream.cpp +++ b/codemp/icarus/BlockStream.cpp @@ -88,7 +88,7 @@ SetData overloads void CBlockMember::SetData( const char *data ) { - WriteDataPointer( data, strlen(data)+1 ); + WriteDataPointer( data, static_cast(strlen(data)+1) ); } void CBlockMember::SetData( vector_t data ) @@ -268,7 +268,7 @@ int CBlock::Write( int member_id, const char *member_data ) bMember->SetID( member_id ); bMember->SetData( member_data ); - bMember->SetSize( strlen(member_data) + 1 ); + bMember->SetSize( static_cast(strlen(member_data) + 1) ); AddMember( bMember ); diff --git a/codemp/icarus/GameInterface.cpp b/codemp/icarus/GameInterface.cpp index d32b2bb964..a9e59eb55d 100644 --- a/codemp/icarus/GameInterface.cpp +++ b/codemp/icarus/GameInterface.cpp @@ -456,7 +456,7 @@ void ICARUS_InterrogateScript( const char *filename ) // char sFilename[MAX_FILENAME_LENGTH]; // should really be MAX_QPATH (and 64 bytes instead of 1024), but this fits the rest of the code - if (!Q_stricmpn(filename,Q3_SCRIPT_DIR,strlen(Q3_SCRIPT_DIR))) + if (!Q_stricmpn(filename,Q3_SCRIPT_DIR,static_cast(strlen(Q3_SCRIPT_DIR)))) { Q_strncpyz(sFilename,filename,sizeof(sFilename)); } diff --git a/codemp/icarus/Instance.cpp b/codemp/icarus/Instance.cpp index 58b32617f3..f01ee417c9 100644 --- a/codemp/icarus/Instance.cpp +++ b/codemp/icarus/Instance.cpp @@ -321,7 +321,7 @@ SaveSequenceIDTable int ICARUS_Instance::SaveSequenceIDTable( void ) { //Save out the number of sequences to follow - int numSequences = m_sequences.size(); + int numSequences = static_cast(m_sequences.size()); m_interface->I_WriteSaveData( INT_ID('#','S','E','Q'), &numSequences, sizeof( numSequences ) ); //Sequences are saved first, by ID and information @@ -376,7 +376,7 @@ SaveSequencers int ICARUS_Instance::SaveSequencers( void ) { //Save out the number of sequences to follow - int numSequencers = m_sequencers.size(); + int numSequencers = static_cast(m_sequencers.size()); m_interface->I_WriteSaveData( INT_ID('#','S','Q','R'), &numSequencers, sizeof( numSequencers ) ); //The sequencers are then saved @@ -397,7 +397,7 @@ SaveSignals int ICARUS_Instance::SaveSignals( void ) { - int numSignals = m_signals.size(); + int numSignals = static_cast(m_signals.size()); m_interface->I_WriteSaveData( INT_ID('I','S','I','G'), &numSignals, sizeof( numSignals ) ); @@ -410,7 +410,7 @@ int ICARUS_Instance::SaveSignals( void ) //Make sure this is a valid string assert( ( name != NULL ) && ( name[0] != '\0' ) ); - int length = strlen( name ) + 1; + int length = static_cast(strlen( name ) + 1); //Save out the string size m_interface->I_WriteSaveData( INT_ID('S','I','G','#'), &length, sizeof ( length ) ); diff --git a/codemp/qcommon/GenericParser2.cpp b/codemp/qcommon/GenericParser2.cpp index 37f7916bf4..2c7471b21f 100644 --- a/codemp/qcommon/GenericParser2.cpp +++ b/codemp/qcommon/GenericParser2.cpp @@ -192,7 +192,7 @@ CTextPool::~CTextPool(void) char *CTextPool::AllocText(char *text, bool addNULL, CTextPool **poolPtr) { - int length = strlen(text) + (addNULL ? 1 : 0); + int length = static_cast(strlen(text) + (addNULL ? 1 : 0)); if (mUsed + length + 1> mSize) { // extra 1 to put a null on the end @@ -822,7 +822,7 @@ CGPValue *CGPGroup::FindPair(const char *key) while(pair) { if (strlen(pair->GetName()) == length && - Q_stricmpn(pair->GetName(), pos, length) == 0) + Q_stricmpn(pair->GetName(), pos, static_cast(length)) == 0) { return pair; } diff --git a/codemp/qcommon/cmd.cpp b/codemp/qcommon/cmd.cpp index 102adf3139..a18e27f5a9 100644 --- a/codemp/qcommon/cmd.cpp +++ b/codemp/qcommon/cmd.cpp @@ -94,7 +94,7 @@ Adds command text at the end of the buffer, does NOT add a final \n void Cbuf_AddText( const char *text ) { int l; - l = strlen (text); + l = static_cast(strlen (text)); if (cmd_text.cursize + l >= cmd_text.maxsize) { @@ -118,7 +118,7 @@ void Cbuf_InsertText( const char *text ) { int len; int i; - len = strlen( text ) + 1; + len = static_cast(strlen( text ) + 1); if ( len + cmd_text.cursize > cmd_text.maxsize ) { Com_Printf( "Cbuf_InsertText overflowed\n" ); return; diff --git a/codemp/qcommon/cvar.cpp b/codemp/qcommon/cvar.cpp index 157cddeb2e..3b924dc9e3 100644 --- a/codemp/qcommon/cvar.cpp +++ b/codemp/qcommon/cvar.cpp @@ -1191,7 +1191,7 @@ void Cvar_WriteVariables( fileHandle_t f ) { } Com_sprintf (buffer, sizeof(buffer), "seta %s \"%s\"\n", var->name, var->string); } - FS_Write( buffer, strlen( buffer ), f ); + FS_Write( buffer, static_cast(strlen( buffer )), f ); } } } @@ -1625,7 +1625,7 @@ static void Cvar_Realloc(char **string, char *memPool, int &memPoolUsed) { char *temp = memPool + memPoolUsed; strcpy(temp, *string); - memPoolUsed += strlen(*string) + 1; + memPoolUsed += static_cast(strlen(*string) + 1); Cvar_FreeString(*string); *string = temp; } @@ -1642,19 +1642,19 @@ void Cvar_Defrag(void) for (var = cvar_vars; var; var = var->next) { if (var->name) { - totalMem += strlen(var->name) + 1; + totalMem += static_cast(strlen(var->name) + 1); } if (var->description) { - totalMem += strlen(var->description) + 1; + totalMem += static_cast(strlen(var->description) + 1); } if (var->string) { - totalMem += strlen(var->string) + 1; + totalMem += static_cast(strlen(var->string) + 1); } if (var->resetString) { - totalMem += strlen(var->resetString) + 1; + totalMem += static_cast(strlen(var->resetString) + 1); } if (var->latchedString) { - totalMem += strlen(var->latchedString) + 1; + totalMem += static_cast(strlen(var->latchedString) + 1); } } diff --git a/codemp/qcommon/files.cpp b/codemp/qcommon/files.cpp index 7077b2d4c3..9df632e7ca 100644 --- a/codemp/qcommon/files.cpp +++ b/codemp/qcommon/files.cpp @@ -1172,7 +1172,7 @@ qboolean FS_IsExt(const char *filename, const char *ext, int namelen) { int extlen; - extlen = strlen(ext); + extlen = static_cast(strlen(ext)); if(extlen > namelen) return qfalse; @@ -1394,7 +1394,7 @@ long FS_FOpenFileRead( const char *filename, fileHandle_t *file, qboolean unique // The x86.dll suffixes are needed in order for sv_pure to continue to // work on non-x86/windows systems... - l = strlen( filename ); + l = static_cast(strlen( filename )); if ( !(pak->referenced & FS_GENERAL_REF)) { if( !FS_IsExt(filename, ".shader", l) && !FS_IsExt(filename, ".txt", l) && @@ -1487,7 +1487,7 @@ long FS_FOpenFileRead( const char *filename, fileHandle_t *file, qboolean unique // if we are running restricted, the only files we // will allow to come from the directory are .cfg files - l = strlen( filename ); + l = static_cast(strlen( filename )); // FIXME TTimo I'm not sure about the fs_numServerPaks test // if you are using FS_ReadFile to find out if a file exists, // this test can make the search fail although the file is in the directory @@ -1672,7 +1672,7 @@ int FS_Read( void *buffer, int len, fileHandle_t f ) { tries = 0; while (remaining) { block = remaining; - read = fread (buf, 1, block, fsh[f].handleFiles.file.o); + read = static_cast(fread (buf, 1, block, fsh[f].handleFiles.file.o)); if (read == 0) { // we might have been trying to read from a CD, which // sometimes returns a 0 read on windows @@ -1723,7 +1723,7 @@ int FS_Write( const void *buffer, int len, fileHandle_t h ) { tries = 0; while (remaining) { block = remaining; - written = fwrite (buf, 1, block, f); + written = static_cast(fwrite (buf, 1, block, f)); if (written == 0) { if (!tries) { tries = 1; @@ -1755,7 +1755,7 @@ void QDECL FS_Printf( fileHandle_t h, const char *fmt, ... ) { Q_vsnprintf (msg, sizeof(msg), fmt, argptr); va_end (argptr); - FS_Write(msg, strlen(msg), h); + FS_Write(msg, static_cast(strlen(msg)), h); } #define PK3_SEEK_BUFFER_SIZE 65536 @@ -2123,7 +2123,7 @@ static pack_t *FS_LoadZipFile( const char *zipfile, const char *basename ) if (err != UNZ_OK) { break; } - len += strlen(filename_inzip) + 1; + len += static_cast(strlen(filename_inzip) + 1); unzGoToNextFile(uf); } @@ -2140,8 +2140,8 @@ static pack_t *FS_LoadZipFile( const char *zipfile, const char *basename ) } } - pack = (pack_t *)Z_Malloc( sizeof( pack_t ) + i * sizeof(fileInPack_t *), TAG_FILESYS, qtrue ); - pack->hashSize = i; + pack = (pack_t *)Z_Malloc( static_cast(sizeof( pack_t ) + i * sizeof(fileInPack_t *)), TAG_FILESYS, qtrue ); + pack->hashSize = static_cast(i); pack->hashTable = (fileInPack_t **) (((char *) pack) + sizeof( pack_t )); for(int j = 0; j < pack->hashSize; j++) { pack->hashTable[j] = NULL; @@ -2324,11 +2324,11 @@ char **FS_ListFilteredFiles( const char *path, const char *extension, char *filt extension = ""; } - pathLength = strlen( path ); + pathLength = static_cast(strlen( path )); if ( path[pathLength-1] == '\\' || path[pathLength-1] == '/' ) { pathLength--; } - extensionLength = strlen( extension ); + extensionLength = static_cast(strlen( extension )); nfiles = 0; FS_ReturnPath(path, zpath, &pathDepth); @@ -2371,7 +2371,7 @@ char **FS_ListFilteredFiles( const char *path, const char *extension, char *filt } // check for extension match - length = strlen( name ); + length = static_cast(strlen( name )); if ( length < extensionLength ) { continue; } @@ -2485,7 +2485,7 @@ int FS_GetFileList( const char *path, const char *extension, char *listbuf, int pFiles = FS_ListFiles(path, extension, &nFiles); for (i =0; i < nFiles; i++) { - nLen = strlen(pFiles[i]) + 1; + nLen = static_cast(strlen(pFiles[i]) + 1); if (nTotal + nLen + 1 < bufsize) { strcpy(listbuf, pFiles[i]); listbuf += nLen; @@ -2653,7 +2653,7 @@ int FS_GetModList( char *listbuf, int bufsize ) { if (nPaks > 0) { bool isBase = !Q_stricmp( name, BASEGAME ); - nLen = isBase ? 1 : strlen(name) + 1; + nLen = isBase ? 1 : static_cast(strlen(name) + 1); // nLen is the length of the mod path // we need to see if there is a description available descPath[0] = '\0'; @@ -2664,7 +2664,7 @@ int FS_GetModList( char *listbuf, int bufsize ) { FILE *file; file = FS_FileForHandle(descHandle); Com_Memset( descPath, 0, sizeof( descPath ) ); - nDescLen = fread(descPath, 1, 48, file); + nDescLen = static_cast(fread(descPath, 1, 48, file)); if (nDescLen >= 0) { descPath[nDescLen] = '\0'; } @@ -2674,7 +2674,7 @@ int FS_GetModList( char *listbuf, int bufsize ) { } else { strcpy(descPath, name); } - nDescLen = strlen(descPath) + 1; + nDescLen = static_cast(strlen(descPath) + 1); if (nTotal + nLen + 1 + nDescLen + 1 < bufsize) { if ( isBase ) @@ -3580,7 +3580,7 @@ const char *FS_ReferencedPakChecksums( void ) { for ( search = fs_searchpaths ; search ; search = search->next ) { // is the element a pak file? if ( search->pack ) { - if (search->pack->referenced || Q_stricmpn(search->pack->pakGamename, BASEGAME, strlen(BASEGAME))) { + if (search->pack->referenced || Q_stricmpn(search->pack->pakGamename, BASEGAME, static_cast(strlen(BASEGAME)))) { Q_strcat( info, sizeof( info ), va("%i ", search->pack->checksum ) ); } } @@ -3659,7 +3659,7 @@ const char *FS_ReferencedPakNames( void ) { for ( search = fs_searchpaths ; search ; search = search->next ) { // is the element a pak file? if ( search->pack ) { - if (search->pack->referenced || Q_stricmpn(search->pack->pakGamename, BASEGAME, strlen(BASEGAME))) { + if (search->pack->referenced || Q_stricmpn(search->pack->pakGamename, BASEGAME, static_cast(strlen(BASEGAME)))) { if (*info) { Q_strcat(info, sizeof( info ), " " ); } @@ -4153,7 +4153,7 @@ qboolean FS_WriteToTemporaryFile( const void *data, size_t dataLength, char **te if ( file != INVALID_HANDLE_VALUE ) { DWORD bytesWritten = 0; - if (WriteFile(file, data, dataLength, &bytesWritten, NULL)) + if (WriteFile(file, data, static_cast(dataLength), &bytesWritten, NULL)) { int deletesRemaining = ARRAY_LEN(fs_temporaryFileNames); @@ -4194,8 +4194,8 @@ qboolean FS_WriteToTemporaryFile( const void *data, size_t dataLength, char **te if ( tempFilePath ) { size_t fileNameLen = strlen(tempFileName); - *tempFilePath = (char *)Z_Malloc(fileNameLen + 1, TAG_FILESYS); - Q_strncpyz(*tempFilePath, tempFileName, fileNameLen + 1); + *tempFilePath = (char *)Z_Malloc(static_cast(fileNameLen + 1), TAG_FILESYS); + Q_strncpyz(*tempFilePath, tempFileName, static_cast(fileNameLen + 1)); } return qtrue; diff --git a/codemp/qcommon/msg.cpp b/codemp/qcommon/msg.cpp index ac178d342f..32f64a3039 100644 --- a/codemp/qcommon/msg.cpp +++ b/codemp/qcommon/msg.cpp @@ -337,7 +337,7 @@ void MSG_WriteString( msg_t *sb, const char *s ) { int l; char string[MAX_STRING_CHARS]; - l = strlen( s ); + l = static_cast(strlen( s )); if ( l >= MAX_STRING_CHARS ) { Com_Printf( "MSG_WriteString: MAX_STRING_CHARS" ); MSG_WriteData (sb, "", 1); @@ -365,7 +365,7 @@ void MSG_WriteBigString( msg_t *sb, const char *s ) { int l; char string[BIG_INFO_STRING]; - l = strlen( s ); + l = static_cast(strlen( s )); if ( l >= BIG_INFO_STRING ) { Com_Printf( "MSG_WriteString: BIG_INFO_STRING" ); MSG_WriteData (sb, "", 1); diff --git a/codemp/qcommon/net_chan.cpp b/codemp/qcommon/net_chan.cpp index 69ee3ed5cf..86bb6e2561 100644 --- a/codemp/qcommon/net_chan.cpp +++ b/codemp/qcommon/net_chan.cpp @@ -602,7 +602,7 @@ void QDECL NET_OutOfBandPrint( netsrc_t sock, netadr_t adr, const char *format, va_end( argptr ); // send the datagram - NET_SendPacket( sock, strlen( string ), string, adr ); + NET_SendPacket( sock, static_cast(strlen( string )), string, adr ); } /* diff --git a/codemp/qcommon/net_ip.cpp b/codemp/qcommon/net_ip.cpp index bf72ebcc9e..d58d8267f0 100644 --- a/codemp/qcommon/net_ip.cpp +++ b/codemp/qcommon/net_ip.cpp @@ -574,8 +574,8 @@ void NET_OpenSocks( int port ) { int plen; // build the request - ulen = strlen( net_socksUsername->string ); - plen = strlen( net_socksPassword->string ); + ulen = static_cast(strlen( net_socksUsername->string )); + plen = static_cast(strlen( net_socksPassword->string )); buf[0] = 1; // username/password authentication version buf[1] = ulen; diff --git a/codemp/qcommon/q_shared.c b/codemp/qcommon/q_shared.c index 74e3ccaff4..ccb44585ca 100644 --- a/codemp/qcommon/q_shared.c +++ b/codemp/qcommon/q_shared.c @@ -131,8 +131,8 @@ qboolean COM_CompareExtension(const char *in, const char *ext) { int inlen, extlen; - inlen = strlen(in); - extlen = strlen(ext); + inlen = (int)strlen(in); + extlen = (int)strlen(ext); if(extlen <= inlen) { @@ -714,7 +714,7 @@ Assumes buffer is atleast TRUNCATE_LENGTH big ============ */ void Com_TruncateLongString( char *buffer, const char *s ) { - int length = strlen( s ); + int length = (int)strlen( s ); if ( length <= TRUNCATE_LENGTH ) Q_strncpyz( buffer, s, TRUNCATE_LENGTH ); diff --git a/codemp/qcommon/stringed_ingame.cpp b/codemp/qcommon/stringed_ingame.cpp index 3518f0db8d..c698f1120a 100644 --- a/codemp/qcommon/stringed_ingame.cpp +++ b/codemp/qcommon/stringed_ingame.cpp @@ -268,7 +268,7 @@ void CStringEdPackage::SetupNewFileParse( const char *psFileName, SE_BOOL bLoadD // SE_BOOL CStringEdPackage::CheckLineForKeyword( const char *psKeyword, const char *&psLine) { - if (!Q_stricmpn(psKeyword, psLine, strlen(psKeyword)) ) + if (!Q_stricmpn(psKeyword, psLine, static_cast(strlen(psKeyword))) ) { psLine += strlen(psKeyword); @@ -292,7 +292,7 @@ const char *CStringEdPackage::ConvertCRLiterals_Read( const char *psString ) static std::string str; str = psString; int iLoc; - while ( (iLoc = str.find("\\n")) != -1 ) + while ( (iLoc = static_cast(str.find("\\n"))) != -1 ) { str[iLoc ] = '\n'; str.erase( iLoc+1,1 ); @@ -335,7 +335,7 @@ void CStringEdPackage::REMKill( char *psBuffer ) // if (psScanPos[0]) // any strlen? (else access violation with -1 below) { - int iWhiteSpaceScanPos = strlen(psScanPos)-1; + int iWhiteSpaceScanPos = static_cast(strlen(psScanPos))-1; while (iWhiteSpaceScanPos>=0 && isspace(psScanPos[iWhiteSpaceScanPos])) { psScanPos[iWhiteSpaceScanPos--] = '\0'; @@ -384,7 +384,7 @@ SE_BOOL CStringEdPackage::ReadLine( const char *&psParsePos, char *psDest ) // if (psDest[0]) { - int iWhiteSpaceScanPos = strlen(psDest)-1; + int iWhiteSpaceScanPos = static_cast(strlen(psDest))-1; while (iWhiteSpaceScanPos>=0 && isspace(psDest[iWhiteSpaceScanPos])) { psDest[iWhiteSpaceScanPos--] = '\0'; @@ -497,7 +497,7 @@ void CStringEdPackage::AddFlagReference( const char *psLocalReference, const cha // static char *CopeWithDumbStringData( const char *psSentence, const char *psThisLanguage ) { - const int iBufferSize = strlen(psSentence)*3; // *3 to allow for expansion of anything even stupid string consisting entirely of elipsis chars + const int iBufferSize = static_cast(strlen(psSentence)*3); // *3 to allow for expansion of anything even stupid string consisting entirely of elipsis chars char *psNewString = (char *) Z_Malloc(iBufferSize, TAG_TEMP_WORKSPACE, qfalse); Q_strncpyz(psNewString, psSentence, iBufferSize); @@ -660,7 +660,7 @@ const char *CStringEdPackage::ParseLine( const char *psLine ) m_bEndMarkerFound_ParseOnly = SE_TRUE; // the only major error checking I bother to do (for file truncation) } else - if (!Q_stricmpn(sSE_KEYWORD_LANG, psLine, strlen(sSE_KEYWORD_LANG))) + if (!Q_stricmpn(sSE_KEYWORD_LANG, psLine, static_cast(strlen(sSE_KEYWORD_LANG)))) { // LANG_ENGLISH "GUARD: Good to see you, sir. Taylor is waiting for you in the clean tent. We need to get you suited up. " // @@ -1052,7 +1052,7 @@ int SE_GetFlags ( const char *psPackageAndStringReference ) int SE_GetNumFlags( void ) { - return TheStringPackage.m_vstrFlagNames.size(); + return static_cast(TheStringPackage.m_vstrFlagNames.size()); } const char *SE_GetFlagName( int iFlagIndex ) @@ -1126,7 +1126,7 @@ int SE_GetNumLanguages(void) } } - return gvLanguagesAvailable.size(); + return static_cast(gvLanguagesAvailable.size()); } // SE_GetNumLanguages() must have been called before this... diff --git a/codemp/qcommon/z_memman_pc.cpp b/codemp/qcommon/z_memman_pc.cpp index 25f92d4fa7..14ed87c527 100644 --- a/codemp/qcommon/z_memman_pc.cpp +++ b/codemp/qcommon/z_memman_pc.cpp @@ -646,7 +646,7 @@ char *CopyString( const char *in ) { } } - out = (char *) S_Malloc (strlen(in)+1); + out = (char *) S_Malloc (static_cast(strlen(in)+1)); strcpy (out, in); return out; } diff --git a/codemp/rd-common/tr_image_jpg.cpp b/codemp/rd-common/tr_image_jpg.cpp index e94d0edc93..c8724cb7f8 100644 --- a/codemp/rd-common/tr_image_jpg.cpp +++ b/codemp/rd-common/tr_image_jpg.cpp @@ -357,7 +357,7 @@ size_t RE_SaveJPGToBuffer(byte *buffer, size_t bufSize, int quality, /* Step 2: specify data destination (eg, a file) */ /* Note: steps 2 and 3 can be done in either order. */ - jpegDest(&cinfo, buffer, bufSize); + jpegDest(&cinfo, buffer, static_cast(bufSize)); /* Step 3: set parameters for compression */ cinfo.image_width = image_width; /* image width and height, in pixels */ @@ -411,10 +411,10 @@ void RE_SaveJPG(const char * filename, int quality, int image_width, int image_h size_t bufSize; bufSize = image_width * image_height * 3; - out = (byte *)Hunk_AllocateTempMemory(bufSize); + out = (byte *)Hunk_AllocateTempMemory(static_cast(bufSize)); bufSize = RE_SaveJPGToBuffer(out, bufSize, quality, image_width, image_height, image_buffer, padding); - ri.FS_WriteFile(filename, out, bufSize); + ri.FS_WriteFile(filename, out, static_cast(bufSize)); Hunk_FreeTempMemory(out); } diff --git a/codemp/rd-common/tr_image_png.cpp b/codemp/rd-common/tr_image_png.cpp index 0bb6ecf89d..22d81027f8 100644 --- a/codemp/rd-common/tr_image_png.cpp +++ b/codemp/rd-common/tr_image_png.cpp @@ -27,7 +27,7 @@ along with this program; if not, see . void user_write_data( png_structp png_ptr, png_bytep data, png_size_t length ) { fileHandle_t fp = *(fileHandle_t*)png_get_io_ptr( png_ptr ); - ri.FS_Write( data, length, fp ); + ri.FS_Write( data, static_cast(length), fp ); } void user_flush_data( png_structp png_ptr ) { //TODO: ri.FS_Flush? @@ -74,8 +74,8 @@ int RE_SavePNG( const char *filename, byte *buf, size_t width, size_t height, in png_set_IHDR (png_ptr, info_ptr, - width, - height, + static_cast(width), + static_cast(height), depth, PNG_COLOR_TYPE_RGB, PNG_INTERLACE_NONE, diff --git a/codemp/rd-dedicated/G2_API.cpp b/codemp/rd-dedicated/G2_API.cpp index c95a0edc69..cdc166089c 100644 --- a/codemp/rd-dedicated/G2_API.cpp +++ b/codemp/rd-dedicated/G2_API.cpp @@ -2500,7 +2500,7 @@ int G2API_GetNumGoreMarks(CGhoul2Info_v& ghoul2, int modelIndex) if (goreSet) { - return goreSet->mGoreRecords.size(); + return static_cast(goreSet->mGoreRecords.size()); } } diff --git a/codemp/rd-dedicated/G2_bolts.cpp b/codemp/rd-dedicated/G2_bolts.cpp index ab08223d41..56f3976430 100644 --- a/codemp/rd-dedicated/G2_bolts.cpp +++ b/codemp/rd-dedicated/G2_bolts.cpp @@ -40,7 +40,7 @@ int G2_Find_Bolt_Bone_Num(boltInfo_v &bltlist, const int boneNum) if (bltlist[i].boneNumber == boneNum) { - return i; + return static_cast(i); } } @@ -62,7 +62,7 @@ int G2_Find_Bolt_Surface_Num(boltInfo_v &bltlist, const int surfaceNum, const in if ((bltlist[i].surfaceNumber == surfaceNum) && ((bltlist[i].surfaceType & flags) == flags)) { - return i; + return static_cast(i); } } @@ -91,7 +91,7 @@ int G2_Add_Bolt_Surf_Num(CGhoul2Info *ghlInfo, boltInfo_v &bltlist, surfaceInfo_ { // increment the usage count bltlist[i].boltUsed++; - return i; + return static_cast(i); } } @@ -106,7 +106,7 @@ int G2_Add_Bolt_Surf_Num(CGhoul2Info *ghlInfo, boltInfo_v &bltlist, surfaceInfo_ bltlist[i].surfaceNumber = surfNum; bltlist[i].surfaceType = G2SURFACEFLAG_GENERATED; bltlist[i].boltUsed = 1; - return i; + return static_cast(i); } } @@ -116,7 +116,7 @@ int G2_Add_Bolt_Surf_Num(CGhoul2Info *ghlInfo, boltInfo_v &bltlist, surfaceInfo_ tempBolt.boneNumber = -1; tempBolt.boltUsed = 1; bltlist.push_back(tempBolt); - return bltlist.size()-1; + return static_cast(bltlist.size())-1; } @@ -145,7 +145,7 @@ int G2_Add_Bolt(CGhoul2Info *ghlInfo, boltInfo_v &bltlist, surfaceInfo_v &slist, { // increment the usage count bltlist[i].boltUsed++; - return i; + return static_cast(i); } } @@ -159,7 +159,7 @@ int G2_Add_Bolt(CGhoul2Info *ghlInfo, boltInfo_v &bltlist, surfaceInfo_v &slist, bltlist[i].surfaceNumber = surfNum; bltlist[i].boltUsed = 1; bltlist[i].surfaceType = 0; - return i; + return static_cast(i); } } @@ -169,7 +169,7 @@ int G2_Add_Bolt(CGhoul2Info *ghlInfo, boltInfo_v &bltlist, surfaceInfo_v &slist, tempBolt.boltUsed = 1; tempBolt.surfaceType = 0; bltlist.push_back(tempBolt); - return bltlist.size()-1; + return static_cast(bltlist.size())-1; } // no, check to see if it's a bone then @@ -206,7 +206,7 @@ int G2_Add_Bolt(CGhoul2Info *ghlInfo, boltInfo_v &bltlist, surfaceInfo_v &slist, { // increment the usage count bltlist[i].boltUsed++; - return i; + return static_cast(i); } } @@ -220,7 +220,7 @@ int G2_Add_Bolt(CGhoul2Info *ghlInfo, boltInfo_v &bltlist, surfaceInfo_v &slist, bltlist[i].boneNumber = x; bltlist[i].boltUsed = 1; bltlist[i].surfaceType = 0; - return i; + return static_cast(i); } } @@ -230,7 +230,7 @@ int G2_Add_Bolt(CGhoul2Info *ghlInfo, boltInfo_v &bltlist, surfaceInfo_v &slist, tempBolt.boltUsed = 1; tempBolt.surfaceType = 0; bltlist.push_back(tempBolt); - return bltlist.size()-1; + return static_cast(bltlist.size())-1; } @@ -247,9 +247,9 @@ qboolean G2_Remove_Bolt (boltInfo_v &bltlist, int index) bltlist[index].boneNumber = -1; bltlist[index].surfaceNumber = -1; - unsigned int newSize = bltlist.size(); + unsigned int newSize = static_cast(bltlist.size()); // now look through the list from the back and see if there is a block of -1's we can resize off the end of the list - for (int i=bltlist.size()-1; i>-1; i--) + for (int i=static_cast(bltlist.size())-1; i>-1; i--) { if ((bltlist[i].surfaceNumber == -1) && (bltlist[i].boneNumber == -1)) { @@ -304,7 +304,7 @@ void G2_RemoveRedundantBolts(boltInfo_v &bltlist, surfaceInfo_v &slist, int *act { // no - we want to remove this bolt, regardless of how many people are using it bltlist[i].boltUsed = 1; - G2_Remove_Bolt(bltlist, i); + G2_Remove_Bolt(bltlist, static_cast(i)); } } // no, it's an original, so look for it in the active surfaces list @@ -313,7 +313,7 @@ void G2_RemoveRedundantBolts(boltInfo_v &bltlist, surfaceInfo_v &slist, int *act { // no - we want to remove this bolt, regardless of how many people are using it bltlist[i].boltUsed = 1; - G2_Remove_Bolt(bltlist, i); + G2_Remove_Bolt(bltlist, static_cast(i)); } } } @@ -325,7 +325,7 @@ void G2_RemoveRedundantBolts(boltInfo_v &bltlist, surfaceInfo_v &slist, int *act { // no - we want to remove this bolt, regardless of how many people are using it bltlist[i].boltUsed = 1; - G2_Remove_Bolt(bltlist, i); + G2_Remove_Bolt(bltlist, static_cast(i)); } } } From 63c006b47626d3496b226ae349122021d83413ef Mon Sep 17 00:00:00 2001 From: Jonathan Horner Date: Tue, 1 Jun 2021 21:38:24 +0100 Subject: [PATCH 09/10] Fixed last of integer conversion warnings. --- codemp/rd-dedicated/G2_bones.cpp | 24 +++++++++--------- codemp/rd-dedicated/G2_misc.cpp | 16 ++++++------ codemp/rd-dedicated/G2_surfaces.cpp | 14 +++++------ codemp/rd-dedicated/tr_ghoul2.cpp | 2 +- codemp/rd-dedicated/tr_model.cpp | 4 +-- codemp/rd-vanilla/G2_API.cpp | 14 +++++------ codemp/rd-vanilla/G2_bolts.cpp | 32 ++++++++++++------------ codemp/rd-vanilla/G2_bones.cpp | 22 ++++++++--------- codemp/rd-vanilla/G2_misc.cpp | 16 ++++++------ codemp/rd-vanilla/G2_surfaces.cpp | 14 +++++------ codemp/rd-vanilla/tr_arb.cpp | 4 +-- codemp/rd-vanilla/tr_bsp.cpp | 6 ++--- codemp/rd-vanilla/tr_ghoul2.cpp | 2 +- codemp/rd-vanilla/tr_image.cpp | 2 +- codemp/rd-vanilla/tr_init.cpp | 22 ++++++++--------- codemp/rd-vanilla/tr_model.cpp | 6 ++--- codemp/rd-vanilla/tr_shade_calc.cpp | 2 +- codemp/server/NPCNav/navigator.cpp | 8 +++--- codemp/server/sv_ccmds.cpp | 2 +- codemp/server/sv_challenge.cpp | 2 +- codemp/server/sv_client.cpp | 4 +-- codemp/server/sv_init.cpp | 2 +- codemp/server/sv_main.cpp | 2 +- codemp/ui/ui_force.c | 6 ++--- codemp/ui/ui_gameinfo.c | 6 ++--- codemp/ui/ui_main.c | 38 ++++++++++++++--------------- codemp/ui/ui_shared.c | 8 +++--- lib/jpeg-9a/jdatadst.c | 2 +- lib/jpeg-9a/jmemmgr.c | 8 +++--- shared/sys/con_win32.cpp | 6 ++--- shared/sys/sys_event.cpp | 2 +- shared/sys/sys_main.cpp | 4 +-- 32 files changed, 151 insertions(+), 151 deletions(-) diff --git a/codemp/rd-dedicated/G2_bones.cpp b/codemp/rd-dedicated/G2_bones.cpp index 1df9d71a60..19b598958a 100644 --- a/codemp/rd-dedicated/G2_bones.cpp +++ b/codemp/rd-dedicated/G2_bones.cpp @@ -67,7 +67,7 @@ int G2_Find_Bone(const model_t *mod, boneInfo_v &blist, const char *boneName) // if name is the same, we found it if (!Q_stricmp(skel->name, boneName)) { - return i; + return static_cast(i); } } @@ -125,7 +125,7 @@ int G2_Add_Bone (const model_t *mod, boneInfo_v &blist, const char *boneName) // if name is the same, we found it if (!Q_stricmp(skel->name, boneName)) { - return i; + return static_cast(i); } } else @@ -133,7 +133,7 @@ int G2_Add_Bone (const model_t *mod, boneInfo_v &blist, const char *boneName) // if we found an entry that had a -1 for the bonenumber, then we hit a bone slot that was empty blist[i].boneNumber = x; blist[i].flags = 0; - return i; + return static_cast(i); } } @@ -144,7 +144,7 @@ int G2_Add_Bone (const model_t *mod, boneInfo_v &blist, const char *boneName) tempBone.boneNumber = x; tempBone.flags = 0; blist.push_back(tempBone); - return blist.size()-1; + return static_cast(blist.size()-1); } @@ -169,9 +169,9 @@ qboolean G2_Remove_Bone_Index ( boneInfo_v &blist, int index) // set this bone to not used blist[index].boneNumber = -1; - unsigned int newSize = blist.size(); + unsigned int newSize = static_cast(blist.size()); // now look through the list from the back and see if there is a block of -1's we can resize off the end of the list - for (int i=blist.size()-1; i>-1; i--) + for (int i=static_cast(blist.size()-1); i>-1; i--) { if (blist[i].boneNumber == -1) { @@ -207,7 +207,7 @@ int G2_Find_Bone_In_List(boneInfo_v &blist, const int boneNum) { if (blist[i].boneNumber == boneNum) { - return i; + return static_cast(i); } } return -1; @@ -1146,7 +1146,7 @@ void G2_Animate_Bone_List(CGhoul2Info_v &ghoul2, const int currentTime, const in if ((blist[i].flags & BONE_ANIM_OVERRIDE_FREEZE) != BONE_ANIM_OVERRIDE_FREEZE) { // nope, just stop it. And remove the bone if possible - G2_Stop_Bone_Index(blist, i, (BONE_ANIM_TOTAL)); + G2_Stop_Bone_Index(blist, static_cast(i), (BONE_ANIM_TOTAL)); } } } @@ -1320,7 +1320,7 @@ int G2_Find_Bone_Rag(CGhoul2Info *ghlInfo, boneInfo_v &blist, const char *boneNa // if name is the same, we found it if (!Q_stricmp(skel->name, boneName)) { - return i; + return static_cast(i); } } #if _DEBUG @@ -1957,7 +1957,7 @@ void G2_SetRagDollBullet(CGhoul2Info &ghoul2,const vec3_t rayStart,const vec3_t int i; int magicFactor13=150.0f; // squared radius multiplier for shot effects boneInfo_v &blist = ghoul2.mBlist; - for(i=blist.size()-1;i>=0;i--) + for(i=static_cast(blist.size()-1);i>=0;i--) { boneInfo_t &bone=blist[i]; if ((bone.flags & BONE_ANGLES_TOTAL)) @@ -2226,7 +2226,7 @@ static bool G2_RagDollSetup(CGhoul2Info &ghoul2,int frameNum,bool resetOrigin,co rag.resize(bone.boneNumber+1,0); } rag[bone.boneNumber]=&bone; - ragBlistIndex[bone.boneNumber]=i; + ragBlistIndex[bone.boneNumber]=static_cast(i); bone.lastTimeUpdated=frameNum; if (resetOrigin) @@ -4652,7 +4652,7 @@ void G2_RemoveRedundantBoneOverrides(boneInfo_v &blist, int *activeBones) if (!activeBones[blist[i].boneNumber]) { blist[i].flags = 0; - G2_Remove_Bone_Index(blist, i); + G2_Remove_Bone_Index(blist, static_cast(i)); } } } diff --git a/codemp/rd-dedicated/G2_misc.cpp b/codemp/rd-dedicated/G2_misc.cpp index 1bcec8e457..3b826a570d 100644 --- a/codemp/rd-dedicated/G2_misc.cpp +++ b/codemp/rd-dedicated/G2_misc.cpp @@ -1709,7 +1709,7 @@ qboolean G2_SaveGhoul2Models(CGhoul2Info_v &ghoul2, char **buffer, int *size) *size = 0; // this one isn't a define since I couldn't work out how to figure it out at compile time - int ghoul2BlockSize = (size_t)&ghoul2[0].mTransformedVertsArray - (size_t)&ghoul2[0].mModelindex; + int ghoul2BlockSize = static_cast((size_t)&ghoul2[0].mTransformedVertsArray - (size_t)&ghoul2[0].mModelindex); // add in count for number of ghoul2 models *size += 4; @@ -1720,13 +1720,13 @@ qboolean G2_SaveGhoul2Models(CGhoul2Info_v &ghoul2, char **buffer, int *size) *size += ghoul2BlockSize; // add in count for number of surfaces *size += 4; - *size += (ghoul2[i].mSlist.size() * SURFACE_SAVE_BLOCK_SIZE); + *size += static_cast(ghoul2[i].mSlist.size() * SURFACE_SAVE_BLOCK_SIZE); // add in count for number of bones *size += 4; - *size += (ghoul2[i].mBlist.size() * BONE_SAVE_BLOCK_SIZE); + *size += static_cast(ghoul2[i].mBlist.size() * BONE_SAVE_BLOCK_SIZE); // add in count for number of bolts *size += 4; - *size += (ghoul2[i].mBltlist.size() * BOLT_SAVE_BLOCK_SIZE); + *size += static_cast(ghoul2[i].mBltlist.size() * BOLT_SAVE_BLOCK_SIZE); } // ok, we should know how much space we need now @@ -1747,7 +1747,7 @@ qboolean G2_SaveGhoul2Models(CGhoul2Info_v &ghoul2, char **buffer, int *size) tempBuffer += ghoul2BlockSize; // save out how many surfaces we have - *(int*)tempBuffer = ghoul2[i].mSlist.size(); + *(int*)tempBuffer = static_cast(ghoul2[i].mSlist.size()); tempBuffer +=4; // now save the all the surface list info @@ -1758,7 +1758,7 @@ qboolean G2_SaveGhoul2Models(CGhoul2Info_v &ghoul2, char **buffer, int *size) } // save out how many bones we have - *(int*)tempBuffer = ghoul2[i].mBlist.size(); + *(int*)tempBuffer = static_cast(ghoul2[i].mBlist.size()); tempBuffer +=4; // now save the all the bone list info @@ -1769,7 +1769,7 @@ qboolean G2_SaveGhoul2Models(CGhoul2Info_v &ghoul2, char **buffer, int *size) } // save out how many bolts we have - *(int*)tempBuffer = ghoul2[i].mBltlist.size(); + *(int*)tempBuffer = static_cast(ghoul2[i].mBltlist.size()); tempBuffer +=4; // lastly save the all the bolt list info @@ -1807,7 +1807,7 @@ void G2_LoadGhoul2Model(CGhoul2Info_v &ghoul2, char *buffer) } // this one isn't a define since I couldn't work out how to figure it out at compile time - int ghoul2BlockSize = (size_t)&ghoul2[0].mTransformedVertsArray - (size_t)&ghoul2[0].mModelindex; + int ghoul2BlockSize = static_cast((size_t)&ghoul2[0].mTransformedVertsArray - (size_t)&ghoul2[0].mModelindex); // now we have enough instances, lets go through each one and load up the relevant details for (int i=0; i= 0; i--) + for (i = static_cast(slist.size() - 1); i >= 0; i--) { if ((slist[i].surface != 10000) && (slist[i].surface != -1)) { @@ -324,7 +324,7 @@ void G2_RemoveRedundantGeneratedSurfaces(surfaceInfo_v &slist, int *activeSurfac // if it's not in the list, remove it if (!activeSurfaces[slist[i].genPolySurfaceIndex & 0xffff]) { - G2_RemoveSurface(slist, i); + G2_RemoveSurface(slist, static_cast(i)); } } // no, so it does point back at a legal surface @@ -333,7 +333,7 @@ void G2_RemoveRedundantGeneratedSurfaces(surfaceInfo_v &slist, int *activeSurfac // if it's not in the list, remove it if (!activeSurfaces[slist[i].surface]) { - G2_RemoveSurface(slist, i); + G2_RemoveSurface(slist, static_cast(i)); } } } @@ -534,7 +534,7 @@ int G2_AddSurface(CGhoul2Info *ghoul2, int surfaceNumber, int polyNumber, float ghoul2->mSlist[i].genBarycentricJ = BarycentricJ; ghoul2->mSlist[i].genPolySurfaceIndex = ((polyNumber & 0xffff) << 16) | (surfaceNumber & 0xffff); ghoul2->mSlist[i].genLod = lod; - return i; + return static_cast(i); } } @@ -549,7 +549,7 @@ int G2_AddSurface(CGhoul2Info *ghoul2, int surfaceNumber, int polyNumber, float ghoul2->mSlist.push_back(temp_slist_entry); - return (ghoul2->mSlist.size() -1 ); + return static_cast(ghoul2->mSlist.size() -1 ); } qboolean G2_RemoveSurface(surfaceInfo_v &slist, const int index) @@ -560,9 +560,9 @@ qboolean G2_RemoveSurface(surfaceInfo_v &slist, const int index) // set us to be the 'not active' state slist[index].surface = -1; - unsigned int newSize = slist.size(); + unsigned int newSize = static_cast(slist.size()); // now look through the list from the back and see if there is a block of -1's we can resize off the end of the list - for (int i=slist.size()-1; i>-1; i--) + for (int i=static_cast(slist.size()-1); i>-1; i--) { if (slist[i].surface == -1) { diff --git a/codemp/rd-dedicated/tr_ghoul2.cpp b/codemp/rd-dedicated/tr_ghoul2.cpp index 0797f76eed..3b68eee11b 100644 --- a/codemp/rd-dedicated/tr_ghoul2.cpp +++ b/codemp/rd-dedicated/tr_ghoul2.cpp @@ -2230,7 +2230,7 @@ void G2_ProcessGeneratedSurfaceBolts(CGhoul2Info &ghoul2, mdxaBone_v &bonePtr, m if (ghoul2.mSlist[i].offFlags & G2SURFACEFLAG_GENERATED) { // well alrighty then. Lets see if there is a bolt that is attempting to use it - int boltNum = G2_Find_Bolt_Surface_Num(ghoul2.mBltlist, i, G2SURFACEFLAG_GENERATED); + int boltNum = G2_Find_Bolt_Surface_Num(ghoul2.mBltlist, static_cast(i), G2SURFACEFLAG_GENERATED); // yes - ok, processing time. if (boltNum != -1) { diff --git a/codemp/rd-dedicated/tr_model.cpp b/codemp/rd-dedicated/tr_model.cpp index ff15e7dd97..6513e2f5ba 100644 --- a/codemp/rd-dedicated/tr_model.cpp +++ b/codemp/rd-dedicated/tr_model.cpp @@ -448,7 +448,7 @@ void RE_RegisterModels_Info_f( void ) return; } - int iModels = CachedModels->size(); + int iModels = static_cast(CachedModels->size()); int iModel = 0; for (CachedModels_t::iterator itModel = CachedModels->begin(); itModel != CachedModels->end(); ++itModel,iModel++) @@ -1501,7 +1501,7 @@ static qboolean R_LoadMD3 (model_t *mod, int lod, void *buffer, const char *mod_ // strip off a trailing _1 or _2 // this is a crutch for q3data being a mess - j = strlen( surf->name ); + j = static_cast(strlen( surf->name )); if ( j > 2 && surf->name[j-2] == '_' ) { surf->name[j-2] = 0; } diff --git a/codemp/rd-vanilla/G2_API.cpp b/codemp/rd-vanilla/G2_API.cpp index d09a90af5e..cfcf65391f 100644 --- a/codemp/rd-vanilla/G2_API.cpp +++ b/codemp/rd-vanilla/G2_API.cpp @@ -332,7 +332,7 @@ static size_t SerializeGhoul2Info ( char *buffer, const CGhoul2Info& g2Info ) buffer += blockSize; // Surfaces vector + size - *(int *)buffer = g2Info.mSlist.size(); + *(int *)buffer = static_cast(g2Info.mSlist.size()); buffer += sizeof (int); blockSize = g2Info.mSlist.size() * sizeof (surfaceInfo_t); @@ -340,7 +340,7 @@ static size_t SerializeGhoul2Info ( char *buffer, const CGhoul2Info& g2Info ) buffer += blockSize; // Bones vector + size - *(int *)buffer = g2Info.mBlist.size(); + *(int *)buffer = static_cast(g2Info.mBlist.size()); buffer += sizeof (int); blockSize = g2Info.mBlist.size() * sizeof (boneInfo_t); @@ -348,7 +348,7 @@ static size_t SerializeGhoul2Info ( char *buffer, const CGhoul2Info& g2Info ) buffer += blockSize; // Bolts vector + size - *(int *)buffer = g2Info.mBltlist.size(); + *(int *)buffer = static_cast(g2Info.mBltlist.size()); buffer += sizeof (int); blockSize = g2Info.mBltlist.size() * sizeof (boltInfo_t); @@ -458,7 +458,7 @@ class Ghoul2InfoArray : public IGhoul2InfoArray char *base = buffer; // Free indices - *(int *)buffer = mFreeIndecies.size(); + *(int *)buffer = static_cast(mFreeIndecies.size()); buffer += sizeof (int); std::copy (mFreeIndecies.begin(), mFreeIndecies.end(), (int *)buffer); @@ -471,7 +471,7 @@ class Ghoul2InfoArray : public IGhoul2InfoArray // Ghoul2 infos for ( size_t i = 0; i < MAX_G2_MODELS; i++ ) { - *(int *)buffer = mInfos[i].size(); + *(int *)buffer = static_cast(mInfos[i].size()); buffer += sizeof (int); for ( size_t j = 0; j < mInfos[i].size(); j++ ) @@ -677,7 +677,7 @@ void RestoreGhoul2InfoArray() void SaveGhoul2InfoArray() { size_t size = singleton->GetSerializedSize(); - void *data = Z_Malloc (size, TAG_GHOUL2); + void *data = Z_Malloc (static_cast(size), TAG_GHOUL2); #ifdef _DEBUG size_t written = #endif @@ -2747,7 +2747,7 @@ int G2API_GetNumGoreMarks(CGhoul2Info_v& ghoul2, int modelIndex) if (goreSet) { - return goreSet->mGoreRecords.size(); + return static_cast(goreSet->mGoreRecords.size()); } } diff --git a/codemp/rd-vanilla/G2_bolts.cpp b/codemp/rd-vanilla/G2_bolts.cpp index cc35e6590e..2a8a46db1b 100644 --- a/codemp/rd-vanilla/G2_bolts.cpp +++ b/codemp/rd-vanilla/G2_bolts.cpp @@ -40,7 +40,7 @@ int G2_Find_Bolt_Bone_Num(boltInfo_v &bltlist, const int boneNum) if (bltlist[i].boneNumber == boneNum) { - return i; + return static_cast(i); } } @@ -62,7 +62,7 @@ int G2_Find_Bolt_Surface_Num(boltInfo_v &bltlist, const int surfaceNum, const in if ((bltlist[i].surfaceNumber == surfaceNum) && ((bltlist[i].surfaceType & flags) == flags)) { - return i; + return static_cast(i); } } @@ -91,7 +91,7 @@ int G2_Add_Bolt_Surf_Num(CGhoul2Info *ghlInfo, boltInfo_v &bltlist, surfaceInfo_ { // increment the usage count bltlist[i].boltUsed++; - return i; + return static_cast(i); } } @@ -106,7 +106,7 @@ int G2_Add_Bolt_Surf_Num(CGhoul2Info *ghlInfo, boltInfo_v &bltlist, surfaceInfo_ bltlist[i].surfaceNumber = surfNum; bltlist[i].surfaceType = G2SURFACEFLAG_GENERATED; bltlist[i].boltUsed = 1; - return i; + return static_cast(i); } } @@ -116,7 +116,7 @@ int G2_Add_Bolt_Surf_Num(CGhoul2Info *ghlInfo, boltInfo_v &bltlist, surfaceInfo_ tempBolt.boneNumber = -1; tempBolt.boltUsed = 1; bltlist.push_back(tempBolt); - return bltlist.size()-1; + return static_cast(bltlist.size()-1); } @@ -145,7 +145,7 @@ int G2_Add_Bolt(CGhoul2Info *ghlInfo, boltInfo_v &bltlist, surfaceInfo_v &slist, { // increment the usage count bltlist[i].boltUsed++; - return i; + return static_cast(i); } } @@ -159,7 +159,7 @@ int G2_Add_Bolt(CGhoul2Info *ghlInfo, boltInfo_v &bltlist, surfaceInfo_v &slist, bltlist[i].surfaceNumber = surfNum; bltlist[i].boltUsed = 1; bltlist[i].surfaceType = 0; - return i; + return static_cast(i); } } @@ -169,7 +169,7 @@ int G2_Add_Bolt(CGhoul2Info *ghlInfo, boltInfo_v &bltlist, surfaceInfo_v &slist, tempBolt.boltUsed = 1; tempBolt.surfaceType = 0; bltlist.push_back(tempBolt); - return bltlist.size()-1; + return static_cast(bltlist.size()-1); } // no, check to see if it's a bone then @@ -206,7 +206,7 @@ int G2_Add_Bolt(CGhoul2Info *ghlInfo, boltInfo_v &bltlist, surfaceInfo_v &slist, { // increment the usage count bltlist[i].boltUsed++; - return i; + return static_cast(i); } } @@ -220,7 +220,7 @@ int G2_Add_Bolt(CGhoul2Info *ghlInfo, boltInfo_v &bltlist, surfaceInfo_v &slist, bltlist[i].boneNumber = x; bltlist[i].boltUsed = 1; bltlist[i].surfaceType = 0; - return i; + return static_cast(i); } } @@ -230,7 +230,7 @@ int G2_Add_Bolt(CGhoul2Info *ghlInfo, boltInfo_v &bltlist, surfaceInfo_v &slist, tempBolt.boltUsed = 1; tempBolt.surfaceType = 0; bltlist.push_back(tempBolt); - return bltlist.size()-1; + return static_cast(bltlist.size()-1); } @@ -247,9 +247,9 @@ qboolean G2_Remove_Bolt (boltInfo_v &bltlist, int index) bltlist[index].boneNumber = -1; bltlist[index].surfaceNumber = -1; - unsigned int newSize = bltlist.size(); + unsigned int newSize = static_cast(bltlist.size()); // now look through the list from the back and see if there is a block of -1's we can resize off the end of the list - for (int i=bltlist.size()-1; i>-1; i--) + for (int i=static_cast(bltlist.size()-1); i>-1; i--) { if ((bltlist[i].surfaceNumber == -1) && (bltlist[i].boneNumber == -1)) { @@ -304,7 +304,7 @@ void G2_RemoveRedundantBolts(boltInfo_v &bltlist, surfaceInfo_v &slist, int *act { // no - we want to remove this bolt, regardless of how many people are using it bltlist[i].boltUsed = 1; - G2_Remove_Bolt(bltlist, i); + G2_Remove_Bolt(bltlist, static_cast(i)); } } // no, it's an original, so look for it in the active surfaces list @@ -313,7 +313,7 @@ void G2_RemoveRedundantBolts(boltInfo_v &bltlist, surfaceInfo_v &slist, int *act { // no - we want to remove this bolt, regardless of how many people are using it bltlist[i].boltUsed = 1; - G2_Remove_Bolt(bltlist, i); + G2_Remove_Bolt(bltlist, static_cast(i)); } } } @@ -325,7 +325,7 @@ void G2_RemoveRedundantBolts(boltInfo_v &bltlist, surfaceInfo_v &slist, int *act { // no - we want to remove this bolt, regardless of how many people are using it bltlist[i].boltUsed = 1; - G2_Remove_Bolt(bltlist, i); + G2_Remove_Bolt(bltlist, static_cast(i)); } } } diff --git a/codemp/rd-vanilla/G2_bones.cpp b/codemp/rd-vanilla/G2_bones.cpp index 67379509db..0a6c303f61 100644 --- a/codemp/rd-vanilla/G2_bones.cpp +++ b/codemp/rd-vanilla/G2_bones.cpp @@ -66,7 +66,7 @@ int G2_Find_Bone(const model_t *mod, boneInfo_v &blist, const char *boneName) // if name is the same, we found it if (!Q_stricmp(skel->name, boneName)) { - return i; + return static_cast(i); } } @@ -124,7 +124,7 @@ int G2_Add_Bone (const model_t *mod, boneInfo_v &blist, const char *boneName) // if name is the same, we found it if (!Q_stricmp(skel->name, boneName)) { - return i; + return static_cast(i); } } else @@ -132,7 +132,7 @@ int G2_Add_Bone (const model_t *mod, boneInfo_v &blist, const char *boneName) // if we found an entry that had a -1 for the bonenumber, then we hit a bone slot that was empty blist[i].boneNumber = x; blist[i].flags = 0; - return i; + return static_cast(i); } } @@ -143,7 +143,7 @@ int G2_Add_Bone (const model_t *mod, boneInfo_v &blist, const char *boneName) tempBone.boneNumber = x; tempBone.flags = 0; blist.push_back(tempBone); - return blist.size()-1; + return static_cast(blist.size()-1); } @@ -168,9 +168,9 @@ qboolean G2_Remove_Bone_Index ( boneInfo_v &blist, int index) // set this bone to not used blist[index].boneNumber = -1; - unsigned int newSize = blist.size(); + unsigned int newSize = static_cast(blist.size()); // now look through the list from the back and see if there is a block of -1's we can resize off the end of the list - for (int i=blist.size()-1; i>-1; i--) + for (int i=static_cast(blist.size()-1); i>-1; i--) { if (blist[i].boneNumber == -1) { @@ -206,7 +206,7 @@ int G2_Find_Bone_In_List(boneInfo_v &blist, const int boneNum) { if (blist[i].boneNumber == boneNum) { - return i; + return static_cast(i); } } return -1; @@ -1145,7 +1145,7 @@ void G2_Animate_Bone_List(CGhoul2Info_v &ghoul2, const int currentTime, const in if ((blist[i].flags & BONE_ANIM_OVERRIDE_FREEZE) != BONE_ANIM_OVERRIDE_FREEZE) { // nope, just stop it. And remove the bone if possible - G2_Stop_Bone_Index(blist, i, (BONE_ANIM_TOTAL)); + G2_Stop_Bone_Index(blist, static_cast(i), (BONE_ANIM_TOTAL)); } } } @@ -1319,7 +1319,7 @@ int G2_Find_Bone_Rag(CGhoul2Info *ghlInfo, boneInfo_v &blist, const char *boneNa // if name is the same, we found it if (!Q_stricmp(skel->name, boneName)) { - return i; + return static_cast(i); } } #if _DEBUG @@ -2343,7 +2343,7 @@ static bool G2_RagDollSetup(CGhoul2Info &ghoul2,int frameNum,bool resetOrigin,co rag.resize(bone.boneNumber+1,0); } rag[bone.boneNumber]=&bone; - ragBlistIndex[bone.boneNumber]=i; + ragBlistIndex[bone.boneNumber]=static_cast(i); bone.lastTimeUpdated=frameNum; if (resetOrigin) @@ -4874,7 +4874,7 @@ void G2_RemoveRedundantBoneOverrides(boneInfo_v &blist, int *activeBones) if (!activeBones[blist[i].boneNumber]) { blist[i].flags = 0; - G2_Remove_Bone_Index(blist, i); + G2_Remove_Bone_Index(blist, static_cast(i)); } } } diff --git a/codemp/rd-vanilla/G2_misc.cpp b/codemp/rd-vanilla/G2_misc.cpp index 02cded0724..58029b88e3 100644 --- a/codemp/rd-vanilla/G2_misc.cpp +++ b/codemp/rd-vanilla/G2_misc.cpp @@ -1710,7 +1710,7 @@ qboolean G2_SaveGhoul2Models(CGhoul2Info_v &ghoul2, char **buffer, int *size) *size = 0; // this one isn't a define since I couldn't work out how to figure it out at compile time - int ghoul2BlockSize = (size_t)&ghoul2[0].mTransformedVertsArray - (size_t)&ghoul2[0].mModelindex; + int ghoul2BlockSize = static_cast((size_t)&ghoul2[0].mTransformedVertsArray - (size_t)&ghoul2[0].mModelindex); // add in count for number of ghoul2 models *size += 4; @@ -1721,13 +1721,13 @@ qboolean G2_SaveGhoul2Models(CGhoul2Info_v &ghoul2, char **buffer, int *size) *size += ghoul2BlockSize; // add in count for number of surfaces *size += 4; - *size += (ghoul2[i].mSlist.size() * SURFACE_SAVE_BLOCK_SIZE); + *size += static_cast(ghoul2[i].mSlist.size() * SURFACE_SAVE_BLOCK_SIZE); // add in count for number of bones *size += 4; - *size += (ghoul2[i].mBlist.size() * BONE_SAVE_BLOCK_SIZE); + *size += static_cast(ghoul2[i].mBlist.size() * BONE_SAVE_BLOCK_SIZE); // add in count for number of bolts *size += 4; - *size += (ghoul2[i].mBltlist.size() * BOLT_SAVE_BLOCK_SIZE); + *size += static_cast(ghoul2[i].mBltlist.size() * BOLT_SAVE_BLOCK_SIZE); } // ok, we should know how much space we need now @@ -1748,7 +1748,7 @@ qboolean G2_SaveGhoul2Models(CGhoul2Info_v &ghoul2, char **buffer, int *size) tempBuffer += ghoul2BlockSize; // save out how many surfaces we have - *(int*)tempBuffer = ghoul2[i].mSlist.size(); + *(int*)tempBuffer = static_cast(ghoul2[i].mSlist.size()); tempBuffer +=4; // now save the all the surface list info @@ -1759,7 +1759,7 @@ qboolean G2_SaveGhoul2Models(CGhoul2Info_v &ghoul2, char **buffer, int *size) } // save out how many bones we have - *(int*)tempBuffer = ghoul2[i].mBlist.size(); + *(int*)tempBuffer = static_cast(ghoul2[i].mBlist.size()); tempBuffer +=4; // now save the all the bone list info @@ -1770,7 +1770,7 @@ qboolean G2_SaveGhoul2Models(CGhoul2Info_v &ghoul2, char **buffer, int *size) } // save out how many bolts we have - *(int*)tempBuffer = ghoul2[i].mBltlist.size(); + *(int*)tempBuffer = static_cast(ghoul2[i].mBltlist.size()); tempBuffer +=4; // lastly save the all the bolt list info @@ -1808,7 +1808,7 @@ void G2_LoadGhoul2Model(CGhoul2Info_v &ghoul2, char *buffer) } // this one isn't a define since I couldn't work out how to figure it out at compile time - int ghoul2BlockSize = (size_t)&ghoul2[0].mTransformedVertsArray - (size_t)&ghoul2[0].mModelindex; + int ghoul2BlockSize = static_cast((size_t)&ghoul2[0].mTransformedVertsArray - (size_t)&ghoul2[0].mModelindex); // now we have enough instances, lets go through each one and load up the relevant details for (int i=0; i= 0; i--) + for (i = static_cast(slist.size() - 1); i >= 0; i--) { if ((slist[i].surface != 10000) && (slist[i].surface != -1)) { @@ -324,7 +324,7 @@ void G2_RemoveRedundantGeneratedSurfaces(surfaceInfo_v &slist, int *activeSurfac // if it's not in the list, remove it if (!activeSurfaces[slist[i].genPolySurfaceIndex & 0xffff]) { - G2_RemoveSurface(slist, i); + G2_RemoveSurface(slist, static_cast(i)); } } // no, so it does point back at a legal surface @@ -333,7 +333,7 @@ void G2_RemoveRedundantGeneratedSurfaces(surfaceInfo_v &slist, int *activeSurfac // if it's not in the list, remove it if (!activeSurfaces[slist[i].surface]) { - G2_RemoveSurface(slist, i); + G2_RemoveSurface(slist, static_cast(i)); } } } @@ -534,7 +534,7 @@ int G2_AddSurface(CGhoul2Info *ghoul2, int surfaceNumber, int polyNumber, float ghoul2->mSlist[i].genBarycentricJ = BarycentricJ; ghoul2->mSlist[i].genPolySurfaceIndex = ((polyNumber & 0xffff) << 16) | (surfaceNumber & 0xffff); ghoul2->mSlist[i].genLod = lod; - return i; + return static_cast(i); } } @@ -549,7 +549,7 @@ int G2_AddSurface(CGhoul2Info *ghoul2, int surfaceNumber, int polyNumber, float ghoul2->mSlist.push_back(temp_slist_entry); - return (ghoul2->mSlist.size() -1 ); + return static_cast(ghoul2->mSlist.size() -1 ); } qboolean G2_RemoveSurface(surfaceInfo_v &slist, const int index) @@ -560,9 +560,9 @@ qboolean G2_RemoveSurface(surfaceInfo_v &slist, const int index) // set us to be the 'not active' state slist[index].surface = -1; - unsigned int newSize = slist.size(); + unsigned int newSize = static_cast(slist.size()); // now look through the list from the back and see if there is a block of -1's we can resize off the end of the list - for (int i=slist.size()-1; i>-1; i--) + for (int i=static_cast(slist.size()-1); i>-1; i--) { if (slist[i].surface == -1) { diff --git a/codemp/rd-vanilla/tr_arb.cpp b/codemp/rd-vanilla/tr_arb.cpp index 5f12c09996..23fd363140 100644 --- a/codemp/rd-vanilla/tr_arb.cpp +++ b/codemp/rd-vanilla/tr_arb.cpp @@ -207,7 +207,7 @@ void ARB_InitGPUShaders(void) { qglGenProgramsARB(1, &tr.gammaCorrectVtxShader); qglBindProgramARB(GL_VERTEX_PROGRAM_ARB, tr.gammaCorrectVtxShader); - qglProgramStringARB(GL_VERTEX_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, strlen(gammaCorrectVtxShader), gammaCorrectVtxShader); + qglProgramStringARB(GL_VERTEX_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, static_cast(strlen(gammaCorrectVtxShader)), gammaCorrectVtxShader); int errorChar; qglGetIntegerv(GL_PROGRAM_ERROR_POSITION_ARB, &errorChar); @@ -220,7 +220,7 @@ void ARB_InitGPUShaders(void) { { qglGenProgramsARB(1, &tr.gammaCorrectPxShader); qglBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, tr.gammaCorrectPxShader); - qglProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, strlen(gammaCorrectPxShader), gammaCorrectPxShader); + qglProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, static_cast(strlen(gammaCorrectPxShader)), gammaCorrectPxShader); qglGetIntegerv(GL_PROGRAM_ERROR_POSITION_ARB, &errorChar); if ( errorChar != -1 ) diff --git a/codemp/rd-vanilla/tr_bsp.cpp b/codemp/rd-vanilla/tr_bsp.cpp index a7f42c0cf1..befc3d3c29 100644 --- a/codemp/rd-vanilla/tr_bsp.cpp +++ b/codemp/rd-vanilla/tr_bsp.cpp @@ -383,7 +383,7 @@ static void ParseFace( dsurface_t *ds, mapVert_t *verts, msurface_t *surf, int * numIndexes = LittleLong( ds->numIndexes ); // create the srfSurfaceFace_t - sfaceSize = ( size_t ) &((srfSurfaceFace_t *)0)->points[numPoints]; + sfaceSize = static_cast(( size_t ) &((srfSurfaceFace_t *)0)->points[numPoints]); ofsIndexes = sfaceSize; sfaceSize += sizeof( int ) * numIndexes; @@ -1928,7 +1928,7 @@ void R_LoadEntities( lump_t *l, world_t &worldData ) { // check for remapping of shaders for vertex lighting s = "vertexremapshader"; - if (!Q_strncmp(keyname, s, strlen(s)) ) { + if (!Q_strncmp(keyname, s, static_cast(strlen(s))) ) { s = strchr(value, ';'); if (!s) { ri.Printf( PRINT_ALL, S_COLOR_YELLOW "WARNING: no semi colon in vertexshaderremap '%s'\n", value ); @@ -1942,7 +1942,7 @@ void R_LoadEntities( lump_t *l, world_t &worldData ) { } // check for remapping of shaders s = "remapshader"; - if (!Q_strncmp(keyname, s, strlen(s)) ) { + if (!Q_strncmp(keyname, s, static_cast(strlen(s))) ) { s = strchr(value, ';'); if (!s) { ri.Printf( PRINT_ALL, S_COLOR_YELLOW "WARNING: no semi colon in shaderremap '%s'\n", value ); diff --git a/codemp/rd-vanilla/tr_ghoul2.cpp b/codemp/rd-vanilla/tr_ghoul2.cpp index f4ca58b8d6..bab1506a09 100644 --- a/codemp/rd-vanilla/tr_ghoul2.cpp +++ b/codemp/rd-vanilla/tr_ghoul2.cpp @@ -2382,7 +2382,7 @@ void G2_ProcessGeneratedSurfaceBolts(CGhoul2Info &ghoul2, mdxaBone_v &bonePtr, m if (ghoul2.mSlist[i].offFlags & G2SURFACEFLAG_GENERATED) { // well alrighty then. Lets see if there is a bolt that is attempting to use it - int boltNum = G2_Find_Bolt_Surface_Num(ghoul2.mBltlist, i, G2SURFACEFLAG_GENERATED); + int boltNum = G2_Find_Bolt_Surface_Num(ghoul2.mBltlist, static_cast(i), G2SURFACEFLAG_GENERATED); // yes - ok, processing time. if (boltNum != -1) { diff --git a/codemp/rd-vanilla/tr_image.cpp b/codemp/rd-vanilla/tr_image.cpp index 23de173e30..ce7e81ee92 100644 --- a/codemp/rd-vanilla/tr_image.cpp +++ b/codemp/rd-vanilla/tr_image.cpp @@ -533,7 +533,7 @@ int giTextureBindNum = 1024; // will be set to this anyway at runtime, but wtf? int R_Images_StartIteration(void) { itAllocatedImages = AllocatedImages.begin(); - return AllocatedImages.size(); + return static_cast(AllocatedImages.size()); } image_t *R_Images_GetNextIteration(void) diff --git a/codemp/rd-vanilla/tr_init.cpp b/codemp/rd-vanilla/tr_init.cpp index 2fb27a4401..2a6f9a344b 100644 --- a/codemp/rd-vanilla/tr_init.cpp +++ b/codemp/rd-vanilla/tr_init.cpp @@ -764,8 +764,8 @@ static const char *TruncateGLExtensionsString (const char *extensionsString, int extensionsLen = p - extensionsString - 1; } - truncatedExtensions = (char *)Hunk_Alloc(extensionsLen + 1, h_low); - Q_strncpyz (truncatedExtensions, extensionsString, extensionsLen + 1); + truncatedExtensions = (char *)Hunk_Alloc(static_cast(extensionsLen + 1), h_low); + Q_strncpyz (truncatedExtensions, extensionsString, static_cast(extensionsLen + 1)); return truncatedExtensions; } @@ -912,7 +912,7 @@ byte *RB_ReadPixels(int x, int y, int width, int height, size_t *offset, int *pa padwidth = PAD(linelen, packAlign); // Allocate a few more bytes so that we can choose an alignment we like - buffer = (byte *)Hunk_AllocateTempMemory(padwidth * height + *offset + packAlign - 1); + buffer = (byte *)Hunk_AllocateTempMemory(static_cast(padwidth * height + *offset + packAlign - 1)); bufstart = (byte *)PADP((intptr_t) buffer + *offset, packAlign); qglReadPixels(x, y, width, height, GL_RGB, GL_UNSIGNED_BYTE, bufstart); @@ -976,9 +976,9 @@ void R_TakeScreenshot( int x, int y, int width, int height, char *fileName ) { // gamma correct if(glConfig.deviceSupportsGamma && !glConfigExt.doGammaCorrectionWithShaders) - R_GammaCorrect(allbuf + offset, memcount); + R_GammaCorrect(allbuf + offset, static_cast(memcount)); - ri.FS_WriteFile(fileName, buffer, memcount + 18); + ri.FS_WriteFile(fileName, buffer, static_cast(memcount + 18)); ri.Hunk_FreeTempMemory(allbuf); } @@ -1013,7 +1013,7 @@ void R_TakeScreenshotJPEG( int x, int y, int width, int height, char *fileName ) // gamma correct if(glConfig.deviceSupportsGamma && !glConfigExt.doGammaCorrectionWithShaders) - R_GammaCorrect(buffer + offset, memcount); + R_GammaCorrect(buffer + offset, static_cast(memcount)); RE_SaveJPG(fileName, r_screenshotJpegQuality->integer, width, height, buffer + offset, padlen); ri.Hunk_FreeTempMemory(buffer); @@ -1243,10 +1243,10 @@ const void *RB_TakeVideoFrameCmd( const void *data ) // Alignment stuff for glReadPixels padwidth = PAD(linelen, packAlign); - padlen = padwidth - linelen; + padlen = padwidth - static_cast(linelen); // AVI line padding avipadwidth = PAD(linelen, AVI_LINE_PADDING); - avipadlen = avipadwidth - linelen; + avipadlen = avipadwidth - static_cast(linelen); cBuf = (byte *)PADP(cmd->captureBuffer, packAlign); @@ -1257,14 +1257,14 @@ const void *RB_TakeVideoFrameCmd( const void *data ) // gamma correct if(glConfig.deviceSupportsGamma && !glConfigExt.doGammaCorrectionWithShaders) - R_GammaCorrect(cBuf, memcount); + R_GammaCorrect(cBuf, static_cast(memcount)); if(cmd->motionJpeg) { memcount = RE_SaveJPGToBuffer(cmd->encodeBuffer, linelen * cmd->height, r_aviMotionJpegQuality->integer, cmd->width, cmd->height, cBuf, padlen); - ri.CL_WriteAVIVideoFrame(cmd->encodeBuffer, memcount); + ri.CL_WriteAVIVideoFrame(cmd->encodeBuffer, static_cast(memcount)); } else { @@ -1357,7 +1357,7 @@ void R_PrintLongString(const char *string) { char buffer[1024]; const char *p = string; - int remainingLength = strlen(string); + int remainingLength = static_cast(strlen(string)); while (remainingLength > 0) { diff --git a/codemp/rd-vanilla/tr_model.cpp b/codemp/rd-vanilla/tr_model.cpp index 92c30ce4bd..5bbf5ebf62 100644 --- a/codemp/rd-vanilla/tr_model.cpp +++ b/codemp/rd-vanilla/tr_model.cpp @@ -234,7 +234,7 @@ void *RE_RegisterModels_Malloc(int iSize, void *pvDiskBufferIfJustLoaded, const { // if we already had this model entry, then re-register all the shaders it wanted... // - int iEntries = ModelBin.ShaderRegisterData.size(); + int iEntries = static_cast(ModelBin.ShaderRegisterData.size()); for (int i=0; isize(); + int iModels = static_cast(CachedModels->size()); int iModel = 0; for (CachedModels_t::iterator itModel = CachedModels->begin(); itModel != CachedModels->end(); ++itModel,iModel++) @@ -1566,7 +1566,7 @@ static qboolean R_LoadMD3 (model_t *mod, int lod, void *buffer, const char *mod_ // strip off a trailing _1 or _2 // this is a crutch for q3data being a mess - j = strlen( surf->name ); + j = static_cast(strlen( surf->name )); if ( j > 2 && surf->name[j-2] == '_' ) { surf->name[j-2] = 0; } diff --git a/codemp/rd-vanilla/tr_shade_calc.cpp b/codemp/rd-vanilla/tr_shade_calc.cpp index 254bdddf30..d53870056f 100644 --- a/codemp/rd-vanilla/tr_shade_calc.cpp +++ b/codemp/rd-vanilla/tr_shade_calc.cpp @@ -349,7 +349,7 @@ void DeformText( const char *text ) { VectorScale( width, height[2] * -0.75f, width ); // determine the starting position - len = strlen( text ); + len = static_cast(strlen( text )); VectorMA( origin, (len-1), width, origin ); // clear the shader indexes diff --git a/codemp/server/NPCNav/navigator.cpp b/codemp/server/NPCNav/navigator.cpp index 3331687cd3..ad483089d2 100644 --- a/codemp/server/NPCNav/navigator.cpp +++ b/codemp/server/NPCNav/navigator.cpp @@ -690,7 +690,7 @@ bool CNavigator::Save( const char *filename, int checksum ) //Write out the checksum FS_Write( &checksum, sizeof( checksum ), file ); - int numNodes = m_nodes.size(); + int numNodes = static_cast(m_nodes.size()); //Write out the number of nodes to follow FS_Write( &numNodes, sizeof(numNodes), file ); @@ -719,7 +719,7 @@ AddRawPoint int CNavigator::AddRawPoint( vec3_t point, int flags, int radius ) { - CNode *node = CNode::Create( point, flags, radius, m_nodes.size() ); + CNode *node = CNode::Create( point, flags, radius, static_cast(m_nodes.size()) ); if ( node == NULL ) { @@ -900,7 +900,7 @@ void CNavigator::CalculatePaths( qboolean recalc ) for ( size_t i = 0; i < m_nodes.size(); i++ ) { //Allocate the needed memory - m_nodes[i]->InitRanks( m_nodes.size() ); + m_nodes[i]->InitRanks( static_cast(m_nodes.size()) ); } for ( size_t i = 0; i < m_nodes.size(); i++ ) @@ -1300,7 +1300,7 @@ int CNavigator::CollectNearestNodes( vec3_t origin, int radius, int maxCollect, nChain.distance = dist; nodeChain.insert( nci, nChain ); - collected = nodeChain.size(); + collected = static_cast(nodeChain.size()); added = true; //If we've hit our collection limit, throw off the oldest one diff --git a/codemp/server/sv_ccmds.cpp b/codemp/server/sv_ccmds.cpp index 47c2deb879..ccdf773264 100644 --- a/codemp/server/sv_ccmds.cpp +++ b/codemp/server/sv_ccmds.cpp @@ -683,7 +683,7 @@ static void SV_WriteBans( void ) Com_sprintf( writebuf, sizeof( writebuf ), "%d %s %d\n", curban->isexception, NET_AdrToString( curban->ip ), curban->subnet ); - FS_Write( writebuf, strlen( writebuf ), writeto ); + FS_Write( writebuf, static_cast(strlen( writebuf )), writeto ); } FS_FCloseFile( writeto ); diff --git a/codemp/server/sv_challenge.cpp b/codemp/server/sv_challenge.cpp index 147c48da58..59efb6bec3 100644 --- a/codemp/server/sv_challenge.cpp +++ b/codemp/server/sv_challenge.cpp @@ -112,7 +112,7 @@ static int SV_CreateChallenge(int timestamp, netadr_t from) // Create an unforgeable, temporal challenge for this client using HMAC(secretKey, clientParams + timestamp) byte digest[MD5_DIGEST_SIZE]; - HMAC_MD5_Update(&challenger, (byte*)clientParams, clientParamsLen); + HMAC_MD5_Update(&challenger, (byte*)clientParams, static_cast(clientParamsLen)); HMAC_MD5_Update(&challenger, (byte*)×tamp, sizeof(timestamp)); HMAC_MD5_Final(&challenger, digest); HMAC_MD5_Reset(&challenger); diff --git a/codemp/server/sv_client.cpp b/codemp/server/sv_client.cpp index 073fbbe6a4..f69258f4bf 100644 --- a/codemp/server/sv_client.cpp +++ b/codemp/server/sv_client.cpp @@ -1185,9 +1185,9 @@ void SV_UserinfoChanged( client_t *cl ) { val = Info_ValueForKey( cl->userinfo, "ip" ); if( val[0] ) - len = strlen( ip ) - strlen( val ) + strlen( cl->userinfo ); + len = static_cast(strlen( ip ) - strlen( val ) + strlen( cl->userinfo )); else - len = strlen( ip ) + 4 + strlen( cl->userinfo ); + len = static_cast(strlen( ip ) + 4 + strlen( cl->userinfo )); if( len >= MAX_INFO_STRING ) SV_DropClient( cl, "userinfo string length exceeded" ); diff --git a/codemp/server/sv_init.cpp b/codemp/server/sv_init.cpp index be62b91bf1..a6e66476a6 100644 --- a/codemp/server/sv_init.cpp +++ b/codemp/server/sv_init.cpp @@ -42,7 +42,7 @@ static void SV_SendConfigstring(client_t *client, int index) int maxChunkSize = MAX_STRING_CHARS - 24; int len; - len = strlen(sv.configstrings[index]); + len = static_cast(strlen(sv.configstrings[index])); if( len >= maxChunkSize ) { int sent = 0; diff --git a/codemp/server/sv_main.cpp b/codemp/server/sv_main.cpp index 1bb2f7daf6..3071e9ddad 100644 --- a/codemp/server/sv_main.cpp +++ b/codemp/server/sv_main.cpp @@ -453,7 +453,7 @@ void SVC_Status( netadr_t from ) { ps = SV_GameClientNum( i ); Com_sprintf (player, sizeof(player), "%i %i \"%s\"\n", ps->persistant[PERS_SCORE], cl->ping, cl->name); - playerLength = strlen(player); + playerLength = static_cast(strlen(player)); if (statusLength + playerLength >= (int)sizeof(status) ) { break; // can't hold any more } diff --git a/codemp/ui/ui_force.c b/codemp/ui/ui_force.c index 898ad36880..ce3d3d5f7a 100644 --- a/codemp/ui/ui_force.c +++ b/codemp/ui/ui_force.c @@ -258,7 +258,7 @@ void UI_SaveForceTemplate() } Com_sprintf(fcfString, sizeof(fcfString), "%i-%i-", uiForceRank, uiForceSide); - strPlace = strlen(fcfString); + strPlace = (int)strlen(fcfString); while (forcePlace < NUM_FORCE_POWERS) { @@ -271,7 +271,7 @@ void UI_SaveForceTemplate() fcfString[strPlace] = '\n'; fcfString[strPlace+1] = 0; - trap->FS_Write(fcfString, strlen(fcfString), f); + trap->FS_Write(fcfString, (int)strlen(fcfString), f); trap->FS_Close(f); Com_Printf("Template saved as \"%s\".\n", selectedName); @@ -498,7 +498,7 @@ void UI_ReadLegalForce(void) //First, stick them into a string. Com_sprintf(fcfString, sizeof(fcfString), "%i-%i-", uiForceRank, uiForceSide); - strPlace = strlen(fcfString); + strPlace = (int)strlen(fcfString); while (forcePlace < NUM_FORCE_POWERS) { diff --git a/codemp/ui/ui_gameinfo.c b/codemp/ui/ui_gameinfo.c index f348d9cf19..4cd7da8fb8 100644 --- a/codemp/ui/ui_gameinfo.c +++ b/codemp/ui/ui_gameinfo.c @@ -87,7 +87,7 @@ int UI_ParseInfos( char *buf, int max, char *infos[] ) { Info_SetValueForKey( info, key, token ); } //NOTE: extra space for arena number - infos[count] = (char *) UI_Alloc(strlen(info) + strlen("\\num\\") + strlen(va("%d", MAX_ARENAS)) + 1); + infos[count] = (char *) UI_Alloc((int)(strlen(info) + strlen("\\num\\") + strlen(va("%d", MAX_ARENAS)) + 1)); if (infos[count]) { strcpy(infos[count], info); #ifndef FINAL_BUILD @@ -162,7 +162,7 @@ void UI_LoadArenas( void ) { numdirs = trap->FS_GetFileList( "scripts", ".arena", dirlist, ARRAY_LEN( dirlist ) ); dirptr = dirlist; for (i = 0; i < numdirs; i++, dirptr += dirlen+1) { - dirlen = strlen(dirptr); + dirlen = (int)strlen(dirptr); strcpy(filename, "scripts/"); strcat(filename, dirptr); UI_LoadArenasFromFile(filename); @@ -305,7 +305,7 @@ void UI_LoadBots( void ) { numdirs = trap->FS_GetFileList("scripts", ".bot", dirlist, 1024 ); dirptr = dirlist; for (i = 0; i < numdirs; i++, dirptr += dirlen+1) { - dirlen = strlen(dirptr); + dirlen = (int)strlen(dirptr); strcpy(filename, "scripts/"); strcat(filename, dirptr); UI_LoadBotsFromFile(filename); diff --git a/codemp/ui/ui_main.c b/codemp/ui/ui_main.c index 8ca16b705e..7b544b654a 100644 --- a/codemp/ui/ui_main.c +++ b/codemp/ui/ui_main.c @@ -3856,7 +3856,7 @@ static qboolean UI_Skill_HandleKey(int flags, float *special, int key) { } if (i < 1) { - i = numSkillLevels; + i = (int)numSkillLevels; } else if (i > numSkillLevels) { i = 1; } @@ -4071,7 +4071,7 @@ static qboolean UI_BotSkill_HandleKey(int flags, float *special, int key) { if (uiInfo.skillIndex >= numSkillLevels) { uiInfo.skillIndex = 0; } else if (uiInfo.skillIndex < 0) { - uiInfo.skillIndex = numSkillLevels-1; + uiInfo.skillIndex = (int)(numSkillLevels-1); } return qtrue; } @@ -4379,7 +4379,7 @@ static void UI_LoadMods() { numdirs = trap->FS_GetFileList( "$modlist", "", dirlist, sizeof(dirlist) ); dirptr = dirlist; for( i = 0; i < numdirs; i++ ) { - dirlen = strlen( dirptr ) + 1; + dirlen = (int)(strlen( dirptr ) + 1); descptr = dirptr + dirlen; uiInfo.modList[uiInfo.modCount].modName = String_Alloc(dirptr); uiInfo.modList[uiInfo.modCount].modDescr = String_Alloc(descptr); @@ -4409,7 +4409,7 @@ static void UI_LoadMovies() { } moviename = movielist; for ( i = 0; i < uiInfo.movieCount; i++ ) { - len = strlen( moviename ); + len = (int)strlen( moviename ); if (!Q_stricmp(moviename + len - 4, ".roq")) { moviename[len-4] = '\0'; } @@ -7427,10 +7427,10 @@ static void UI_BuildServerDisplayList(int force) { // do motd updates here too trap->Cvar_VariableStringBuffer( "cl_motdString", uiInfo.serverStatus.motd, sizeof(uiInfo.serverStatus.motd) ); - len = strlen(uiInfo.serverStatus.motd); + len = (int)strlen(uiInfo.serverStatus.motd); if (len == 0) { Q_strncpyz( uiInfo.serverStatus.motd, "Welcome to Jedi Academy MP!", sizeof( uiInfo.serverStatus.motd ) ); - len = strlen(uiInfo.serverStatus.motd); + len = (int)strlen(uiInfo.serverStatus.motd); } if (len != uiInfo.serverStatus.motdLen) { uiInfo.serverStatus.motdLen = len; @@ -7678,7 +7678,7 @@ static int UI_GetServerStatusInfo( const char *serverAddress, serverStatusInfo_t name = p; Com_sprintf(&info->pings[len], sizeof(info->pings)-len, "%d", i); info->lines[info->numLines][0] = &info->pings[len]; - len += strlen(&info->pings[len]) + 1; + len += (int)(strlen(&info->pings[len]) + 1); info->lines[info->numLines][1] = score; info->lines[info->numLines][2] = ping; info->lines[info->numLines][3] = name; @@ -8544,7 +8544,7 @@ static qhandle_t UI_FeederItemImage(float feederID, int index) { int i = 0; int skinPlace; - i = strlen(uiInfo.q3HeadNames[index]); + i = (int)strlen(uiInfo.q3HeadNames[index]); while (uiInfo.q3HeadNames[index][i] != '/') { @@ -8557,7 +8557,7 @@ static qhandle_t UI_FeederItemImage(float feederID, int index) { //now, build a full path out of what's in q3HeadNames, into iconNameFromSkinName Com_sprintf(iconNameFromSkinName, sizeof(iconNameFromSkinName), "models/players/%s", uiInfo.q3HeadNames[index]); - i = strlen(iconNameFromSkinName); + i = (int)strlen(iconNameFromSkinName); while (iconNameFromSkinName[i] != '/') { @@ -8569,7 +8569,7 @@ static qhandle_t UI_FeederItemImage(float feederID, int index) { Q_strcat(iconNameFromSkinName, 256, "icon_"); //and now, for the final step, append the skin name from q3HeadNames onto the end of iconNameFromSkinName - i = strlen(iconNameFromSkinName); + i = (int)strlen(iconNameFromSkinName); while (uiInfo.q3HeadNames[index][skinPlace]) { @@ -9368,7 +9368,7 @@ void UI_LoadForceConfig_List( void ) for (j=0; jFS_GetFileList("models/players", "/", dirlist, dirListSize ); + numdirs = trap->FS_GetFileList("models/players", "/", dirlist, (int)dirListSize ); dirptr = dirlist; for (i=0; iFS_Close(f); } - filelen = strlen(fileptr); + filelen = (int)strlen(fileptr); COM_StripExtension(fileptr,skinname,sizeof(skinname)); if (bIsImageFile(dirptr, skinname)) @@ -10207,11 +10207,11 @@ static void UI_ReadableSize ( char *buf, int bufsize, int value ) { if (value > 1024*1024*1024 ) { // gigs Com_sprintf( buf, bufsize, "%d", value / (1024*1024*1024) ); - Com_sprintf( buf+strlen(buf), bufsize-strlen(buf), ".%02d GB", + Com_sprintf( buf+strlen(buf), (int)(bufsize-strlen(buf)), ".%02d GB", (value % (1024*1024*1024))*100 / (1024*1024*1024) ); } else if (value > 1024*1024 ) { // megs Com_sprintf( buf, bufsize, "%d", value / (1024*1024) ); - Com_sprintf( buf+strlen(buf), bufsize-strlen(buf), ".%02d MB", + Com_sprintf( buf+strlen(buf), (int)(bufsize-strlen(buf)), ".%02d MB", (value % (1024*1024))*100 / (1024*1024) ); } else if (value > 1024 ) { // kilos Com_sprintf( buf, bufsize, "%d KB", value / 1024 ); diff --git a/codemp/ui/ui_shared.c b/codemp/ui/ui_shared.c index f2ed6d56f9..a0027101a1 100644 --- a/codemp/ui/ui_shared.c +++ b/codemp/ui/ui_shared.c @@ -243,7 +243,7 @@ const char *String_Alloc(const char *p) { str = str->next; } - len = strlen(p); + len = (int)strlen(p); if (len + strPoolIndex + 1 < STRING_POOL_SIZE) { int ph = strPoolIndex; strcpy(&strPool[strPoolIndex], p); @@ -3458,7 +3458,7 @@ void Item_TextField_Paste( itemDef_t *item ) { } // send as if typed, so insert / overstrike works properly - pasteLen = strlen( buff ); + pasteLen = (int)strlen( buff ); for ( i = 0; i < pasteLen; i++ ) { Item_TextField_HandleKey( item, buff[i]|K_CHAR_FLAG ); } @@ -3475,7 +3475,7 @@ qboolean Item_TextField_HandleKey(itemDef_t *item, int key) { buff[0] = 0; DC->getCVarString(item->cvar, buff, sizeof(buff)); - len = strlen(buff); + len = (int)strlen(buff); if (editPtr->maxChars && len > editPtr->maxChars) { len = editPtr->maxChars; } @@ -4971,7 +4971,7 @@ int BindingIDFromName( const char *name ) { // iterate each command, set its default binding for ( i=0; i < g_bindCount; i++ ) { if ( !Q_stricmp( name, g_bindCommands[i] ) ) - return i; + return (int)i; } return -1; } diff --git a/lib/jpeg-9a/jdatadst.c b/lib/jpeg-9a/jdatadst.c index 5c8681c9e4..ea31492d94 100644 --- a/lib/jpeg-9a/jdatadst.c +++ b/lib/jpeg-9a/jdatadst.c @@ -182,7 +182,7 @@ term_mem_destination (j_compress_ptr cinfo) my_mem_dest_ptr dest = (my_mem_dest_ptr) cinfo->dest; *dest->outbuffer = dest->buffer; - *dest->outsize = dest->bufsize - dest->pub.free_in_buffer; + *dest->outsize = (unsigned long)(dest->bufsize - dest->pub.free_in_buffer); } diff --git a/lib/jpeg-9a/jmemmgr.c b/lib/jpeg-9a/jmemmgr.c index 0a137cdde4..de0a3c7438 100644 --- a/lib/jpeg-9a/jmemmgr.c +++ b/lib/jpeg-9a/jmemmgr.c @@ -304,7 +304,7 @@ alloc_small (j_common_ptr cinfo, int pool_id, size_t sizeofobject) if (slop < MIN_SLOP) /* give up when it gets real small */ out_of_memory(cinfo, 2); /* jpeg_get_small failed */ } - mem->total_space_allocated += min_request + slop; + mem->total_space_allocated += (long)(min_request + slop); /* Success, initialize the new pool header and add to end of list */ hdr_ptr->hdr.next = NULL; hdr_ptr->hdr.bytes_used = 0; @@ -364,7 +364,7 @@ alloc_large (j_common_ptr cinfo, int pool_id, size_t sizeofobject) SIZEOF(large_pool_hdr)); if (hdr_ptr == NULL) out_of_memory(cinfo, 4); /* jpeg_get_large failed */ - mem->total_space_allocated += sizeofobject + SIZEOF(large_pool_hdr); + mem->total_space_allocated += (long)(sizeofobject + SIZEOF(large_pool_hdr)); /* Success, initialize the new pool header and add to list */ hdr_ptr->hdr.next = mem->large_list[pool_id]; @@ -974,7 +974,7 @@ free_pool (j_common_ptr cinfo, int pool_id) lhdr_ptr->hdr.bytes_left + SIZEOF(large_pool_hdr); jpeg_free_large(cinfo, (void FAR *) lhdr_ptr, space_freed); - mem->total_space_allocated -= space_freed; + mem->total_space_allocated -= (long)space_freed; lhdr_ptr = next_lhdr_ptr; } @@ -988,7 +988,7 @@ free_pool (j_common_ptr cinfo, int pool_id) shdr_ptr->hdr.bytes_left + SIZEOF(small_pool_hdr); jpeg_free_small(cinfo, (void *) shdr_ptr, space_freed); - mem->total_space_allocated -= space_freed; + mem->total_space_allocated -= (long)space_freed; shdr_ptr = next_shdr_ptr; } } diff --git a/shared/sys/con_win32.cpp b/shared/sys/con_win32.cpp index 30261a2a81..a03947bbe0 100644 --- a/shared/sys/con_win32.cpp +++ b/shared/sys/con_win32.cpp @@ -138,7 +138,7 @@ static void CON_HistPrev( void ) qconsole_history_pos = pos; Q_strncpyz( qconsole_line, qconsole_history[ qconsole_history_pos ], sizeof( qconsole_line ) ); - qconsole_linelen = strlen( qconsole_line ); + qconsole_linelen = static_cast(strlen( qconsole_line )); qconsole_cursor = qconsole_linelen; } @@ -169,7 +169,7 @@ static void CON_HistNext( void ) qconsole_history_pos = pos; Q_strncpyz( qconsole_line, qconsole_history[ qconsole_history_pos ], sizeof( qconsole_line ) ); - qconsole_linelen = strlen( qconsole_line ); + qconsole_linelen = static_cast(strlen( qconsole_line )); qconsole_cursor = qconsole_linelen; } @@ -406,7 +406,7 @@ char *CON_Input( void ) Q_strncpyz( f.buffer, qconsole_line, sizeof( f.buffer ) ); Field_AutoComplete( &f ); Q_strncpyz( qconsole_line, f.buffer, sizeof( qconsole_line ) ); - qconsole_linelen = strlen( qconsole_line ); + qconsole_linelen = static_cast(strlen( qconsole_line )); qconsole_cursor = qconsole_linelen; break; diff --git a/shared/sys/sys_event.cpp b/shared/sys/sys_event.cpp index 6bf884f42e..e3ebb317d2 100644 --- a/shared/sys/sys_event.cpp +++ b/shared/sys/sys_event.cpp @@ -75,7 +75,7 @@ sysEvent_t Sys_GetEvent( void ) { char *b; int len; - len = strlen( s ) + 1; + len = static_cast(strlen( s ) + 1); b = (char *)Z_Malloc( len,TAG_EVENT,qfalse ); strcpy( b, s ); Sys_QueEvent( 0, SE_CONSOLE, 0, 0, len, b ); diff --git a/shared/sys/sys_main.cpp b/shared/sys/sys_main.cpp index fd103e713f..da6f12bb3b 100644 --- a/shared/sys/sys_main.cpp +++ b/shared/sys/sys_main.cpp @@ -109,8 +109,8 @@ char *Sys_GetClipboardData( void ) { char *cbText = SDL_GetClipboardText(); size_t len = strlen( cbText ) + 1; - char *buf = (char *)Z_Malloc( len, TAG_CLIPBOARD ); - Q_strncpyz( buf, cbText, len ); + char *buf = (char *)Z_Malloc( static_cast(len), TAG_CLIPBOARD ); + Q_strncpyz( buf, cbText, static_cast(len) ); SDL_free( cbText ); return buf; From 92fff5a404cf8e04605a88f3770f77b66dcb8fad Mon Sep 17 00:00:00 2001 From: Jonathan Horner Date: Tue, 1 Jun 2021 22:00:08 +0100 Subject: [PATCH 10/10] Fixed some int -> float conversion warnings. --- shared/qcommon/q_math.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/shared/qcommon/q_math.c b/shared/qcommon/q_math.c index b15b3dbaf4..dedb3dd0ef 100644 --- a/shared/qcommon/q_math.c +++ b/shared/qcommon/q_math.c @@ -1259,9 +1259,9 @@ void SnapVector( float *v ) __asm fistp i *v = (float)i; #else // mac, linux, mingw - v[0] = (int)v[0]; - v[1] = (int)v[1]; - v[2] = (int)v[2]; + v[0] = (float)((int)v[0]); + v[1] = (float)((int)v[1]); + v[2] = (float)((int)v[2]); #endif }