diff --git a/common/GameUI/scriptobject.cpp b/common/GameUI/scriptobject.cpp index 672c1a43f..aed8d0bd9 100644 --- a/common/GameUI/scriptobject.cpp +++ b/common/GameUI/scriptobject.cpp @@ -417,7 +417,7 @@ void CScriptObject::WriteToConfig( ) if ( pItem ) { - V_sprintf_safe( szValue, "%s", pItem->szValue ); + V_strcpy_safe( szValue, pItem->szValue ); V_StripInvalidCharacters( szValue ); } else //Couldn't find index diff --git a/common/vscript_utils.h b/common/vscript_utils.h index fce7ce2c9..992ab3fa1 100644 --- a/common/vscript_utils.h +++ b/common/vscript_utils.h @@ -62,7 +62,7 @@ inline bool ScriptVmStringFromVariant( ScriptVariant_t &varValue, char (&chScrat V_sprintf_safe( chScratchBuffer, "%c", ( char ) varValue ); return true; case FIELD_CSTRING: - V_sprintf_safe( chScratchBuffer, "%s", ( const char * ) varValue ); + V_strcpy_safe( chScratchBuffer, ( const char * ) varValue ); return true; default: Warning( "ScriptVmStringFromVariant failed to unpack parameter variant type %d\n", varValue.GetType() ); diff --git a/dedicated/sys_common.cpp b/dedicated/sys_common.cpp index b917aaaef..e6907c8e4 100644 --- a/dedicated/sys_common.cpp +++ b/dedicated/sys_common.cpp @@ -114,7 +114,7 @@ const char *PrefixMessageGroup(char (&out)[out_size], const char *group, if (length > 1 && message[length - 1] == '\n') { V_sprintf_safe(out, "[%.3f][%s] %s", Plat_FloatTime(), out_group, message); } else { - V_sprintf_safe(out, "%s", message); + V_strcpy_safe(out, message); } return out; diff --git a/engine/DownloadListGenerator.cpp b/engine/DownloadListGenerator.cpp index 7ad64d610..7754ab3a5 100644 --- a/engine/DownloadListGenerator.cpp +++ b/engine/DownloadListGenerator.cpp @@ -121,7 +121,7 @@ void CDownloadListGenerator::OnLevelLoadStart(const char *levelName) Q_FixSlashes( m_gameDir ); // save off the map name - Q_snprintf( m_mapName, sizeof( m_mapName ), "%s", levelName ); + V_strcpy_safe( m_mapName, levelName ); } //----------------------------------------------------------------------------- diff --git a/engine/audio/private/snd_dev_xaudio.cpp b/engine/audio/private/snd_dev_xaudio.cpp index 1ba874e2f..636dd502e 100644 --- a/engine/audio/private/snd_dev_xaudio.cpp +++ b/engine/audio/private/snd_dev_xaudio.cpp @@ -48,7 +48,7 @@ const char *PrefixMessageGroup(char (&out)[out_size], const char *group, if (length > 1 && message[length - 1] == '\n') { V_sprintf_safe(out, "[%.3f][%s] %s", Plat_FloatTime(), group, message); } else { - V_sprintf_safe(out, "%s", message); + V_strcpy_safe(out, message); } return out; diff --git a/engine/audio/private/vox.cpp b/engine/audio/private/vox.cpp index 8d5ae8f90..47352faba 100644 --- a/engine/audio/private/vox.cpp +++ b/engine/audio/private/vox.cpp @@ -2031,7 +2031,7 @@ void VOX_TouchSound( const char *pszin, CUtlDict< int, int >& filelist, CUtlRBTr for ( intp j = 0 ; j < c; ++j ) { char name[ 256 ]; - Q_snprintf( name, sizeof( name ), "%s", list[ j ].word ); + V_strcpy_safe( name, list[ j ].word ); if ( !Q_strnicmp( name, "V_", 2 ) ) { diff --git a/engine/baseautocompletefilelist.cpp b/engine/baseautocompletefilelist.cpp index 8d8fa9098..1c4aecc3b 100644 --- a/engine/baseautocompletefilelist.cpp +++ b/engine/baseautocompletefilelist.cpp @@ -52,7 +52,7 @@ int CBaseAutoCompleteFileList::AutoCompletionFunc( char const *partial, char com while ( findfn ) { - Q_snprintf( sz, sizeof( sz ), "%s", findfn ); + V_strcpy_safe( sz, findfn ); bool add = false; // Insert into lookup diff --git a/engine/baseclient.cpp b/engine/baseclient.cpp index 1ea49b62e..3c141a34f 100644 --- a/engine/baseclient.cpp +++ b/engine/baseclient.cpp @@ -28,6 +28,7 @@ #include "iregistry.h" #include "sv_main.h" #include "hltvserver.h" +#include #ifdef REPLAY_ENABLED #include "replay_internal.h" @@ -1152,7 +1153,9 @@ void CBaseClient::SendSnapshot( CClientFrame *pFrame ) bool bFailedOnce = false; write_again: - bf_write msg( "CBaseClient::SendSnapshot", m_SnapshotScratchBuffer, sizeof( m_SnapshotScratchBuffer ) ); + // RaphaelIT7: Were deep in networking and the stack can easily get close to an overflow + static thread_local std::unique_ptr pSnapshotScratchBuffer(new unsigned int[g_nScratchBufferSizeAsInt]); + bf_write msg( "CBaseClient::SendSnapshot", pSnapshotScratchBuffer.get(), SNAPSHOT_SCRATCH_BUFFER_SIZE ); TRACE_PACKET( ( "SendSnapshot(%d)\n", pFrame->tick_count ) ); @@ -1625,7 +1628,7 @@ const char *GetUserIDString( const USERID_t& id ) } else { - V_sprintf_safe( idstr, "%s", id.steamid.Render() ); + V_strcpy_safe( idstr, id.steamid.Render() ); } } break; diff --git a/engine/baseclient.h b/engine/baseclient.h index 082ca7c34..299b335d9 100644 --- a/engine/baseclient.h +++ b/engine/baseclient.h @@ -276,8 +276,7 @@ class CBaseClient : public IGameEventListener2, public IClient, public IClientMe { SNAPSHOT_SCRATCH_BUFFER_SIZE = 160000, }; - - unsigned int m_SnapshotScratchBuffer[ SNAPSHOT_SCRATCH_BUFFER_SIZE / 4 ]; + static constexpr int g_nScratchBufferSizeAsInt = SNAPSHOT_SCRATCH_BUFFER_SIZE / sizeof(unsigned int); private: void StartTrace( bf_write &msg ); diff --git a/engine/bugreporter.cpp b/engine/bugreporter.cpp index 4e98c41bd..05153e705 100644 --- a/engine/bugreporter.cpp +++ b/engine/bugreporter.cpp @@ -1275,11 +1275,11 @@ void CBugUIPanel::OnFileSelected( char const *fullpath ) // // if ( baseDirFile ) // { - // V_sprintf_safe( inc.fixedname, "%s", inc.name+3 ); // strip the "..\" + // V_strcpy_safe( inc.fixedname, inc.name+3 ); // strip the "..\" // } // else // { - // V_sprintf_safe( inc.fixedname, "%s", inc.name ); + // V_strcpy_safe( inc.fixedname, inc.name ); // } // V_FixSlashes( inc.fixedname ); // @@ -1733,7 +1733,7 @@ void CBugUIPanel::OnSubmit() } else { - Q_snprintf( title, sizeof( title ), "%s", temp ); + V_strcpy_safe( title, temp ); } Msg( "title: %s\n", title ); diff --git a/engine/cdll_engine_int.cpp b/engine/cdll_engine_int.cpp index cd2760bb4..dd78be0cf 100644 --- a/engine/cdll_engine_int.cpp +++ b/engine/cdll_engine_int.cpp @@ -2175,7 +2175,7 @@ bool CEngineClient::StartDemoRecording( const char *pszFilename, const char *psz } else { - V_sprintf_safe( szTemp, "%s", pszFilename ); + V_strcpy_safe( szTemp, pszFilename ); } // remove .dem extension if it exists @@ -2246,7 +2246,7 @@ void CEngineClient::TakeScreenshot( const char *pszFilename, const char *pszFold } else { - V_sprintf_safe( szFinal, "%s", pszFilename ); + V_strcpy_safe( szFinal, pszFilename ); } V_SetExtension( szFinal, ".tga" ); diff --git a/engine/cl_main.cpp b/engine/cl_main.cpp index ce35d4476..cf74482f7 100644 --- a/engine/cl_main.cpp +++ b/engine/cl_main.cpp @@ -1084,7 +1084,7 @@ void CL_FullyConnected( void ) float map_loadtime_start = dev_loadtime_map_start.GetFloat(); if (map_loadtime_start > 0.0) { - float elapsed = Plat_FloatTime() - map_loadtime_start; + float elapsed = static_cast( Plat_FloatTime() - map_loadtime_start ); dev_loadtime_map_elapsed.SetValue( elapsed ); // Clear this for next time so we know we did. @@ -1156,7 +1156,7 @@ void CL_TakeScreenshot(const char *name) if ( !Q_isempty( cl_screenshotname.GetString() ) ) { - Q_snprintf( cl_snapshotname, sizeof( cl_snapshotname ), "%s", cl_screenshotname.GetString() ); + V_strcpy_safe( cl_snapshotname, cl_screenshotname.GetString() ); } } diff --git a/engine/cvar.cpp b/engine/cvar.cpp index 7b9f01a03..af1b5d948 100644 --- a/engine/cvar.cpp +++ b/engine/cvar.cpp @@ -771,7 +771,7 @@ static void PrintCommand( const ConCommand *cmd, bool logging, FileHandle_t& f ) // Names staring with +/- need to be wrapped in single quotes char name[ 256 ]; - Q_snprintf( name, sizeof( name ), "%s", cmd->GetName() ); + V_strcpy_safe( name, cmd->GetName() ); if ( name[ 0 ] == '+' || name[ 0 ] == '-' ) { Q_snprintf( name, sizeof( name ), "'%s'", cmd->GetName() ); @@ -820,7 +820,7 @@ void CCvarUtilities::CvarList( const CCommand &args ) if ( V_strieq( args[1],"log" ) && iArgs >= 3 ) { char fn[256]; - Q_snprintf( fn, sizeof( fn ), "%s", args[2] ); + V_strcpy_safe( fn, args[2] ); f = g_pFileSystem->Open( fn,"wb" ); if ( f ) { diff --git a/engine/hltvserver.cpp b/engine/hltvserver.cpp index 4153e2860..5666ee7e7 100644 --- a/engine/hltvserver.cpp +++ b/engine/hltvserver.cpp @@ -1442,7 +1442,7 @@ void CHLTVServer::UpdateStats( void ) else { // forward address - Q_snprintf( address, sizeof(address), "%s", m_RootServer.ToString() ); + V_strcpy_safe( address, m_RootServer.ToString() ); } event->SetString( "master", address ); diff --git a/engine/host.cpp b/engine/host.cpp index d9ae81a6a..a73193b46 100644 --- a/engine/host.cpp +++ b/engine/host.cpp @@ -1611,7 +1611,7 @@ char const * Host_CleanupConVarStringValue( char const *invalue ) { static char clean[ 256 ]; - V_sprintf_safe( clean, "%s", invalue ); + V_strcpy_safe( clean, invalue ); // Don't mess with empty string // Otherwise, if it appears numeric and has a decimal, try to strip all zeroes after decimal diff --git a/engine/host_cmd.cpp b/engine/host_cmd.cpp index 2f5ff892f..0cffc334a 100644 --- a/engine/host_cmd.cpp +++ b/engine/host_cmd.cpp @@ -1111,7 +1111,7 @@ CON_COMMAND( kickid, "Kick a player by userid or uniqueid, with a message." ) // NOTE: assumed to be one argument else { - Q_snprintf( szSearchString, sizeof( szSearchString ), "%s", pszArg1 ); + V_strcpy_safe( szSearchString, pszArg1 ); } } // this is a userid diff --git a/engine/staticpropmgr.cpp b/engine/staticpropmgr.cpp index 0e76682f4..757ca1830 100644 --- a/engine/staticpropmgr.cpp +++ b/engine/staticpropmgr.cpp @@ -934,7 +934,7 @@ void CStaticProp::DisplayStaticPropInfo( int nInfoType ) switch( nInfoType ) { case 1: - Q_snprintf( buf, sizeof( buf ), "%s", modelloader->GetName( m_pModel ) ); + V_strcpy_safe( buf, modelloader->GetName( m_pModel ) ); break; case 2: diff --git a/engine/sv_filter.cpp b/engine/sv_filter.cpp index fdb71a5d2..237ee8264 100644 --- a/engine/sv_filter.cpp +++ b/engine/sv_filter.cpp @@ -578,7 +578,7 @@ CON_COMMAND( removeid, "Remove a user ID from the ban list." ) { bValid = id->steamid.IsValid(); if ( bValid ) - V_sprintf_safe( szSearchString, "%s", id->steamid.Render() ); + V_strcpy_safe( szSearchString, id->steamid.Render() ); } } else @@ -590,7 +590,7 @@ CON_COMMAND( removeid, "Remove a user ID from the ban list." ) bValid = cSteamIDCheck.IsValid(); if ( bValid ) - V_sprintf_safe( szSearchString, "%s", cSteamIDCheck.Render() ); + V_strcpy_safe( szSearchString, cSteamIDCheck.Render() ); } } @@ -758,7 +758,7 @@ CON_COMMAND( banid, "Add a user ID to the ban list." ) bValid = cSteamIDCheck.IsValid(); if ( bValid ) - V_sprintf_safe( szSearchString, "%s", cSteamIDCheck.Render() ); + V_strcpy_safe( szSearchString, cSteamIDCheck.Render() ); } } diff --git a/engine/sys_dll.cpp b/engine/sys_dll.cpp index bdf277e19..2b4b536f3 100644 --- a/engine/sys_dll.cpp +++ b/engine/sys_dll.cpp @@ -736,7 +736,7 @@ const char *PrefixMessageGroup(char (&out)[out_size], const char *group, if (length > 1 && message[length - 1] == '\n') { V_sprintf_safe(out, "[%.3f][%s] %s", Plat_FloatTime(), out_group, message); } else { - V_sprintf_safe(out, "%s", message); + V_strcpy_safe(out, message); } return out; diff --git a/engine/vgui_drawtreepanel.cpp b/engine/vgui_drawtreepanel.cpp index d3cb42fa1..a9f2e63eb 100644 --- a/engine/vgui_drawtreepanel.cpp +++ b/engine/vgui_drawtreepanel.cpp @@ -350,10 +350,7 @@ void VGui_RecursivePrintTree( // Bind data to pVal. char name[1024]; const char *pInputName = ipanel->GetName( current ); - if ( !Q_isempty( pInputName ) ) - V_sprintf_safe( name, "%s", pInputName ); - else - V_sprintf_safe( name, "%s", "(no name)" ); + V_strcpy_safe( name, !Q_isempty( pInputName ) ? pInputName : "(no name)" ); if ( ipanel->IsMouseInputEnabled( current ) ) { @@ -387,7 +384,7 @@ void VGui_RecursivePrintTree( V_sprintf_safe( str, "%s - [%d]", name, kv->GetInt("alpha") ); } else - V_sprintf_safe( str, "%s", name ); + V_strcpy_safe( str, name ); pVal->SetString( "Text", str ); // dimhotepus: SetInt -> SetPtr diff --git a/filesystem/linux_support.cpp b/filesystem/linux_support.cpp index 7c43cd956..a4709480d 100644 --- a/filesystem/linux_support.cpp +++ b/filesystem/linux_support.cpp @@ -86,7 +86,7 @@ int FillDataStruct( FIND_DATA *dat ) dat->dwFileAttributes = !stat( szFullPath, &fileStat ) ? fileStat.st_mode : 0; // now just put the filename in the output data - V_sprintf_safe( dat->cFileName, "%s", name->d_name ); + V_strcpy_safe( dat->cFileName, name->d_name ); free( name ); diff --git a/game/client/c_baseflex.cpp b/game/client/c_baseflex.cpp index 70db864f9..2ab7e77ce 100644 --- a/game/client/c_baseflex.cpp +++ b/game/client/c_baseflex.cpp @@ -180,7 +180,7 @@ void C_BaseFlex::SetupMappings( char const *pchFileRoot ) memset( m_PhonemeClasses, 0, sizeof( m_PhonemeClasses ) ); Emphasized_Phoneme *normal = &m_PhonemeClasses[ PHONEME_CLASS_NORMAL ]; - Q_snprintf( normal->classname, sizeof( normal->classname ), "%s", pchFileRoot ); + V_strcpy_safe( normal->classname, pchFileRoot ); normal->required = true; Emphasized_Phoneme *weak = &m_PhonemeClasses[ PHONEME_CLASS_WEAK ]; diff --git a/game/client/cdll_util.cpp b/game/client/cdll_util.cpp index d3c9e4d25..f991d27d6 100644 --- a/game/client/cdll_util.cpp +++ b/game/client/cdll_util.cpp @@ -923,7 +923,7 @@ void UTIL_ReplaceKeyBindings( const wchar_t *inbuf, intp inbufsizebytes, OUT_Z_B //!! change some key names into better names char friendlyName[64]; bool bAddBrackets = false; - V_sprintf_safe( friendlyName, "%s", key ); + V_strcpy_safe( friendlyName, key ); V_strupr( friendlyName ); const wchar_t* locName = nullptr; diff --git a/game/client/cstrike/VGUI/cstrikespectatorgui.cpp b/game/client/cstrike/VGUI/cstrikespectatorgui.cpp index 9c633c1d8..ef963c845 100644 --- a/game/client/cstrike/VGUI/cstrikespectatorgui.cpp +++ b/game/client/cstrike/VGUI/cstrikespectatorgui.cpp @@ -1711,7 +1711,7 @@ bool CCSMapOverview::CreateRadarImage(const char *mapName, const char * radarFil // And need a vmt file to go with it. char vmtFilename[MAX_PATH]; - Q_snprintf(vmtFilename, MAX_PATH, "%s", fullRadarFileName); + V_strcpy_safe(vmtFilename, fullRadarFileName); char *extension = &vmtFilename[Q_strlen(vmtFilename) - 3]; *extension++ = 'v'; *extension++ = 'm'; diff --git a/game/client/cstrike/cs_hud_freezepanel.cpp b/game/client/cstrike/cs_hud_freezepanel.cpp index 36fdf8254..68932c421 100644 --- a/game/client/cstrike/cs_hud_freezepanel.cpp +++ b/game/client/cstrike/cs_hud_freezepanel.cpp @@ -319,7 +319,7 @@ void CCSFreezePanel::SetActive( bool bActive ) } char szKey[16]; - Q_snprintf( szKey, sizeof(szKey), "%s", pKey ); + V_strcpy_safe( szKey, pKey ); wchar_t wKey[16]; wchar_t wLabel[256]; diff --git a/game/client/dod/dod_hud_freezepanel.cpp b/game/client/dod/dod_hud_freezepanel.cpp index 0d289707e..df60dc91c 100644 --- a/game/client/dod/dod_hud_freezepanel.cpp +++ b/game/client/dod/dod_hud_freezepanel.cpp @@ -535,7 +535,7 @@ void CDODFreezePanel::ShowSnapshotPanel( bool bShow ) if ( bShow ) { char szKey[16]; - Q_snprintf( szKey, sizeof(szKey), "%s", key ); + V_strcpy_safe( szKey, key ); wchar_t wKey[16]; wchar_t wLabel[256]; diff --git a/game/client/dod/dod_hud_hintdisplay.cpp b/game/client/dod/dod_hud_hintdisplay.cpp index 0c81c138d..75c3bafd2 100644 --- a/game/client/dod/dod_hud_hintdisplay.cpp +++ b/game/client/dod/dod_hud_hintdisplay.cpp @@ -171,7 +171,7 @@ bool CDODHudHintDisplay::SetHintText( wchar_t *text ) //!! change some key names into better names char friendlyName[64]; - Q_snprintf( friendlyName, sizeof(friendlyName), "%s", key ); + V_strcpy_safe( friendlyName, key ); Q_strupr( friendlyName ); g_pVGuiLocalize->ConvertANSIToUnicode( friendlyName, token, sizeof(token) ); diff --git a/game/client/hud_lcd.cpp b/game/client/hud_lcd.cpp index 9f95076d4..721b07a7b 100644 --- a/game/client/hud_lcd.cpp +++ b/game/client/hud_lcd.cpp @@ -1356,7 +1356,7 @@ void CLCD::LookupToken( char const *in, CUtlString& value ) case FIELD_STRING: { string_t *pString = (string_t *)((string_t *)pInputData + iIndex ); - Q_snprintf( sz, sizeof( sz ), "%s", pString ? STRING( *pString ) : "" ); + V_strcpy_safe( sz, pString ? STRING( *pString ) : "" ); } break; case FIELD_VECTOR: @@ -1373,7 +1373,7 @@ void CLCD::LookupToken( char const *in, CUtlString& value ) break; case FIELD_BOOLEAN: - Q_snprintf( sz, sizeof( sz ), "%s", *( ( const bool *)pInputData + iIndex ) ? "true" : "false" ); + V_strcpy_safe( sz, *( ( const bool *)pInputData + iIndex ) ? "true" : "false" ); break; case FIELD_INTEGER: V_to_chars( sz, *( (const int *)pInputData + iIndex )); @@ -1384,7 +1384,7 @@ void CLCD::LookupToken( char const *in, CUtlString& value ) break; case FIELD_CHARACTER: - Q_snprintf( sz, sizeof( sz ), "%s", ((const char *)pInputData + iIndex ) ); + V_strcpy_safe( sz, ((const char *)pInputData + iIndex ) ); break; } diff --git a/game/client/hud_pdump.cpp b/game/client/hud_pdump.cpp index 7f62ed5be..61f9de721 100644 --- a/game/client/hud_pdump.cpp +++ b/game/client/hud_pdump.cpp @@ -78,7 +78,7 @@ void CPDumpPanel::DumpComparision( const char *classname, const char *fieldname, DumpInfo *slot = &m_DumpEntityInfo[ idx ]; - Q_snprintf( slot->classname, sizeof( slot->classname ), "%s", classname ); + V_strcpy_safe( slot->classname, classname ); slot->networked = networked; Q_snprintf( slot->fieldstring, sizeof( slot->fieldstring ), "%s %s", fieldname, @@ -318,7 +318,7 @@ void CPDumpPanel::Paint() surface()->DrawSetTextFont( m_FontMedium ); surface()->DrawSetTextColor( Color( 0, 255, 100, 255 ) ); surface()->DrawSetTextPos( x[ col ] - 10, y ); - Q_snprintf( sz, sizeof( sz ), "%s", slot->classname ); + V_strcpy_safe( sz, slot->classname ); g_pVGuiLocalize->ConvertANSIToUnicode( sz, szconverted ); surface()->DrawPrintText( szconverted, V_wcslen( szconverted ) ); @@ -333,7 +333,7 @@ void CPDumpPanel::Paint() surface()->DrawSetTextFont( m_FontSmall ); surface()->DrawSetTextColor( Color( r, g, b, a ) ); surface()->DrawSetTextPos( x[ col ], y ); - Q_snprintf( sz, sizeof( sz ), "%s", slot->fieldstring ); + V_strcpy_safe( sz, slot->fieldstring ); g_pVGuiLocalize->ConvertANSIToUnicode( sz, szconverted ); surface()->DrawPrintText( szconverted, V_wcslen( szconverted ) ); diff --git a/game/client/in_steamcontroller.cpp b/game/client/in_steamcontroller.cpp index ed712c3f1..5acc85c66 100644 --- a/game/client/in_steamcontroller.cpp +++ b/game/client/in_steamcontroller.cpp @@ -269,7 +269,7 @@ void CInput::SteamControllerMove( float flFrametime, CUserCmd *cmd ) if ( ( data.bState && !state.bAwaitingDebounce ) || state.cmd[0] == '+' ) { char cmdbuf[128]; - Q_snprintf( cmdbuf, sizeof( cmdbuf ), "%s", state.cmd ); + V_strcpy_safe( cmdbuf, state.cmd ); if ( !data.bState ) { cmdbuf[0] = '-'; diff --git a/game/client/mp3player.cpp b/game/client/mp3player.cpp index 421d3f0d7..8c801e695 100644 --- a/game/client/mp3player.cpp +++ b/game/client/mp3player.cpp @@ -1055,7 +1055,7 @@ MP3Dir_t *CMP3Player::FindOrAddSubdirectory( MP3Dir_t *parent, char const *dirna char fullpath[ 512 ]; if ( Q_isempty( parent->m_FullDirPath.String() ) ) { - V_sprintf_safe( fullpath, "%s", dirname ); + V_strcpy_safe( fullpath, dirname ); } else { @@ -1135,7 +1135,7 @@ void CMP3Player::RecursiveFindMP3Files( SoundDirectory_t *root, char const *curr } else { - V_sprintf_safe( nextdir, "%s", fn ); + V_strcpy_safe( nextdir, fn ); } RecursiveFindMP3Files( root, nextdir, pathID ); @@ -1160,7 +1160,7 @@ void CMP3Player::RecursiveFindMP3Files( SoundDirectory_t *root, char const *curr } else { - V_sprintf_safe( relative, "%s", fn ); + V_strcpy_safe( relative, fn ); } } Msg( "Found '%s/%s'\n", current, fn ); diff --git a/game/client/portal/portal_credits.cpp b/game/client/portal/portal_credits.cpp index 86ad0bcdc..beddd1431 100644 --- a/game/client/portal/portal_credits.cpp +++ b/game/client/portal/portal_credits.cpp @@ -773,9 +773,9 @@ void CHudPortalCredits::DrawPortalOutroCreditsName( void ) char tmpstr2[256]; Q_strncpy( tmpstr2, pCredit->szCreditName, m_iXOffset ); if (bCursor) - Q_snprintf( tmpstr, 256, "%s_",tmpstr2); + V_sprint_safe( tmpstr, "%s_", tmpstr2 ); else - Q_snprintf( tmpstr, 256, "%s",tmpstr2); + V_strcpy_safe( tmpstr, tmpstr2 ); } else { @@ -1076,9 +1076,9 @@ void CHudPortalCredits::DrawPortalOutroCreditsLyrics( void ) char tmpstr2[256]; Q_strncpy( tmpstr2, pCredit->szCreditName, m_iXOffsetNames ); if (!bCursor) - Q_snprintf( tmpstr, 256, "%s_",tmpstr2); + V_sprintf_safe( tmpstr, "%s_", tmpstr2 ); else - Q_snprintf( tmpstr, 256, "%s",tmpstr2); + V_strcpy_safe( tmpstr, tmpstr2 ); } else { diff --git a/game/client/replay/vgui/replaybrowserlistitempanel.cpp b/game/client/replay/vgui/replaybrowserlistitempanel.cpp index 160cc0560..caaebd751 100644 --- a/game/client/replay/vgui/replaybrowserlistitempanel.cpp +++ b/game/client/replay/vgui/replaybrowserlistitempanel.cpp @@ -900,7 +900,7 @@ void CReplayThumbnailCollection::ApplySchemeSettings( IScheme *pScheme ) else { char szKey[16]; - Q_snprintf( szKey, sizeof(szKey), "%s", pBoundKey ); + V_strcpy_safe( szKey, pBoundKey ); wchar_t wKey[16]; wchar_t wLabel[256]; diff --git a/game/client/replay/vgui/replayreminderpanel.cpp b/game/client/replay/vgui/replayreminderpanel.cpp index e13cff403..50ef33c9d 100644 --- a/game/client/replay/vgui/replayreminderpanel.cpp +++ b/game/client/replay/vgui/replayreminderpanel.cpp @@ -52,7 +52,7 @@ void CReplayReminderPanel::SetupText() } char szKey[16]; - Q_snprintf( szKey, sizeof(szKey), "%s", pBoundKey ); + V_strcpy_safe( szKey, pBoundKey ); wchar_t wKey[16]; wchar_t wLabel[256]; diff --git a/game/client/tf/tf_demo_support.cpp b/game/client/tf/tf_demo_support.cpp index 4d087dcf5..2dc84defe 100644 --- a/game/client/tf/tf_demo_support.cpp +++ b/game/client/tf/tf_demo_support.cpp @@ -464,7 +464,7 @@ bool CTFDemoSupport::StartRecording( void ) ptm->tm_hour, ptm->tm_min, ptm->tm_sec ); char szPrefix[24] = {0}; - V_sprintf_safe( szPrefix, "%s", ds_prefix.GetString() ); + V_strcpy_safe( szPrefix, ds_prefix.GetString() ); V_sprintf_safe( m_szFilename, "%s%s", szPrefix, szTime ); if ( !Q_isempty( ds_dir.GetString() ) ) @@ -476,7 +476,7 @@ bool CTFDemoSupport::StartRecording( void ) return false; } - V_sprintf_safe( m_szFolder, "%s", ds_dir.GetString() ); + V_strcpy_safe( m_szFolder, ds_dir.GetString() ); // make sure the folder exists g_pFullFileSystem->CreateDirHierarchy( m_szFolder, "GAME" ); @@ -486,7 +486,7 @@ bool CTFDemoSupport::StartRecording( void ) else { m_szFolder[0] = '\0'; - V_sprintf_safe( m_szFolderAndFilename, "%s", m_szFilename ); + V_strcpy_safe( m_szFolderAndFilename, m_szFilename ); } if ( !engine->StartDemoRecording( m_szFilename, m_szFolder ) ) diff --git a/game/client/tf/tf_hud_freezepanel.cpp b/game/client/tf/tf_hud_freezepanel.cpp index a6d18aff0..5e778585a 100644 --- a/game/client/tf/tf_hud_freezepanel.cpp +++ b/game/client/tf/tf_hud_freezepanel.cpp @@ -995,7 +995,7 @@ void CTFFreezePanel::ShowSnapshotPanel( bool bShow ) if ( bShow ) { char szKey[16]; - Q_snprintf( szKey, sizeof(szKey), "%s", key ); + V_strcpy_safe( szKey, key ); wchar_t wKey[16]; wchar_t wLabel[256]; diff --git a/game/client/tf/vgui/tf_playermodelpanel.cpp b/game/client/tf/vgui/tf_playermodelpanel.cpp index 0cd66ce04..a96dcb574 100644 --- a/game/client/tf/vgui/tf_playermodelpanel.cpp +++ b/game/client/tf/vgui/tf_playermodelpanel.cpp @@ -2826,7 +2826,7 @@ void CTFPlayerModelPanel::SetupMappings( char const *pchFileRoot ) memset( m_PhonemeClasses, 0, sizeof( m_PhonemeClasses ) ); Emphasized_Phoneme *normal = &m_PhonemeClasses[ PHONEME_CLASS_NORMAL ]; - Q_snprintf( normal->classname, sizeof( normal->classname ), "%s", pchFileRoot ); + V_strcpy_safe( normal->classname, pchFileRoot ); normal->required = true; Emphasized_Phoneme *weak = &m_PhonemeClasses[ PHONEME_CLASS_WEAK ]; diff --git a/game/client/tf/vgui/tf_roundinfo.cpp b/game/client/tf/vgui/tf_roundinfo.cpp index 99ad62b27..055688734 100644 --- a/game/client/tf/vgui/tf_roundinfo.cpp +++ b/game/client/tf/vgui/tf_roundinfo.cpp @@ -294,7 +294,7 @@ void RoundInfoOverlay::Update( const char *szMapName ) { roundinfo_control_point_t point; - Q_snprintf( point.m_szName, sizeof(point.m_szName), "%s", pData->GetName() ); + V_strcpy_safe( point.m_szName, pData->GetName() ); // These x,y coords are relative to a 640x480 parent panel. int wide, tall; diff --git a/game/client/tf2/c_weapon_builder.cpp b/game/client/tf2/c_weapon_builder.cpp index edb69ab83..e74eba920 100644 --- a/game/client/tf2/c_weapon_builder.cpp +++ b/game/client/tf2/c_weapon_builder.cpp @@ -365,7 +365,7 @@ void CHumanPDAPanel::OnTick() m_pObjectImage->SetImageFile( buf ); m_pObjectImage->SetColor( GetFgColor() ); - Q_snprintf( buf, sizeof( buf ), "%s", info->m_pStatusName ); + V_strcpy_safe( buf, info->m_pStatusName ); m_pObjectName->SetText( buf ); Q_snprintf( buf, sizeof( buf ), "Cost: %i", iCost ); @@ -374,7 +374,7 @@ void CHumanPDAPanel::OnTick() Q_snprintf( buf, sizeof( buf ), "You own: %i", numOwned ); m_pObjectOnTeamCount->SetText( buf ); - Q_snprintf( buf, sizeof( buf ), "%s", info->m_pBuilderPlacementString ? info->m_pBuilderPlacementString : "" ); + V_strcpy_safe( buf, info->m_pBuilderPlacementString ? info->m_pBuilderPlacementString : "" ); m_pObjectPlacementDetails->SetText( buf ); //m_pObjectPlacementDetails->SizeToContents(); } diff --git a/game/client/tf2/hud_weaponselection.cpp b/game/client/tf2/hud_weaponselection.cpp index 4b21750c7..7afab99cc 100644 --- a/game/client/tf2/hud_weaponselection.cpp +++ b/game/client/tf2/hud_weaponselection.cpp @@ -803,7 +803,7 @@ void CHudWeaponSelection::GetSlotInfo( const CWeaponMenuItem *w, C_BaseCombatWea } info.ammoCaution = ( info.ammoPerc >= CLIP_PERC_THRESHOLD ) ? true : false; - Q_snprintf( info.printname, sizeof( info.printname ), "%s", pWeapon->GetPrintName() ); + V_strcpy_safe( info.printname, pWeapon->GetPrintName() ); info.weapon = pWeapon; } diff --git a/game/server/baseentity.cpp b/game/server/baseentity.cpp index 0c546d9fb..8c8362cc1 100644 --- a/game/server/baseentity.cpp +++ b/game/server/baseentity.cpp @@ -5378,7 +5378,7 @@ void CC_Ent_Dump( const CCommand& args ) // get the entities name if ( var.Entity() ) { - Q_snprintf( buf,sizeof(buf), "%s", STRING(var.Entity()->GetEntityName()) ); + V_strcpy_safe( buf, STRING(var.Entity()->GetEntityName()) ); } } break; diff --git a/game/server/buttons.cpp b/game/server/buttons.cpp index af7862f2a..5196516ff 100644 --- a/game/server/buttons.cpp +++ b/game/server/buttons.cpp @@ -824,11 +824,11 @@ int CBaseButton::DrawDebugTextOverlays() nState = 4; } - Q_snprintf( tempstr, sizeof(tempstr), "State: %s", pszStates[nState] ); + V_sprintf_safe( tempstr, "State: %s", pszStates[nState] ); EntityText( text_offset, tempstr, 0 ); text_offset++; - Q_snprintf( tempstr, sizeof(tempstr), "%s", m_bLocked ? "Locked" : "Unlocked" ); + V_strcpy_safe( tempstr, m_bLocked ? "Locked" : "Unlocked" ); EntityText( text_offset, tempstr, 0 ); text_offset++; } diff --git a/game/server/client.cpp b/game/server/client.cpp index 0c83bdd38..925348896 100644 --- a/game/server/client.cpp +++ b/game/server/client.cpp @@ -219,7 +219,7 @@ void Host_Say( edict_t *pEdict, const CCommand &args, bool teamonly ) else { // Just a one word command, use the first word...sigh - V_sprintf_safe( szTemp, "%s", pcmd ); + V_strcpy_safe( szTemp, pcmd ); } } diff --git a/game/server/cstrike/cs_player.cpp b/game/server/cstrike/cs_player.cpp index bf8cffc90..018a2bd03 100644 --- a/game/server/cstrike/cs_player.cpp +++ b/game/server/cstrike/cs_player.cpp @@ -6140,7 +6140,7 @@ void CCSPlayer::PrioritizeAutoBuyString(char *autobuyString, const char *priorit // terminate the string. Trailing spaces shouldn't matter. newString[newStringPos] = 0; - Q_snprintf(autobuyString, sizeof(autobuyString), "%s", newString); + V_strcpy_safe(autobuyString, newString); } diff --git a/game/server/gameinterface.cpp b/game/server/gameinterface.cpp index ada4f97c7..cc1769ca2 100644 --- a/game/server/gameinterface.cpp +++ b/game/server/gameinterface.cpp @@ -362,7 +362,7 @@ void DrawMeasuredSections(void) while ( p ) { char str[256]; - Q_snprintf(str,sizeof(str),"%s",p->GetName()); + V_strcpy_safe(str,p->GetName()); NDebugOverlay::ScreenText( 0.01,0.51+(row*rowheight),str, 255,255,255,255, 0.0 ); Q_snprintf(str,sizeof(str),"%5.2f\n",p->GetTime().GetMillisecondsF()); diff --git a/game/server/hl1/hl1_weaponbox.cpp b/game/server/hl1/hl1_weaponbox.cpp index cf8273f63..78661f54d 100644 --- a/game/server/hl1/hl1_weaponbox.cpp +++ b/game/server/hl1/hl1_weaponbox.cpp @@ -140,7 +140,7 @@ bool CWeaponBox::PackAmmo( char *szName, int iCount ) return false; } - Q_snprintf( szConvertedName, sizeof( szConvertedName ), "%s", szName ); + V_strcpy_safe( szConvertedName, szName ); if ( V_strieq( szName, "bolts" ) ) { Q_snprintf( szConvertedName, sizeof( szConvertedName ), "XBowBolt" ); diff --git a/game/server/hl2/combine_mine.cpp b/game/server/hl2/combine_mine.cpp index 81852dff5..b66f1106a 100644 --- a/game/server/hl2/combine_mine.cpp +++ b/game/server/hl2/combine_mine.cpp @@ -244,7 +244,7 @@ int CBounceBomb::DrawDebugTextOverlays(void) if (m_debugOverlays & OVERLAY_TEXT_BIT) { char tempstr[512]; - Q_snprintf(tempstr,sizeof(tempstr), "%s", pszMineStateNames[m_iMineState] ); + V_strcpy_safe(tempstr, pszMineStateNames[m_iMineState] ); EntityText(text_offset,tempstr,0); text_offset++; } diff --git a/game/server/message_entity.cpp b/game/server/message_entity.cpp index e5bb114bd..c5226d070 100644 --- a/game/server/message_entity.cpp +++ b/game/server/message_entity.cpp @@ -152,7 +152,7 @@ void CMessageEntity::DrawOverlays(void) // display text if they are within range char tempstr[512]; - Q_snprintf( tempstr, sizeof(tempstr), "%s", STRING(m_messageText) ); + V_strcpy_safe( tempstr, STRING(m_messageText) ); EntityText( 0, tempstr, 0); } diff --git a/game/server/tf/tf_gc_api.cpp b/game/server/tf/tf_gc_api.cpp index cd347e977..4bdffff28 100644 --- a/game/server/tf/tf_gc_api.cpp +++ b/game/server/tf/tf_gc_api.cpp @@ -97,7 +97,7 @@ class CGC_GameServer_AuthChallenge : public GCSDK::CGCClientJob } char szKeyBuffer[16]; - int nKeyLength = Q_snprintf( szKeyBuffer, sizeof( szKeyBuffer ), "%s", tf_server_identity_token.GetString() ); + int nKeyLength = V_sprintf_safe( szKeyBuffer, "%s", tf_server_identity_token.GetString() ); if ( nKeyLength <= 0 || nKeyLength >= ARRAYSIZE( szKeyBuffer ) ) { diff --git a/game/shared/cstrike/bot/bot_profile.cpp b/game/shared/cstrike/bot/bot_profile.cpp index edd492ebd..1964cbc54 100644 --- a/game/shared/cstrike/bot/bot_profile.cpp +++ b/game/shared/cstrike/bot/bot_profile.cpp @@ -177,7 +177,7 @@ void BotProfileManager::Init( const char *filename, unsigned int *checksum ) if ( isCustomSkin ) { - const int BufLen = 64; + constexpr int BufLen = 64; char skinName[BufLen]; // get skin name @@ -189,7 +189,7 @@ void BotProfileManager::Init( const char *filename, unsigned int *checksum ) return; } token = SharedGetToken(); - Q_snprintf( skinName, sizeof( skinName ), "%s", token ); + V_strcpy_safe( skinName, token ); // get attribute name dataFile = SharedParse( dataFile ); diff --git a/game/shared/dod/dod_gamerules.cpp b/game/shared/dod/dod_gamerules.cpp index c2578df8e..a2f0558b8 100644 --- a/game/shared/dod/dod_gamerules.cpp +++ b/game/shared/dod/dod_gamerules.cpp @@ -553,7 +553,7 @@ static CDODViewVectors g_DODViewVectors( void CDODGameRules::UploadLevelStats( void ) { - if ( Q_strlen( STRING( gpGlobals->mapname ) ) > 0 ) + if ( !Q_isempty( STRING( gpGlobals->mapname ) ) ) { int i,j; CDODTeam *pAllies = GetGlobalDODTeam( TEAM_ALLIES ); diff --git a/game/shared/saverestore.cpp b/game/shared/saverestore.cpp index 18bd347b7..a08a36072 100644 --- a/game/shared/saverestore.cpp +++ b/game/shared/saverestore.cpp @@ -299,7 +299,7 @@ void CSave::Log( const char *pName, fieldtype_t fieldType, void *value, int coun case FIELD_STRING: { string_t *pValue = ( string_t* )( value ); - Q_snprintf( szTempBuf, sizeof( szTempBuf ), "%s", ( const char* )STRING( *pValue ) ); + V_strcpy_safe( szTempBuf, ( const char* )STRING( *pValue ) ); Q_strncat( szBuf, szTempBuf, sizeof( szTempBuf ), COPY_ALL_CHARACTERS ); break; } diff --git a/game/shared/tf/tf_quest_editor_panel.cpp b/game/shared/tf/tf_quest_editor_panel.cpp index 0947b10c3..2a155f9a2 100644 --- a/game/shared/tf/tf_quest_editor_panel.cpp +++ b/game/shared/tf/tf_quest_editor_panel.cpp @@ -109,7 +109,7 @@ IEditorObject::IEditorObject( EditorObjectInitStruct init ) memset( m_szKeyName, 0, sizeof( m_szKeyName ) ); if ( init.m_pszKeyName ) { - V_sprintf_safe( m_szKeyName, "%s", init.m_pszKeyName ); + V_strcpy_safe( m_szKeyName, init.m_pszKeyName ); } SetWide( init.pParent->GetWide() ); @@ -557,7 +557,7 @@ void IEditorObjectParameter::UpdateSavedValue( const char* pszNewValue ) const { // Update saved string memset( m_szSavedValueBuff, 0, sizeof( m_szSavedValueBuff ) ); - V_sprintf_safe( m_szSavedValueBuff, "%s", pszNewValue ); + V_strcpy_safe( m_szSavedValueBuff, pszNewValue ); } //----------------------------------------------------------------------------- @@ -651,7 +651,7 @@ CLocalizationEditorParam::CLocalizationEditorParam( EditorObjectInitStruct init, SetTextEntryValue( szBuff ); UpdateSavedValue( szBuff ); - V_sprintf_safe( m_szLocalizationToken, "%s", pszLocalizationToken ); + V_strcpy_safe( m_szLocalizationToken, pszLocalizationToken ); } @@ -1347,7 +1347,7 @@ void CQuestObjectiveRestrictionNode::SetNewEvent( const char *pszEvent ) m_pNewCondition = NULL; char szType[256]; - V_sprintf_safe( szType, "%s", m_pCondition->GetConditionName() ); + V_strcpy_safe( szType, m_pCondition->GetConditionName() ); // Create new restriction CTFQuestCondition* pParent = m_pCondition->GetParent(); @@ -1361,7 +1361,7 @@ void CQuestObjectiveRestrictionNode::SetNewEvent( const char *pszEvent ) m_pCondition = CreateEvaluatorByName( szType, NULL ); } - V_sprintf_safe( m_szEventName, "%s", pszEvent ); + V_strcpy_safe( m_szEventName, pszEvent ); m_pCondition->SetEventName( m_szEventName ); CreateControlsForCondition(); diff --git a/game/shared/tf/tf_robot_destruction_robot.cpp b/game/shared/tf/tf_robot_destruction_robot.cpp index 5fe2a6675..6f1b81c24 100644 --- a/game/shared/tf/tf_robot_destruction_robot.cpp +++ b/game/shared/tf/tf_robot_destruction_robot.cpp @@ -310,8 +310,7 @@ void CTFRobotDestruction_Robot::FireEvent( const Vector& origin, const QAngle& a FOR_EACH_VEC( m_aSpawnProps, i ) { char pstrLowerName[ MAX_PATH ]; - memset( pstrLowerName, 0, sizeof(pstrLowerName) ); - Q_snprintf( pstrLowerName, sizeof(pstrLowerName), "%s", options ); + V_strcpy_safe( pstrLowerName, options ); Q_strlower( pstrLowerName ); if ( Q_strstr( m_aSpawnProps[i].modelName, pstrLowerName ) ) { @@ -376,8 +375,7 @@ void CTFRobotDestruction_Robot::HandleAnimEvent( animevent_t *pEvent ) FOR_EACH_VEC( m_aSpawnProps, i ) { char pstrLowerName[ MAX_PATH ]; - memset( pstrLowerName, 0, sizeof(pstrLowerName) ); - Q_snprintf( pstrLowerName, sizeof(pstrLowerName), "%s", pEvent->options ); + V_strcpy_safe( pstrLowerName, pEvent->options ); Q_strlower( pstrLowerName ); if ( Q_strstr( m_aSpawnProps[i].modelName, pstrLowerName ) ) { diff --git a/gameui/BonusMapsDialog.cpp b/gameui/BonusMapsDialog.cpp index a776ad6f5..e0eeabdad 100644 --- a/gameui/BonusMapsDialog.cpp +++ b/gameui/BonusMapsDialog.cpp @@ -50,7 +50,7 @@ static bool ConstructFullImagePath( { // Use the specified image if ( pchImageName[ 0 ] != '.' ) - V_sprintf_safe( pchImageFileName, "%s", pchImageName ); + V_strcpy_safe( pchImageFileName, pchImageName ); else V_sprintf_safe( pchImageFileName, "%s/%s", pCurrentPath, pchImageName ); diff --git a/gameui/CreateMultiplayerGameGameplayPage.cpp b/gameui/CreateMultiplayerGameGameplayPage.cpp index 881eef792..57214f475 100644 --- a/gameui/CreateMultiplayerGameGameplayPage.cpp +++ b/gameui/CreateMultiplayerGameGameplayPage.cpp @@ -317,17 +317,17 @@ void CCreateMultiplayerGameGameplayPage::GatherCurrentValues() { case O_BOOL: pBox = (CheckButton *)pList->pControl; - Q_snprintf( szValue, sizeof( szValue ), "%s", pBox->IsSelected() ? "1" : "0" ); + V_strcpy_safe( szValue, pBox->IsSelected() ? "1" : "0" ); break; case O_NUMBER: pEdit = ( TextEntry * )pList->pControl; //-V1037 pEdit->GetText( strValue ); - Q_snprintf( szValue, sizeof( szValue ), "%s", strValue ); + V_strcpy_safe( szValue, strValue ); break; case O_STRING: pEdit = ( TextEntry * )pList->pControl; pEdit->GetText( strValue ); - Q_snprintf( szValue, sizeof( szValue ), "%s", strValue ); + V_strcpy_safe( szValue, strValue ); break; case O_LIST: pCombo = ( ComboBox *)pList->pControl; @@ -368,11 +368,11 @@ void CCreateMultiplayerGameGameplayPage::GatherCurrentValues() if ( pItem ) { - Q_snprintf( szValue, sizeof( szValue ), "%s", pItem->szValue ); + V_strcpy_safe( szValue, pItem->szValue ); } else //Couldn't find index { - Q_snprintf( szValue, sizeof( szValue ), "%s", pObj->defValue ); + V_strcpy_safe( szValue, pObj->defValue ); } break; } diff --git a/gameui/MultiplayerAdvancedDialog.cpp b/gameui/MultiplayerAdvancedDialog.cpp index 2cf9584cb..3851f44ba 100644 --- a/gameui/MultiplayerAdvancedDialog.cpp +++ b/gameui/MultiplayerAdvancedDialog.cpp @@ -178,17 +178,17 @@ void CMultiplayerAdvancedDialog::GatherCurrentValues() { case O_BOOL: pBox = (CheckButton *)pList->pControl; - V_sprintf_safe( szValue, "%s", pBox->IsSelected() ? "1" : "0" ); + V_strcpy_safe( szValue, pBox->IsSelected() ? "1" : "0" ); break; case O_NUMBER: pEdit = ( TextEntry * )pList->pControl; //-V1037 pEdit->GetText( strValue ); - V_sprintf_safe( szValue, "%s", strValue ); + V_strcpy_safe( szValue, strValue ); break; case O_STRING: pEdit = ( TextEntry * )pList->pControl; pEdit->GetText( strValue ); - V_sprintf_safe( szValue, "%s", strValue ); + V_strcpy_safe( szValue, strValue ); break; case O_LIST: { @@ -209,12 +209,12 @@ void CMultiplayerAdvancedDialog::GatherCurrentValues() if ( pItem ) { - V_sprintf_safe( szValue, "%s", pItem->szValue ); + V_strcpy_safe( szValue, pItem->szValue ); } else // Couln't find index { //Assert(!("Couldn't find string in list, using default value")); - V_sprintf_safe( szValue, "%s", pObj->defValue ); + V_strcpy_safe( szValue, pObj->defValue ); } break; } diff --git a/gameui/NewGameDialog.cpp b/gameui/NewGameDialog.cpp index 88f595eda..872432ee0 100644 --- a/gameui/NewGameDialog.cpp +++ b/gameui/NewGameDialog.cpp @@ -373,7 +373,7 @@ CNewGameDialog::CNewGameDialog(vgui::Panel *parent, bool bCommentaryMode) : Base sscanf(fileName, "chapter%31s", chapterID); chapterID[ssize(chapterID) - 1] = '\0'; - V_sprintf_safe( szFullFileName, "%s", fileName ); + V_strcpy_safe( szFullFileName, fileName ); // strip the extension char *ext = V_stristr(chapterID, ".cfg"); diff --git a/hammer/Render.cpp b/hammer/Render.cpp index e75daeea4..2c66bbbbc 100644 --- a/hammer/Render.cpp +++ b/hammer/Render.cpp @@ -129,7 +129,8 @@ void CRender::PushInstanceData( CMapInstance *pInstanceClass, const Vector &Inst m_CurrentInstanceState.m_InstanceOrigin = vecTransformedOrigin; // RotateInstanceVector( ( Vector )InstanceState.m_InstanceAngles, m_CurrentInstanceState.m_InstanceAngles ); no one uses this right now make sure to store it in the same fashion as vecTransformedOrigin - if ( m_InstanceState.Count() > 0 ) + // dimhotepus: Prevent nullptr pInstanceClass dereference. + if ( pInstanceClass && m_InstanceState.Count() > 0 ) { // first push is just a default state m_bInstanceRendering = true; BeginLocalTransfrom( InstanceState.m_InstanceMatrix, true ); diff --git a/hammer/ToolCamera.cpp b/hammer/ToolCamera.cpp index d565133f3..944b5d86a 100644 --- a/hammer/ToolCamera.cpp +++ b/hammer/ToolCamera.cpp @@ -264,7 +264,7 @@ ChunkFileResult_t Camera3D::LoadCamerasKeyCallback(const char *szKey, const char ChunkFileResult_t Camera3D::LoadCameraCallback(CChunkFile *pFile, Camera3D *pCameras) { CAMSTRUCT Cam; - memset(&Cam, 0, sizeof(Cam)); + BitwiseClear(Cam); ChunkFileResult_t eResult = pFile->ReadChunk(LoadCameraKeyCallback, &Cam); diff --git a/hammer/ToolPickEntity.cpp b/hammer/ToolPickEntity.cpp index 532b6e8c4..0930dd246 100644 --- a/hammer/ToolPickEntity.cpp +++ b/hammer/ToolPickEntity.cpp @@ -138,7 +138,8 @@ bool CToolPickEntity::OnLMouseDownLogical(CMapViewLogical *pView, UINT nFlags, c int nHits = pView->ObjectsAt( vPoint, &hitData, 1 ); if ( ( nHits > 0 ) && hitData.pObject ) { - CMapClass *pSelObject = hitData.pObject->PrepareSelection( selectObjects ); + auto *pMapClass = dynamic_cast(hitData.pObject); + CMapClass *pSelObject = pMapClass->PrepareSelection( selectObjects ); CMapEntity *pEntity = dynamic_cast ( pSelObject ); if (pEntity != NULL) { diff --git a/hammer/ToolSelection.cpp b/hammer/ToolSelection.cpp index 137260656..827561ab1 100644 --- a/hammer/ToolSelection.cpp +++ b/hammer/ToolSelection.cpp @@ -544,7 +544,8 @@ CBaseTool *Selection3D::GetToolObject( CMapView2D *pView, const Vector2D &vPoint // They clicked on some part of the object. See if there is a // tool associated with what we clicked on. // - CBaseTool *pToolHit = HitData.pObject->GetToolObject(HitData.uData, bAttach ); + auto *pMapClass = dynamic_cast(HitData.pObject); + CBaseTool *pToolHit = pMapClass->GetToolObject(HitData.uData, bAttach ); if ( pToolHit != NULL ) { return pToolHit; @@ -573,7 +574,8 @@ CBaseTool *Selection3D::GetToolObjectLogical( CMapViewLogical *pView, const Vect // They clicked on some part of the object. See if there is a // tool associated with what we clicked on. // - CBaseTool *pToolHit = HitData.pObject->GetToolObject(HitData.uData, bAttach ); + auto *pMapClass = dynamic_cast(HitData.pObject); + CBaseTool *pToolHit = pMapClass->GetToolObject(HitData.uData, bAttach ); if ( pToolHit != NULL ) { return pToolHit; diff --git a/hammer/mapclass.h b/hammer/mapclass.h index 9e2914bdf..68414841d 100644 --- a/hammer/mapclass.h +++ b/hammer/mapclass.h @@ -60,7 +60,8 @@ struct MapObjectPair_t //----------------------------------------------------------------------------- typedef struct HitInfo_s { - CMapClass *pObject; // Pointer to the CMapAtom that was clicked on. + // dimhotepus: Make map atom to correctly process clicks. + CMapAtom *pObject; // Pointer to the CMapAtom that was clicked on. unsigned int uData; // Additional data provided by the CMapAtom object. unsigned int nDepth; // Depth value of the object that was clicked on. VMatrix m_LocalMatrix; diff --git a/hammer/mapdisp.cpp b/hammer/mapdisp.cpp index e61546d4f..19b3aebcc 100644 --- a/hammer/mapdisp.cpp +++ b/hammer/mapdisp.cpp @@ -673,7 +673,8 @@ void CMapDisp::SamplePoints( int index, int width, int height, bool *pValidPoint // set initial sample values // Vector vField, vSPos, vSNormal; - int value = GetFieldDistance( index ); + // dimhotepus: int -> float. + float value = GetFieldDistance( index ); float alpha = GetAlpha( index ); GetFieldVector( index, vField ); GetSubdivPosition( index, vSPos ); diff --git a/hammer/mapdoc.cpp b/hammer/mapdoc.cpp index 277280c0f..2e9e5b82a 100644 --- a/hammer/mapdoc.cpp +++ b/hammer/mapdoc.cpp @@ -4626,7 +4626,7 @@ void CMapDoc::GetBestPastePoint(Vector &vecPasteOrigin) // If they clicked on a solid, the index of the face they clicked on is stored // in array index [1]. - CMapClass *pObject = Hits.pObject; + CMapClass *pObject = dynamic_cast(Hits.pObject); CMapSolid *pSolid = dynamic_cast(pObject); Vector HitPos,HitNormal; diff --git a/hammer/mapoverlay.h b/hammer/mapoverlay.h index 0cdadce69..87a475a5b 100644 --- a/hammer/mapoverlay.h +++ b/hammer/mapoverlay.h @@ -71,7 +71,8 @@ class CMapOverlay : public CMapSideList void HandleMoveTo( int iHandle, Vector &vecPoint, CMapFace *pFace ); void SetTexCoords( Vector2D vecTexCoords[4] ); void GetHandlePos( int iHandle, Vector &vecPos ); - bool IsSelected( void ) { return ( GetSelectionState() == SELECT_NORMAL ); } + // dimhotepus: Add const. + bool IsSelected( void ) const override { return ( GetSelectionState() == SELECT_NORMAL ); } void DoClip( void ); void CenterEntity( void ); diff --git a/hammer/mapview.cpp b/hammer/mapview.cpp index 07f11e2c5..3066664b6 100644 --- a/hammer/mapview.cpp +++ b/hammer/mapview.cpp @@ -147,7 +147,8 @@ bool CMapView::SelectAt(const Vector2D &ptClient, bool bMakeFirst, bool bFace) { if ( HitData[i].pObject ) { - CMapClass *pSelObject = HitData[i].pObject->PrepareSelection( eSelectMode ); + auto *pMapClass = dynamic_cast(HitData[i].pObject); + CMapClass *pSelObject = pMapClass->PrepareSelection( eSelectMode ); if (pSelObject) { pSelection->AddHit(pSelObject); diff --git a/hammer/mapviewlogical.cpp b/hammer/mapviewlogical.cpp index e6085e72e..a647de8e8 100644 --- a/hammer/mapviewlogical.cpp +++ b/hammer/mapviewlogical.cpp @@ -143,7 +143,8 @@ bool CMapViewLogical::SelectAtCascading( const Vector2D &ptClient, bool bMakeFir for ( int i=0; iPrepareSelection( eSelectMode ); + auto *pMapClass = dynamic_cast(HitData[i].pObject); + CMapClass *pSelObject = pMapClass->PrepareSelection( eSelectMode ); if ( !pSelObject ) continue; diff --git a/hammer/render3dms.cpp b/hammer/render3dms.cpp index 8d727f1ae..e425000f7 100644 --- a/hammer/render3dms.cpp +++ b/hammer/render3dms.cpp @@ -265,10 +265,10 @@ void CRender3D::EndRenderHitTarget(void) const uintp low = (uintp)m_Pick.uSelectionBuffer[3]; const uintp hi = ((uintp)m_Pick.uSelectionBuffer[4] << 32); const uintp ptr = hi | low; - hit.pObject = (CMapClass *)ptr; + hit.pObject = (CMapAtom *)ptr; hit.uData = m_Pick.uSelectionBuffer[5]; #else - hit.pObject = (CMapClass *)m_Pick.uSelectionBuffer[3]; + hit.pObject = (CMapAtom *)m_Pick.uSelectionBuffer[3]; hit.uData = m_Pick.uSelectionBuffer[4]; #endif hit.m_LocalMatrix = m_LocalMatrix.Head(); diff --git a/hammer/soundsystem.cpp b/hammer/soundsystem.cpp index 8917537e4..d5780e210 100644 --- a/hammer/soundsystem.cpp +++ b/hammer/soundsystem.cpp @@ -535,7 +535,7 @@ void CSoundSystem::OpenSource( SoundType_t type, intp nIndex ) if ( pFileName ) { char pRelativePath[MAX_PATH]; - V_sprintf_safe( pRelativePath, "%s", pFileName ); + V_strcpy_safe( pRelativePath, pFileName ); char pFullPath[MAX_PATH]; if ( g_pFullFileSystem->GetLocalPath_safe( pRelativePath, pFullPath ) ) diff --git a/hammer/studiomodel.cpp b/hammer/studiomodel.cpp index addbbc9d9..aec665098 100644 --- a/hammer/studiomodel.cpp +++ b/hammer/studiomodel.cpp @@ -50,7 +50,7 @@ class CStudioFileChangeWatcher : private CFileChangeWatcher::ICallbacks private: // CFileChangeWatcher::ICallbacks.. - virtual void OnFileChange( const char *pRelativeFilename, const char *pFullFilename ); + void OnFileChange( const char *pRelativeFilename, const char *pFullFilename ) override; private: CFileChangeWatcher m_Watcher; diff --git a/hammer_launcher/main.cpp b/hammer_launcher/main.cpp index 7b5dbc7c0..f4f3e4917 100644 --- a/hammer_launcher/main.cpp +++ b/hammer_launcher/main.cpp @@ -20,6 +20,7 @@ #include "tier0/icommandline.h" #include "tier0/dbg.h" #include "tier0/platform.h" +#include "tier1/strtools.h" #include "vgui/ivgui.h" #include "vgui/ISurface.h" #include "vstdlib/cvar.h" @@ -71,9 +72,9 @@ const char *PrefixMessageGroup( const size_t length{strlen(message)}; if (length > 1 && message[length - 1] == '\n') { - Q_snprintf(out, std::size(out), "[%s] %s", out_group, message); + V_sprintf_safe(out, "[%s] %s", out_group, message); } else { - Q_snprintf(out, std::size(out), "%s", message); + V_strcpy_safe(out, message); } return out; diff --git a/launcher/launcher_main.cpp b/launcher/launcher_main.cpp index 264b882e9..0811e949b 100644 --- a/launcher/launcher_main.cpp +++ b/launcher/launcher_main.cpp @@ -64,7 +64,7 @@ const char *PrefixMessageGroup(char (&out)[out_size], const char *group, if (length > 1 && message[length - 1] == '\n') { V_sprintf_safe(out, "[%.3f][%s] %s", Plat_FloatTime(), out_group, message); } else { - V_sprintf_safe(out, "%s", message); + V_strcpy_safe(out, message); } return out; diff --git a/materialsystem/cmaterialvar.cpp b/materialsystem/cmaterialvar.cpp index a85789b73..92c277d9a 100644 --- a/materialsystem/cmaterialvar.cpp +++ b/materialsystem/cmaterialvar.cpp @@ -35,48 +35,48 @@ struct MaterialVarMatrix_t bool m_bIsIdent; }; -class CMaterialVar : public IMaterialVar +class CMaterialVar final : public IMaterialVar { public: // stuff from IMaterialVar - virtual const char * GetName( void ) const; - virtual MaterialVarSym_t GetNameAsSymbol() const; - virtual void SetFloatValue( float val ); - virtual void SetIntValue( int val ); - virtual void SetStringValue( const char *val ); - virtual const char * GetStringValue( void ) const; - virtual void SetMatrixValue( VMatrix const& matrix ); - virtual VMatrix const& GetMatrixValue( ); - virtual bool MatrixIsIdentity( void ) const; - virtual void SetVecValue( const float* pVal, int numComps ); - virtual void SetVecValue( float x, float y ); - virtual void SetVecValue( float x, float y, float z ); - virtual void SetVecValue( float x, float y, float z, float w ); - void SetVecValueInternal( const Vector4D &vec, int nComps ); - virtual void SetVecComponentValue( float fVal, int nComponent ); - virtual void GetLinearVecValue( float *val, int numComps ) const; - virtual void SetFourCCValue( FourCC type, void *pData ); - virtual void GetFourCCValue( FourCC *type, void **ppData ); - virtual int GetIntValueInternal( void ) const; - virtual float GetFloatValueInternal( void ) const; - virtual float const* GetVecValueInternal( ) const; - virtual void GetVecValueInternal( float *val, int numcomps ) const; - virtual int VectorSizeInternal() const; + const char * GetName( void ) const override; + MaterialVarSym_t GetNameAsSymbol() const override; + void SetFloatValue( float val ) override; + void SetIntValue( int val ) override; + void SetStringValue( const char *val ) override; + const char * GetStringValue( void ) const override; + void SetMatrixValue( VMatrix const& matrix ) override; + VMatrix const& GetMatrixValue( ) override; + bool MatrixIsIdentity( void ) const override; + void SetVecValue( const float* pVal, int numComps ) override; + void SetVecValue( float x, float y ) override; + void SetVecValue( float x, float y, float z ) override; + void SetVecValue( float x, float y, float z, float w ) override; + void SetVecValueInternal( const Vector4D &vec, int nComps ); + void SetVecComponentValue( float fVal, int nComponent ) override; + void GetLinearVecValue( float *val, int numComps ) const override; + void SetFourCCValue( FourCC type, void *pData ) override; + void GetFourCCValue( FourCC *type, void **ppData ) override; + int GetIntValueInternal( void ) const override; + float GetFloatValueInternal( void ) const override; + float const* GetVecValueInternal( ) const override; + void GetVecValueInternal( float *val, int numcomps ) const override; + int VectorSizeInternal() const override; // revisit: is this a good interface for textures? - virtual ITexture * GetTextureValue( void ); - virtual void SetTextureValue( ITexture * ); - void SetTextureValueQueued( ITexture *texture ); + ITexture * GetTextureValue( void ) override; + void SetTextureValue( ITexture * ) override; + void SetTextureValueQueued( ITexture *texture ); - virtual IMaterial * GetMaterialValue( void ); - virtual void SetMaterialValue( IMaterial * ); + IMaterial * GetMaterialValue( void ) override; + void SetMaterialValue( IMaterial * ) override; - virtual operator ITexture *() { return GetTextureValue(); } - virtual bool IsDefined() const; - virtual void SetUndefined(); + virtual operator ITexture *() { return GetTextureValue(); } + bool IsDefined() const override; + void SetUndefined() override; - virtual void CopyFrom( IMaterialVar *pMaterialVar ); + void CopyFrom( IMaterialVar *pMaterialVar ) override; FORCEINLINE void Init( void ) { @@ -99,9 +99,9 @@ class CMaterialVar : public IMaterialVar CMaterialVar( IMaterial* pMaterial, const char *key ); virtual ~CMaterialVar(); - virtual void SetValueAutodetectType( const char *val ); + void SetValueAutodetectType( const char *val ) override; - virtual IMaterial * GetOwningMaterial() { return m_pMaterial; } + IMaterial * GetOwningMaterial() override { return m_pMaterial; } private: // Cleans up material var data @@ -786,7 +786,8 @@ void CMaterialVar::SetStringValue( const char *val ) CleanUpData(); m_pStringVal = V_strdup( val ); m_Type = MATERIAL_VAR_TYPE_STRING; - m_intVal = atoi( val ); + // dimhotepus: atoi -> V_atoi. + m_intVal = V_atoi( val ); // dimhotepus: atof -> V_atof. m_VecVal[0] = m_VecVal[1] = m_VecVal[2] = m_VecVal[3] = V_atof( m_pStringVal ); VarChanged(); diff --git a/movieobjects/dmelog.cpp b/movieobjects/dmelog.cpp index 55a2a7e30..4531147c5 100644 --- a/movieobjects/dmelog.cpp +++ b/movieobjects/dmelog.cpp @@ -2655,7 +2655,7 @@ void CDmeTypedCurveInfo< T >::OnConstruction() for ( int i = 0; i < 2; ++i ) { char edgename[ 32 ]; - Q_snprintf( edgename, sizeof( edgename ), "%s", i == 0 ? "left" : "right" ); + V_strcpy_safe( edgename, i == 0 ? "left" : "right" ); char name[ 32 ]; Q_snprintf( name, sizeof( name ), "%sEdgeActive", edgename ); m_bEdgeActive[ i ].Init( this, name ); diff --git a/public/chunkfile.cpp b/public/chunkfile.cpp index 4cf806fb0..a4c22af02 100644 --- a/public/chunkfile.cpp +++ b/public/chunkfile.cpp @@ -285,7 +285,7 @@ const char *CChunkFile::GetErrorText(ChunkFileResult_t eResult) case ChunkFile_OpenFail: { - Q_snprintf(szError, sizeof( szError ), "%s", strerror(errno)) ; + V_strcpy_safe(szError, strerror(errno)); break; } diff --git a/public/game/server/pluginvariant.h b/public/game/server/pluginvariant.h index b4a798c7c..1290f9290 100644 --- a/public/game/server/pluginvariant.h +++ b/public/game/server/pluginvariant.h @@ -56,7 +56,7 @@ class pluginvariant fieldtype_t FieldType( void ) { return fieldType; } void SetBool( bool b ) { bVal = b; fieldType = FIELD_BOOLEAN; } - void SetString( char *str ) { Q_snprintf(iszVal, 1024, "%s", str); fieldType = FIELD_STRING; } + void SetString( char *str ) { V_strcpy_safe(iszVal, str); fieldType = FIELD_STRING; } void SetInt( int val ) { iVal = val, fieldType = FIELD_INTEGER; } void SetFloat( float val ) { flVal = val, fieldType = FIELD_FLOAT; } void SetEdict( edict_t *val ) { eVal = val; fieldType = FIELD_EHANDLE; } diff --git a/public/posedebugger.cpp b/public/posedebugger.cpp index 9ed6a54bc..eeb5079e2 100644 --- a/public/posedebugger.cpp +++ b/public/posedebugger.cpp @@ -513,8 +513,8 @@ void CPoseDebuggerImpl::AccumulatePose( const CStudioHdr *pStudioHdr, CIKContext int numLines = 0; txt.m_iActivity = seqdesc.activity; - V_sprintf_safe( txt.m_chActivity, "%s", seqdesc.pszActivityName() ); - V_sprintf_safe( txt.m_chLabel, "%s", seqdesc.pszLabel() ); + V_strcpy_safe( txt.m_chActivity, seqdesc.pszActivityName() ); + V_strcpy_safe( txt.m_chLabel, seqdesc.pszLabel() ); if ( !txt.m_chActivity[0] ) { @@ -525,7 +525,7 @@ void CPoseDebuggerImpl::AccumulatePose( const CStudioHdr *pStudioHdr, CIKContext if ( lastSeenTxt.m_uiFlags & ModelPoseDebugInfo::F_SEEN_THIS_FRAME && lastSeenTxt.m_chActivity[0] ) { - V_sprintf_safe( txt.m_chActivity, "%s", lastSeenTxt.m_chActivity ); + V_strcpy_safe( txt.m_chActivity, lastSeenTxt.m_chActivity ); break; } } diff --git a/sdklauncher/ModWizard_CopyFiles.cpp b/sdklauncher/ModWizard_CopyFiles.cpp index e9aff5738..d8546383a 100644 --- a/sdklauncher/ModWizard_CopyFiles.cpp +++ b/sdklauncher/ModWizard_CopyFiles.cpp @@ -668,7 +668,7 @@ bool CModWizardSubPanel_CopyFiles_Source2007::BuildCopyFilesForMod_HL2MP() bool CModWizardSubPanel_CopyFiles_Source2006::BuildCopyFilesForMod_SourceCodeOnly() { char outputSrcDirName[MAX_PATH]; - Q_snprintf( outputSrcDirName, sizeof( outputSrcDirName ), "%s", m_OutputDirName ); + V_strcpy_safe( outputSrcDirName, m_OutputDirName ); int len = strlen( outputSrcDirName ); if ( len > 0 && PATHSEPARATOR( outputSrcDirName[len-1] ) ) outputSrcDirName[len-1] = 0; @@ -685,7 +685,7 @@ bool CModWizardSubPanel_CopyFiles_Source2006::BuildCopyFilesForMod_SourceCodeOnl bool CModWizardSubPanel_CopyFiles_Source2009::BuildCopyFilesForMod_SourceCodeOnly() { char outputSrcDirName[MAX_PATH]; - Q_snprintf( outputSrcDirName, sizeof( outputSrcDirName ), "%s", m_OutputDirName ); + V_strcpy_safe( outputSrcDirName, m_OutputDirName ); int len = strlen( outputSrcDirName ); if ( len > 0 && PATHSEPARATOR( outputSrcDirName[len-1] ) ) outputSrcDirName[len-1] = 0; @@ -702,7 +702,7 @@ bool CModWizardSubPanel_CopyFiles_Source2009::BuildCopyFilesForMod_SourceCodeOnl bool CModWizardSubPanel_CopyFiles_Source2007::BuildCopyFilesForMod_SourceCodeOnly() { char outputSrcDirName[MAX_PATH]; - Q_snprintf( outputSrcDirName, sizeof( outputSrcDirName ), "%s", m_OutputDirName ); + V_strcpy_safe( outputSrcDirName, m_OutputDirName ); int len = strlen( outputSrcDirName ); if ( len > 0 && PATHSEPARATOR( outputSrcDirName[len-1] ) ) outputSrcDirName[len-1] = 0; @@ -902,7 +902,7 @@ void CModWizardSubPanel_CopyFiles::OnTick() if ( iNum < (unsigned int)m_FileCopyInfos.Count() ) { char msg[512]; - Q_snprintf( msg, sizeof( msg ), "%s", m_FileCopyInfos[iNum].m_InFilename ); + V_strcpy_safe( msg, m_FileCopyInfos[iNum].m_InFilename ); m_pLabel->SetText( msg ); m_pProgressBar->SetProgress( (float)iNum / m_FileCopyInfos.Count() ); @@ -942,7 +942,7 @@ bool CModWizardSubPanel_CopyFiles_Source2009::HandleReplacements_GameProjectFile if ( Q_stricmp( pInfo->m_InFilename, "src_mod\\source2009\\materialsystem\\stdshaders\\stdshader_dx9-2005.vcxproj" ) == 0 ) { bErrorStatus = true; - Q_snprintf( replaceWith, sizeof( replaceWith ), "%s", m_OutModGamedirName ); + V_strcpy_safe( replaceWith, m_OutModGamedirName ); bErrorStatus = CopyWithReplacements( pInfo->m_InFilename, replacements, ARRAYSIZE( replacements ), "%s", pInfo->m_OutFilename ); return true; @@ -953,7 +953,7 @@ bool CModWizardSubPanel_CopyFiles_Source2009::HandleReplacements_GameProjectFile bErrorStatus = true; if ( m_ModType == ModType_FromScratch ) { - Q_snprintf( replaceWith, sizeof( replaceWith ), "%s", m_OutModGamedirName ); + V_strcpy_safe( replaceWith, m_OutModGamedirName ); bErrorStatus = CopyWithReplacements( pInfo->m_InFilename, replacements, ARRAYSIZE( replacements ), "%s", pInfo->m_OutFilename ); } @@ -967,7 +967,7 @@ bool CModWizardSubPanel_CopyFiles_Source2009::HandleReplacements_GameProjectFile bErrorStatus = true; if ( m_ModType == ModType_HL2 || m_ModType == ModType_SourceCodeOnly ) { - Q_snprintf( replaceWith, sizeof( replaceWith ), "%s", m_OutModGamedirName ); + V_strcpy_safe( replaceWith, m_OutModGamedirName ); bErrorStatus = CopyWithReplacements( pInfo->m_InFilename, replacements, ARRAYSIZE( replacements ), "%s", pInfo->m_OutFilename ); } @@ -980,7 +980,7 @@ bool CModWizardSubPanel_CopyFiles_Source2009::HandleReplacements_GameProjectFile bErrorStatus = true; if ( m_ModType == ModType_HL2_Multiplayer ) { - Q_snprintf( replaceWith, sizeof( replaceWith ), "%s", m_OutModGamedirName ); + V_strcpy_safe( replaceWith, m_OutModGamedirName ); bErrorStatus = CopyWithReplacements( pInfo->m_InFilename, replacements, ARRAYSIZE( replacements ), "%s", pInfo->m_OutFilename ); } @@ -1013,7 +1013,7 @@ bool CModWizardSubPanel_CopyFiles_Source2007::HandleReplacements_GameProjectFile if ( Q_stricmp( pInfo->m_InFilename, "src_mod\\orangebox\\materialsystem\\stdshaders\\stdshader_dx9-2005.vcxproj" ) == 0 ) { bErrorStatus = true; - Q_snprintf( replaceWith, sizeof( replaceWith ), "%s", m_OutModGamedirName ); + V_strcpy_safe( replaceWith, m_OutModGamedirName ); bErrorStatus = CopyWithReplacements( pInfo->m_InFilename, replacements, ARRAYSIZE( replacements ), "%s", pInfo->m_OutFilename ); return true; @@ -1024,7 +1024,7 @@ bool CModWizardSubPanel_CopyFiles_Source2007::HandleReplacements_GameProjectFile bErrorStatus = true; if ( m_ModType == ModType_FromScratch ) { - Q_snprintf( replaceWith, sizeof( replaceWith ), "%s", m_OutModGamedirName ); + V_strcpy_safe( replaceWith, m_OutModGamedirName ); bErrorStatus = CopyWithReplacements( pInfo->m_InFilename, replacements, ARRAYSIZE( replacements ), "%s", pInfo->m_OutFilename ); } @@ -1038,7 +1038,7 @@ bool CModWizardSubPanel_CopyFiles_Source2007::HandleReplacements_GameProjectFile bErrorStatus = true; if ( m_ModType == ModType_HL2 || m_ModType == ModType_SourceCodeOnly ) { - Q_snprintf( replaceWith, sizeof( replaceWith ), "%s", m_OutModGamedirName ); + V_strcpy_safe( replaceWith, m_OutModGamedirName ); bErrorStatus = CopyWithReplacements( pInfo->m_InFilename, replacements, ARRAYSIZE( replacements ), "%s", pInfo->m_OutFilename ); } @@ -1051,7 +1051,7 @@ bool CModWizardSubPanel_CopyFiles_Source2007::HandleReplacements_GameProjectFile bErrorStatus = true; if ( m_ModType == ModType_HL2_Multiplayer ) { - Q_snprintf( replaceWith, sizeof( replaceWith ), "%s", m_OutModGamedirName ); + V_strcpy_safe( replaceWith, m_OutModGamedirName ); bErrorStatus = CopyWithReplacements( pInfo->m_InFilename, replacements, ARRAYSIZE( replacements ), "%s", pInfo->m_OutFilename ); } @@ -1084,7 +1084,7 @@ bool CModWizardSubPanel_CopyFiles_Source2006::HandleReplacements_GameProjectFile Q_stricmp( pInfo->m_InFilename, "src_mod\\ep1\\materialsystem\\stdshaders\\stdshader_dx9-2005.vcxproj" ) == 0 ) { bErrorStatus = true; - Q_snprintf( replaceWith, sizeof( replaceWith ), "%s", m_OutModGamedirName ); + V_strcpy_safe( replaceWith, m_OutModGamedirName ); bErrorStatus = CopyWithReplacements( pInfo->m_InFilename, replacements, ARRAYSIZE( replacements ), "%s", pInfo->m_OutFilename ); return true; @@ -1097,7 +1097,7 @@ bool CModWizardSubPanel_CopyFiles_Source2006::HandleReplacements_GameProjectFile bErrorStatus = true; if ( m_ModType == ModType_FromScratch ) { - Q_snprintf( replaceWith, sizeof( replaceWith ), "%s", m_OutModGamedirName ); + V_strcpy_safe( replaceWith, m_OutModGamedirName ); bErrorStatus = CopyWithReplacements( pInfo->m_InFilename, replacements, ARRAYSIZE( replacements ), "%s", pInfo->m_OutFilename ); } @@ -1112,7 +1112,7 @@ bool CModWizardSubPanel_CopyFiles_Source2006::HandleReplacements_GameProjectFile bErrorStatus = true; if ( m_ModType == ModType_HL2 || m_ModType == ModType_SourceCodeOnly ) { - Q_snprintf( replaceWith, sizeof( replaceWith ), "%s", m_OutModGamedirName ); + V_strcpy_safe( replaceWith, m_OutModGamedirName ); bErrorStatus = CopyWithReplacements( pInfo->m_InFilename, replacements, ARRAYSIZE( replacements ), "%s", pInfo->m_OutFilename ); } @@ -1127,7 +1127,7 @@ bool CModWizardSubPanel_CopyFiles_Source2006::HandleReplacements_GameProjectFile bErrorStatus = true; if ( m_ModType == ModType_HL2_Multiplayer ) { - Q_snprintf( replaceWith, sizeof( replaceWith ), "%s", m_OutModGamedirName ); + V_strcpy_safe( replaceWith, m_OutModGamedirName ); bErrorStatus = CopyWithReplacements( pInfo->m_InFilename, replacements, ARRAYSIZE( replacements ), "%s", pInfo->m_OutFilename ); } diff --git a/serverbrowser/BaseGamesPage.cpp b/serverbrowser/BaseGamesPage.cpp index bf6f8d376..29553dc47 100644 --- a/serverbrowser/BaseGamesPage.cpp +++ b/serverbrowser/BaseGamesPage.cpp @@ -460,7 +460,7 @@ static int ServerMapnameSortFunc( const servermaps_t *p1, const servermaps_t *p void CBaseGamesPage::PrepareQuickListMap( const char *pMapName, int iListID ) { char szMapName[ 512 ]; - V_sprintf_safe( szMapName, "%s", pMapName ); + V_strcpy_safe( szMapName, pMapName ); V_strlower( szMapName ); @@ -1059,7 +1059,7 @@ void CBaseGamesPage::UpdateDerivedLayouts( void ) char rgchControlSettings[MAX_PATH]; if ( m_pCustomResFilename ) { - Q_snprintf( rgchControlSettings, sizeof( rgchControlSettings ), "%s", m_pCustomResFilename ); + V_strcpy_safe( rgchControlSettings, m_pCustomResFilename ); } else {