engine: client: replace COM_CheckString with COM_StringEmptyOrNULL

This commit is contained in:
Alibek Omarov
2026-02-20 23:43:26 +05:00
committed by a1batross
parent 24aaeb07cb
commit 3040552580
15 changed files with 53 additions and 49 deletions

View File

@@ -160,7 +160,7 @@ word CL_EventIndex( const char *name )
{
word i;
if( !COM_CheckString( name ))
if( COM_StringEmptyOrNULL( name ))
return 0;
for( i = 1; i < MAX_EVENTS && cl.event_precache[i][0]; i++ )

View File

@@ -324,7 +324,7 @@ void CL_DrawStringLen( cl_font_t *font, const char *s, int *width, int *height,
if( width )
*width = 0;
if( !COM_CheckString( s ))
if( COM_StringEmptyOrNULL( s ))
return;
if( FBitSet( flags, FONT_DRAW_UTF8 ))

View File

@@ -270,7 +270,7 @@ void CL_CenterPrint( const char *text, float y )
{
cl_font_t *font = Con_GetCurFont();
if( !COM_CheckString( text ) || !font || !font->valid )
if( COM_StringEmptyOrNULL( text ) || !font || !font->valid )
return;
clgame.centerPrint.totalWidth = 0;
@@ -596,7 +596,9 @@ Template to show hud messages
*/
void CL_HudMessage( const char *pMessage )
{
if( !COM_CheckString( pMessage )) return;
if( COM_StringEmptyOrNULL( pMessage ))
return;
CL_DispatchUserMessage( "HudText", Q_strlen( pMessage ) + 1, (void *)pMessage );
}
@@ -1321,7 +1323,7 @@ static model_t *CL_LoadSpriteModel( const char *filename, uint type, uint texFla
model_t *mod;
int i, start;
if( !COM_CheckString( filename ))
if( COM_StringEmptyOrNULL( filename ))
{
Con_Reportf( S_ERROR "%s: bad name!\n", __func__ );
return NULL;
@@ -1840,7 +1842,7 @@ pfnServerCmd
*/
static int GAME_EXPORT pfnServerCmd( const char *szCmdString )
{
if( !COM_CheckString( szCmdString ))
if( COM_StringEmptyOrNULL( szCmdString ))
return 0;
// just like the client typed "cmd xxxxx" at the console
@@ -1858,7 +1860,7 @@ pfnClientCmd
*/
static int GAME_EXPORT pfnClientCmd( const char *szCmdString )
{
if( !COM_CheckString( szCmdString ))
if( COM_StringEmptyOrNULL( szCmdString ))
return 0;
if( cls.initialized )
@@ -1883,7 +1885,7 @@ pfnFilteredClientCmd
*/
static int GAME_EXPORT pfnFilteredClientCmd( const char *szCmdString )
{
if( !COM_CheckString( szCmdString ))
if( COM_StringEmptyOrNULL( szCmdString ))
return 0;
// a1ba:
@@ -2065,7 +2067,7 @@ prints directly into console (can skip notify)
*/
static void GAME_EXPORT pfnConsolePrint( const char *string )
{
if( !COM_CheckString( string ))
if( COM_StringEmptyOrNULL( string ))
return;
// WON GoldSrc behavior
@@ -2437,7 +2439,7 @@ static int GAME_EXPORT CL_FindModelIndex( const char *m )
char filepath[MAX_QPATH];
int i;
if( !COM_CheckString( m ))
if( COM_StringEmptyOrNULL( m ))
return 0;
Q_strncpy( filepath, m, sizeof( filepath ));
@@ -2809,7 +2811,7 @@ static int GAME_EXPORT COM_ExpandFilename( const char *fileName, char *nameOutBu
{
char result[MAX_SYSPATH];
if( !COM_CheckString( fileName ) || !nameOutBuffer || nameOutBufferSize <= 0 )
if( COM_StringEmptyOrNULL( fileName ) || !nameOutBuffer || nameOutBufferSize <= 0 )
return 0;
// filename examples:
@@ -2922,7 +2924,7 @@ pfnServerCmdUnreliable
*/
static int GAME_EXPORT pfnServerCmdUnreliable( char *szCmdString )
{
if( !COM_CheckString( szCmdString ))
if( COM_StringEmptyOrNULL( szCmdString ))
return 0;
MSG_BeginClientCmd( &cls.datagram, clc_stringcmd );

View File

@@ -41,7 +41,7 @@ void UI_UpdateMenu( float realtime )
if( cls.key_dest == key_console ) return;
// if some deferred cmds is waiting
if( UI_IsVisible() && COM_CheckString( host.deferred_cmd ))
if( UI_IsVisible() && !COM_StringEmptyOrNULL( host.deferred_cmd ))
{
Cbuf_AddText( host.deferred_cmd );
host.deferred_cmd[0] = '\0';
@@ -517,7 +517,7 @@ static HIMAGE GAME_EXPORT pfnPIC_Load( const char *szPicName, const byte *image_
{
HIMAGE tx;
if( !COM_CheckString( szPicName ))
if( COM_StringEmptyOrNULL( szPicName ))
{
Con_Reportf( S_ERROR "%s: refusing to load image with empty name\n", __func__ );
return 0;
@@ -713,7 +713,9 @@ pfnPlaySound
*/
static void GAME_EXPORT pfnPlaySound( const char *szSound )
{
if( !COM_CheckString( szSound )) return;
if( COM_StringEmptyOrNULL( szSound ))
return;
S_StartLocalSound( szSound, VOL_NORM, false );
}

View File

@@ -955,7 +955,7 @@ static void CL_BeginUpload_f( void )
name = Cmd_Argv( 1 );
if( !COM_CheckString( name ))
if( COM_StringEmptyOrNULL( name ))
return;
if( !cl_allow_upload.value )
@@ -1478,7 +1478,7 @@ static void CL_Rcon_f( void )
netadr_t to;
int i;
if( !COM_CheckString( rcon_password.string ))
if( COM_StringEmptyOrNULL( rcon_password.string ))
{
Con_Printf( "You must set 'rcon_password' before issuing an rcon command.\n" );
return;
@@ -1492,7 +1492,7 @@ static void CL_Rcon_f( void )
}
else
{
if( !COM_CheckString( rcon_address.string ))
if( COM_StringEmptyOrNULL( rcon_address.string ))
{
Con_Printf( "You must either be connected or set the 'rcon_address' cvar to issue rcon commands\n" );
return;
@@ -1863,7 +1863,7 @@ static void CL_Reconnect_f( void )
return;
}
if( COM_CheckString( cls.servername ))
if( !COM_StringEmptyOrNULL( cls.servername ))
{
connprotocol_t proto = cls.legacymode;
@@ -1889,7 +1889,7 @@ retry connection to last server
*/
static void CL_Retry_f( void )
{
if( !COM_CheckString( cls.servername ))
if( COM_StringEmptyOrNULL( cls.servername ))
{
Con_Printf( "Can't retry, no previous connection.\n" );
return;
@@ -2001,17 +2001,17 @@ static void CL_ParseStatusMessage( netadr_t from, sizebuf_t *msg )
CL_FixupColorStringsForInfoString( s, infostring, sizeof( infostring ));
if( !COM_CheckString( Info_ValueForKey( infostring, "gamedir" )))
if( COM_StringEmptyOrNULL( Info_ValueForKey( infostring, "gamedir" )))
return; // unsupported proto
if( !COM_CheckString( Info_ValueForKey( infostring, "host" )))
if( COM_StringEmptyOrNULL( Info_ValueForKey( infostring, "host" )))
return;
if( !COM_CheckString( Info_ValueForKey( infostring, "map" )))
if( COM_StringEmptyOrNULL( Info_ValueForKey( infostring, "map" )))
return;
// don't let servers pretend they're something else
if( COM_CheckString( Info_ValueForKey( infostring, "gs" )))
if( !COM_StringEmptyOrNULL( Info_ValueForKey( infostring, "gs" )))
return;
maxcl = Q_atoi( Info_ValueForKey( infostring, "maxcl" ));
@@ -2826,7 +2826,7 @@ Replace the displayed name for some resources
*/
static const char *CL_CleanFileName( const char *filename )
{
if( COM_CheckString( filename ) && filename[0] == '!' )
if( !COM_StringEmptyOrNULL( filename ) && filename[0] == '!' )
return "customization";
return filename;
@@ -2881,7 +2881,7 @@ void CL_ProcessFile( qboolean successfully_received, const char *filename )
byte rgucMD5_hash[16];
resource_t *p;
if( COM_CheckString( filename ) && successfully_received )
if( !COM_StringEmptyOrNULL( filename ) && successfully_received )
{
if( filename[0] != '!' )
Con_Printf( "processing %s\n", filename );

View File

@@ -543,7 +543,7 @@ static void CL_StartResourceDownloading( const char *pszMessage, qboolean bCusto
{
resourceinfo_t ri;
if( COM_CheckString( pszMessage ))
if( !COM_StringEmptyOrNULL( pszMessage ))
Con_DPrintf( "%s", pszMessage );
cls.dl.nTotalSize = COM_SizeofResourceList( &cl.resourcesneeded, &ri );
@@ -2212,20 +2212,20 @@ void CL_ParseExec( sizebuf_t *msg )
is_class = MSG_ReadByte( msg );
if ( is_class )
if( is_class )
{
class_idx = MSG_ReadByte( msg );
if ( class_idx >= 0 && class_idx <= 11 && !Q_stricmp( GI->gamefolder, "tfc" ) )
if( class_idx >= 0 && class_idx <= 11 && !Q_stricmp( GI->gamefolder, "tfc" ) )
Cbuf_AddText( class_cfgs[class_idx] );
}
else if ( !Q_stricmp( GI->gamefolder, "tfc" ) )
else if( !Q_stricmp( GI->gamefolder, "tfc" ) )
{
Cbuf_AddText( "exec mapdefault.cfg\n" );
COM_FileBase( clgame.mapname, mapname, sizeof( mapname ));
if ( COM_CheckString( mapname ) )
if( !COM_StringEmptyOrNULL( mapname ) )
Cbuf_AddTextf( "exec %s.cfg\n", mapname );
}
}
@@ -2241,7 +2241,7 @@ qboolean CL_DispatchUserMessage( const char *pszName, int iSize, void *pbuf )
{
int i;
if( !COM_CheckString( pszName ))
if( COM_StringEmptyOrNULL( pszName ))
return false;
for( i = 0; i < MAX_USER_MESSAGES; i++ )

View File

@@ -267,7 +267,7 @@ static void CL_ParseQuakeServerInfo( sizebuf_t *msg )
{
pResName = MSG_ReadString( msg );
if( !COM_CheckString( pResName ))
if( COM_StringEmptyOrNULL( pResName ))
break; // end of list
pResource = Mem_Calloc( cls.mempool, sizeof( resource_t ));
@@ -285,7 +285,7 @@ static void CL_ParseQuakeServerInfo( sizebuf_t *msg )
{
pResName = MSG_ReadString( msg );
if( !COM_CheckString( pResName ))
if( COM_StringEmptyOrNULL( pResName ))
break; // end of list
pResource = Mem_Calloc( cls.mempool, sizeof( resource_t ));
@@ -840,7 +840,7 @@ static void CL_QuakeExecStuff( void )
int argc = 0;
// check if no commands this frame
if( !COM_CheckString( text ))
if( COM_StringEmptyOrNULL( text ))
return;
while( 1 )

View File

@@ -67,7 +67,7 @@ static void R_EnvShot( const float *vieworg, const char *name, qboolean skyshot,
{
static vec3_t viewPoint;
if( !COM_CheckString( name ))
if( COM_StringEmptyOrNULL( name ))
return;
if( cls.scrshot_action != scrshot_inactive )

View File

@@ -2998,7 +2998,7 @@ int GAME_EXPORT CL_DecalIndexFromName( const char *name )
{
int i;
if( !COM_CheckString( name ))
if( COM_StringEmptyOrNULL( name ))
return 0;
// look through the loaded sprite name list for SpriteName

View File

@@ -693,7 +693,7 @@ void ID_Init( void )
#else
{
const char *home = getenv( "HOME" );
if( COM_CheckString( home ) )
if( !COM_StringEmptyOrNULL( home ) )
{
FILE *cfg = fopen( va( "%s/.config/.xash_id", home ), "r" );
if( !cfg )
@@ -736,7 +736,7 @@ void ID_Init( void )
#else
{
const char *home = getenv( "HOME" );
if( COM_CheckString( home ) )
if( !COM_StringEmptyOrNULL( home ) )
{
FILE *cfg = fopen( va( "%s/.config/.xash_id", home ), "w" );
if( !cfg )

View File

@@ -458,7 +458,7 @@ void Key_WriteBindings( file_t *f )
for( i = 0; i < 256; i++ )
{
if( !COM_CheckString( keys[i].binding ))
if( COM_StringEmptyOrNULL( keys[i].binding ))
continue;
Cmd_Escape( newCommand, keys[i].binding, sizeof( newCommand ));
@@ -483,7 +483,7 @@ static void Key_Bindlist_f( void )
for( i = 0; i < 256; i++ )
{
if( !COM_CheckString( keys[i].binding ))
if( COM_StringEmptyOrNULL( keys[i].binding ))
continue;
Con_Printf( "%s \"%s\"\n", Key_KeynumToString( i ), keys[i].binding );

View File

@@ -111,7 +111,7 @@ void R_SetupSky( const char *name )
int i, len;
qboolean result;
if( !COM_CheckString( name ))
if( COM_StringEmptyOrNULL( name ))
{
ref.dllFuncs.R_SetupSky( NULL ); // unload skybox
return;
@@ -766,7 +766,7 @@ qboolean R_Init( void )
if( Sys_GetParmFromCmdLine( "-ref", requested_cmdline ))
success = R_LoadRenderer( requested_cmdline, false );
if( !success && COM_CheckString( r_refdll.string ) && Q_stricmp( requested_cmdline, r_refdll.string ))
if( !success && !COM_StringEmptyOrNULL( r_refdll.string ) && Q_stricmp( requested_cmdline, r_refdll.string ))
{
Q_strncpy( requested_cvar, r_refdll.string, sizeof( requested_cvar ));

View File

@@ -138,7 +138,7 @@ wavdata_t *S_LoadSound( sfx_t *sfx )
if( sfx->cache )
return sfx->cache;
if( !COM_CheckString( sfx->name ))
if( COM_StringEmptyOrNULL( sfx->name ))
return NULL;
// load it from disk
@@ -182,7 +182,7 @@ sfx_t *S_FindName( const char *pname, int *pfInCache )
uint i, hash;
string name;
if( !COM_CheckString( pname ) || !dma.initialized )
if( COM_StringEmptyOrNULL( pname ) || !dma.initialized )
return NULL;
if( Q_strlen( pname ) >= sizeof( sfx->name ))
@@ -336,7 +336,7 @@ sound_t S_RegisterSound( const char *name )
{
sfx_t *sfx;
if( !COM_CheckString( name ) || !dma.initialized )
if( COM_StringEmptyOrNULL( name ) || !dma.initialized )
return -1;
if( S_TestSoundChar( name, '!' ))

View File

@@ -91,13 +91,13 @@ void S_StartBackgroundTrack( const char *introTrack, const char *mainTrack, int
if( mainTrack && *mainTrack == '*' )
mainTrack = NULL;
if( !COM_CheckString( introTrack ) && !COM_CheckString( mainTrack ))
if( COM_StringEmptyOrNULL( introTrack ) && COM_StringEmptyOrNULL( mainTrack ))
return;
if( !introTrack ) introTrack = mainTrack;
if( !*introTrack ) return;
if( !COM_CheckString( mainTrack ))
if( COM_StringEmptyOrNULL( mainTrack ))
s_bgTrack.loopName[0] = '\0';
else Q_strncpy( s_bgTrack.loopName, mainTrack, sizeof( s_bgTrack.loopName ));

View File

@@ -56,7 +56,7 @@ static qboolean Voice_IsGoldSrcMode( const char *codec )
// it will send an empty codec
// however, decoding is still possible
// if the voice data contains Opus
return( COM_CheckString( codec ) == 0 || Q_strstr( codec, "voice_speex" ) != NULL );
return( !COM_StringEmptyOrNULL( codec ) == 0 || Q_strstr( codec, "voice_speex" ) != NULL );
}
/*