From 4ad82ee54196f1a5c991ba9d0bff8ccd89bb40fe Mon Sep 17 00:00:00 2001 From: Andrey Akhmichin <15944199+nekonomicon@users.noreply.github.com> Date: Mon, 14 Nov 2022 07:41:21 +0500 Subject: [PATCH] Fix strange sprintf usage. --- cl_dll/ev_hldm.cpp | 2 +- cl_dll/hud_redraw.cpp | 4 +--- cl_dll/hud_spectator.cpp | 4 ++-- cl_dll/scoreboard.cpp | 2 +- cl_dll/tri.cpp | 4 +--- cl_dll/vgui_ScorePanel.cpp | 17 ++++++----------- 6 files changed, 12 insertions(+), 21 deletions(-) diff --git a/cl_dll/ev_hldm.cpp b/cl_dll/ev_hldm.cpp index a3160cb9..166f86bd 100644 --- a/cl_dll/ev_hldm.cpp +++ b/cl_dll/ev_hldm.cpp @@ -247,7 +247,7 @@ char *EV_HLDM_DamageDecal( physent_t *pe ) } else if( pe->rendermode != kRenderNormal ) { - sprintf( decalname, "{bproof1" ); + strcpy( decalname, "{bproof1" ); } else { diff --git a/cl_dll/hud_redraw.cpp b/cl_dll/hud_redraw.cpp index 300c228f..64e24e1c 100644 --- a/cl_dll/hud_redraw.cpp +++ b/cl_dll/hud_redraw.cpp @@ -201,9 +201,7 @@ int CHud::Redraw( float flTime, int intermission ) if( m_hsprCursor == 0 ) { - char sz[256]; - sprintf( sz, "sprites/cursor.spr" ); - m_hsprCursor = SPR_Load( sz ); + m_hsprCursor = SPR_Load( "sprites/cursor.spr" ); } SPR_Set( m_hsprCursor, 250, 250, 250 ); diff --git a/cl_dll/hud_spectator.cpp b/cl_dll/hud_spectator.cpp index c20e6ba0..a6db99f2 100644 --- a/cl_dll/hud_spectator.cpp +++ b/cl_dll/hud_spectator.cpp @@ -448,12 +448,12 @@ int CHudSpectator::Draw( float flTime ) color = GetClientColor( i + 1 ); // draw the players name and health underneath - sprintf( string, "%s", g_PlayerInfoList[i + 1].name ); + strcpy( string, g_PlayerInfoList[i + 1].name ); lx = strlen( string ) * 3; // 3 is avg. character length :) DrawSetTextColor( color[0], color[1], color[2] ); - DrawConsoleString( m_vPlayerPos[i][0] - lx,m_vPlayerPos[i][1], string ); + DrawConsoleString( m_vPlayerPos[i][0] - lx,m_vPlayerPos[i][1], string ); } return 1; diff --git a/cl_dll/scoreboard.cpp b/cl_dll/scoreboard.cpp index 2b8d7d20..685aaa9f 100644 --- a/cl_dll/scoreboard.cpp +++ b/cl_dll/scoreboard.cpp @@ -453,7 +453,7 @@ int CHudScoreboard::DrawPlayers( int xpos_rel, float list_slot, int nameoffset, if( g_PlayerInfoList[best_player].packetloss >= 63 ) { UnpackRGB( r, g, b, RGB_REDISH ); - sprintf( buf, " !!!!" ); + strcpy( buf, " !!!!" ); } else { diff --git a/cl_dll/tri.cpp b/cl_dll/tri.cpp index 0c45307c..0088daf3 100644 --- a/cl_dll/tri.cpp +++ b/cl_dll/tri.cpp @@ -50,9 +50,7 @@ void Draw_Triangles( void ) if( gHUD.m_hsprCursor == 0 ) { - char sz[256]; - sprintf( sz, "sprites/cursor.spr" ); - gHUD.m_hsprCursor = SPR_Load( sz ); + gHUD.m_hsprCursor = SPR_Load( "sprites/cursor.spr" ); } if( !gEngfuncs.pTriAPI->SpriteTexture( (struct model_s *)gEngfuncs.GetSpritePointer( gHUD.m_hsprCursor ), 0 ) ) diff --git a/cl_dll/vgui_ScorePanel.cpp b/cl_dll/vgui_ScorePanel.cpp index af2d9ec2..e746675d 100644 --- a/cl_dll/vgui_ScorePanel.cpp +++ b/cl_dll/vgui_ScorePanel.cpp @@ -256,10 +256,7 @@ void ScorePanel::Update() // Set the title if( gViewPort->m_szServerName[0] != '\0' ) { - char sz[MAX_SERVERNAME_LENGTH + 16]; - - sprintf( sz, "%s", gViewPort->m_szServerName ); - m_TitleLabel.setText( sz ); + m_TitleLabel.setText( gViewPort->m_szServerName ); } m_iRows = 0; @@ -684,7 +681,7 @@ void ScorePanel::FillGrid() } // Fill out with the correct data - strcpy(sz, ""); + sz[0] = '\0'; if ( m_iIsATeam[row] ) { char sz2[128]; @@ -694,11 +691,11 @@ void ScorePanel::FillGrid() case COLUMN_NAME: if ( m_iIsATeam[row] == TEAM_SPECTATORS ) { - sprintf( sz2, "%s", CHudTextMessage::BufferedLocaliseTextString( "#Spectators" ) ); + strcpy( sz2, CHudTextMessage::BufferedLocaliseTextString( "#Spectators" ) ); } else { - sprintf( sz2, "%s", gViewPort->GetTeamName(team_info->teamnumber) ); + strcpy( sz2, gViewPort->GetTeamName(team_info->teamnumber) ); } strcpy(sz, sz2); @@ -790,7 +787,7 @@ void ScorePanel::FillGrid() if (bNoClass) sz[0] = '\0'; else - sprintf( sz, "%s", CHudTextMessage::BufferedLocaliseTextString( sLocalisedClasses[ g_PlayerExtraInfo[ m_iSortedRows[row] ].playerclass ] ) ); + strcpy( sz, CHudTextMessage::BufferedLocaliseTextString( sLocalisedClasses[ g_PlayerExtraInfo[ m_iSortedRows[row] ].playerclass ] ) ); } else { @@ -909,14 +906,12 @@ void ScorePanel::mousePressed(MouseCode code, Panel* panel) else { char string1[1024]; - char string2[1024]; // mute the player GetClientVoiceMgr()->SetPlayerBlockedState(iPlayer, true); sprintf( string1, CHudTextMessage::BufferedLocaliseTextString( "#Muted" ), pl_info->name ); - sprintf( string2, "%s", CHudTextMessage::BufferedLocaliseTextString( "#No_longer_hear_that_player" ) ); - sprintf( string, "%c** %s %s\n", HUD_PRINTTALK, string1, string2 ); + sprintf( string, "%c** %s %s\n", HUD_PRINTTALK, string1, CHudTextMessage::BufferedLocaliseTextString( "#No_longer_hear_that_player" ) ); gHUD.m_TextMessage.MsgFunc_TextMsg(NULL, strlen(string)+1, string ); }