Browse Source

engine: client: replace some obvious va uses by temp buffer and Q_snprintf

pull/2/head
Alibek Omarov 1 year ago
parent
commit
9690fe9334
  1. 12
      engine/client/cl_game.c
  2. 7
      engine/client/cl_parse.c
  3. 4
      engine/client/cl_tent.c
  4. 13
      engine/client/s_main.c

12
engine/client/cl_game.c

@ -590,7 +590,11 @@ static void CL_InitTitles( const char *filename ) @@ -590,7 +590,11 @@ static void CL_InitTitles( const char *filename )
// initialize text messages (game_text)
for( i = 0; i < MAX_TEXTCHANNELS; i++ )
{
cl_textmessage[i].pName = _copystring( clgame.mempool, va( TEXT_MSGNAME, i ), __FILE__, __LINE__ );
char name[MAX_VA_STRING];
Q_snprintf( name, sizeof( name ), TEXT_MSGNAME, i );
cl_textmessage[i].pName = _copystring( clgame.mempool, name, __FILE__, __LINE__ );
cl_textmessage[i].pMessage = cl_textbuffer[i];
}
@ -1852,7 +1856,11 @@ client_textmessage_t *CL_TextMessageGet( const char *pName ) @@ -1852,7 +1856,11 @@ client_textmessage_t *CL_TextMessageGet( const char *pName )
// first check internal messages
for( i = 0; i < MAX_TEXTCHANNELS; i++ )
{
if( !Q_strcmp( pName, va( TEXT_MSGNAME, i )))
char name[MAX_VA_STRING];
Q_snprintf( name, sizeof( name ), TEXT_MSGNAME, i );
if( !Q_strcmp( pName, name ))
return cl_textmessage + i;
}

7
engine/client/cl_parse.c

@ -2694,10 +2694,15 @@ void CL_LegacyParseResourceList( sizebuf_t *msg ) @@ -2694,10 +2694,15 @@ void CL_LegacyParseResourceList( sizebuf_t *msg )
for( i = 0; i < reslist.rescount; i++ )
{
char soundpath[MAX_VA_STRING];
const char *path;
if( reslist.restype[i] == t_sound )
path = va( DEFAULT_SOUNDPATH "%s", reslist.resnames[i] );
{
Q_snprintf( soundpath, sizeof( soundpath ), DEFAULT_SOUNDPATH "%s", reslist.resnames[i] );
path = soundpath;
}
else path = reslist.resnames[i];
if( FS_FileExists( path, false ))

4
engine/client/cl_tent.c

@ -2929,7 +2929,9 @@ void CL_PlayerDecal( int playernum, int customIndex, int entityIndex, float *pos @@ -2929,7 +2929,9 @@ void CL_PlayerDecal( int playernum, int customIndex, int entityIndex, float *pos
if( !pCust->nUserData1 )
{
int sprayTextureIndex;
const char *decalname = va( "player%dlogo%d", playernum, customIndex );
char decalname[MAX_VA_STRING];
Q_snprintf( decalname, sizeof( decalname ), "player%dlogo%d", playernum, customIndex );
sprayTextureIndex = ref.dllFuncs.GL_FindTexture( decalname );
if( sprayTextureIndex != 0 )
{

13
engine/client/s_main.c

@ -1842,8 +1842,12 @@ void S_Music_f( void ) @@ -1842,8 +1842,12 @@ void S_Music_f( void )
for( i = 0; i < 2; i++ )
{
const char *intro_path = va( "media/%s.%s", intro, ext[i] );
const char *main_path = va( "media/%s.%s", main, ext[i] );
char intro_path[MAX_VA_STRING];
char main_path[MAX_VA_STRING];
char track_path[MAX_VA_STRING];
Q_snprintf( intro_path, sizeof( intro_path ), "media/%s.%s", intro, ext[i] );
Q_snprintf( main_path, sizeof( main_path ), "media/%s.%s", main, ext[i] );
if( FS_FileExists( intro_path, false ) && FS_FileExists( main_path, false ))
{
@ -1851,7 +1855,10 @@ void S_Music_f( void ) @@ -1851,7 +1855,10 @@ void S_Music_f( void )
S_StartBackgroundTrack( intro, main, 0, false );
break;
}
else if( FS_FileExists( va( "media/%s.%s", track, ext[i] ), false ))
Q_snprintf( track_path, sizeof( track_path ), "media/%s.%s", track, ext[i] );
if( FS_FileExists( track_path, false ))
{
// single non-looped theme
S_StartBackgroundTrack( track, NULL, 0, false );

Loading…
Cancel
Save