From de70e12bbe3c69f2e6ebc6370ee21e0596d59986 Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Sat, 21 Feb 2026 00:04:30 +0500 Subject: [PATCH] engine: server: replace COM_CheckString and COM_CheckStringEmpty by COM_StringEmptyOrNULL and COM_StringEmpty --- engine/server/server.h | 2 +- engine/server/sv_client.c | 20 ++++++++++---------- engine/server/sv_cmds.c | 8 ++++---- engine/server/sv_custom.c | 4 ++-- engine/server/sv_game.c | 30 +++++++++++++++--------------- engine/server/sv_init.c | 26 +++++++++++++------------- engine/server/sv_log.c | 7 ++++--- engine/server/sv_main.c | 4 ++-- engine/server/sv_query.c | 2 +- engine/server/sv_save.c | 8 ++++---- 10 files changed, 56 insertions(+), 55 deletions(-) diff --git a/engine/server/server.h b/engine/server/server.h index be883051..1bded216 100644 --- a/engine/server/server.h +++ b/engine/server/server.h @@ -550,7 +550,7 @@ void SV_GetPlayerCount( int *clients, int *bots ); static inline qboolean SV_HavePassword( void ) { - if( COM_CheckStringEmpty( sv_password.string ) && Q_stricmp( sv_password.string, "none" )) + if( !COM_StringEmpty( sv_password.string ) && Q_stricmp( sv_password.string, "none" )) return true; return false; diff --git a/engine/server/sv_client.c b/engine/server/sv_client.c index 409bd016..b10ac10f 100644 --- a/engine/server/sv_client.c +++ b/engine/server/sv_client.c @@ -192,7 +192,7 @@ tell the client about this problem */ static void SV_FailDownload( sv_client_t *cl, const char *filename ) { - if( !COM_CheckString( filename )) + if( COM_StringEmptyOrNULL( filename )) return; MSG_BeginServerCmd( &cl->netchan.message, svc_filetxferfailed ); @@ -477,7 +477,7 @@ edict_t *GAME_EXPORT SV_FakeConnect( const char *netname ) userinfo[0] = '\0'; - if( !COM_CheckString( netname )) + if( COM_StringEmptyOrNULL( netname )) netname = "Bot"; // setup fake client params @@ -766,7 +766,7 @@ sv_client_t *SV_ClientByName( const char *name ) sv_client_t *cl; int i; - if( !COM_CheckString( name )) + if( COM_StringEmptyOrNULL( name )) return NULL; for( i = 0, cl = svs.clients; cl && i < svgame.globals->maxClients; i++, cl++ ) @@ -967,7 +967,7 @@ static void SV_BuildNetAnswer( netadr_t from ) if( FBitSet( cv->flags, FCVAR_PROTECTED )) { - if( COM_CheckStringEmpty( cv->string ) && Q_stricmp( cv->string, "none" )) + if( !COM_StringEmpty( cv->string ) && Q_stricmp( cv->string, "none" )) Info_SetValueForKey( string, cv->name, "1", sizeof( string )); else Info_SetValueForKey( string, cv->name, "0", sizeof( string )); } @@ -1032,7 +1032,7 @@ Rcon_Validate */ static qboolean Rcon_Validate( void ) { - if( !COM_CheckString( rcon_password.string )) + if( COM_StringEmptyOrNULL( rcon_password.string )) return false; if( Q_strcmp( Cmd_Argv( 1 ), rcon_password.string )) return false; @@ -1053,7 +1053,7 @@ void SV_RemoteCommand( netadr_t from, sizebuf_t *msg ) const char *adr; int i; - if( !rcon_enable.value || !COM_CheckStringEmpty( rcon_password.string )) + if( !rcon_enable.value || COM_StringEmpty( rcon_password.string )) return; adr = NET_AdrToString( from ); @@ -1508,7 +1508,7 @@ void SV_TogglePause( const char *msg ) sv.paused ^= 1; - if( COM_CheckString( msg )) + if( !COM_StringEmptyOrNULL( msg )) SV_BroadcastPrintf( NULL, "%s", msg ); // send notification to all clients @@ -1822,7 +1822,7 @@ static void SV_UserinfoChanged( sv_client_t *cl ) const char *val; int ival; - if( !COM_CheckString( cl->userinfo )) + if( COM_StringEmptyOrNULL( cl->userinfo )) return; if( !SV_ShouldUpdateUserinfo( cl )) @@ -1846,7 +1846,7 @@ static void SV_UserinfoChanged( sv_client_t *cl ) val = Info_ValueForKey( cl->userinfo, "name" ); } - if( !COM_CheckStringEmpty( name1 )) + if( COM_StringEmpty( name1 )) { Info_SetValueForKey( cl->userinfo, "name", "unnamed", sizeof( cl->userinfo )); val = Info_ValueForKey( cl->userinfo, "name" ); @@ -2069,7 +2069,7 @@ static qboolean SV_DownloadFile_f( sv_client_t *cl ) name = Cmd_Argv( 1 ); - if( !COM_CheckString( name )) + if( COM_StringEmptyOrNULL( name )) return true; if( !COM_IsSafeFileToDownload( name ) || !sv_allow_download.value ) diff --git a/engine/server/sv_cmds.c b/engine/server/sv_cmds.c index 92d492df..471c2303 100644 --- a/engine/server/sv_cmds.c +++ b/engine/server/sv_cmds.c @@ -702,11 +702,11 @@ static void SV_Status_f( void ) Q_strncpy( arch, Info_ValueForKey( cl->useragent, "a" ), sizeof( arch )); buildnum = Q_atoi( Info_ValueForKey( cl->useragent, "b" )); - if( !COM_CheckStringEmpty( version )) + if( COM_StringEmpty( version )) Q_strncpy( version, "n/a", sizeof( version )); - if( !COM_CheckStringEmpty( os )) + if( COM_StringEmpty( os )) Q_strncpy( os, "n/a", sizeof( os )); - if( !COM_CheckStringEmpty( arch )) + if( COM_StringEmpty( arch )) Q_strncpy( arch, "n/a", sizeof( arch )); Con_Printf( "%2i %5i %4s %4s %.5f %5i %s (%s-%s %i)\t%8s\t%8s\n", @@ -1010,7 +1010,7 @@ static void SV_ListMessages_f( void ) Con_Printf( "num size name\n" ); for( i = 1; i < MAX_USER_MESSAGES; i++ ) { - if( !COM_CheckStringEmpty( svgame.msg[i].name )) + if( COM_StringEmpty( svgame.msg[i].name )) break; Con_Printf( "%3d\t%3d\t%s\n", svgame.msg[i].number, svgame.msg[i].size, svgame.msg[i].name ); diff --git a/engine/server/sv_custom.c b/engine/server/sv_custom.c index 159358be..0529790e 100644 --- a/engine/server/sv_custom.c +++ b/engine/server/sv_custom.c @@ -182,7 +182,7 @@ void SV_ParseConsistencyResponse( sv_client_t *cl, sizebuf_t *msg ) dropmessage[0] = 0; if( svgame.dllFuncs.pfnInconsistentFile( cl->edict, sv.resources[badresindex - 1].szFileName, dropmessage )) { - if( COM_CheckString( dropmessage )) + if( !COM_StringEmptyOrNULL( dropmessage )) SV_ClientPrintf( cl, "%s", dropmessage ); SV_DropClient( cl, false ); } @@ -562,7 +562,7 @@ void SV_SendResources( sv_client_t *cl, sizebuf_t *msg ) MSG_WriteLong( msg, svs.spawncount ); MSG_WriteLong( msg, 0 ); - if( COM_CheckString( sv_downloadurl.string ) && Q_strlen( sv_downloadurl.string ) < 256 ) + if( !COM_StringEmptyOrNULL( sv_downloadurl.string ) && Q_strlen( sv_downloadurl.string ) < 256 ) { MSG_BeginServerCmd( msg, svc_resourcelocation ); MSG_WriteString( msg, sv_downloadurl.string ); diff --git a/engine/server/sv_game.c b/engine/server/sv_game.c index ce26db5a..04ca59c0 100644 --- a/engine/server/sv_game.c +++ b/engine/server/sv_game.c @@ -264,7 +264,7 @@ void GAME_EXPORT SV_SetModel( edict_t *ent, const char *modelname ) return; } - if( COM_CheckString( name )) + if( !COM_StringEmptyOrNULL( name )) { ent->v.model = MAKE_STRING( sv.model_precache[i] ); ent->v.modelindex = i; @@ -746,7 +746,7 @@ void SV_QueueChangeLevel( const char *level, const char *landname ) Q_strncpy( mapname, level, sizeof( mapname )); COM_StripExtension( mapname ); - if( COM_CheckString( landname )) + if( !COM_StringEmptyOrNULL( landname )) smooth = true; flags = SV_MapIsValid( mapname, landname ); @@ -937,7 +937,7 @@ uint SV_MapIsValid( const char *filename, const char *landmark_name ) char token[MAX_TOKEN]; string check_name; - need_landmark = COM_CheckString( landmark_name ); + need_landmark = !COM_StringEmptyOrNULL( landmark_name ); if( !need_landmark ) { @@ -1329,7 +1329,7 @@ static int GAME_EXPORT pfnModelIndex( const char *m ) char name[MAX_QPATH]; int i; - if( !COM_CheckString( m )) + if( COM_StringEmptyOrNULL( m )) return 0; if( *m == '\\' || *m == '/' ) m++; @@ -1387,7 +1387,7 @@ static void GAME_EXPORT pfnChangeLevel( const char *level, const char *landmark char landname[MAX_QPATH]; char *text; - if( !COM_CheckString( level ) || sv.state != ss_active ) + if( COM_StringEmptyOrNULL( level ) || sv.state != ss_active ) return; // ??? // make sure we don't issue two changelevels @@ -1400,7 +1400,7 @@ static void GAME_EXPORT pfnChangeLevel( const char *level, const char *landmark // g-cont. some level-designers wrote landmark name with space // and Cmd_TokenizeString separating all the after space as next argument // emulate this bug for compatibility - if( COM_CheckString( landmark )) + if( !COM_StringEmptyOrNULL( landmark )) { text = (char *)landname; while( *landmark && ((byte)*landmark) != ' ' ) @@ -1501,7 +1501,7 @@ static edict_t *GAME_EXPORT SV_FindEntityByString( edict_t *pStartEdict, const c edict_t *ed; const char *t; - if( !COM_CheckString( pszValue )) + if( COM_StringEmptyOrNULL( pszValue )) return svgame.edicts; if( pStartEdict ) e = NUM_FOR_EDICT( pStartEdict ); @@ -1990,7 +1990,7 @@ int SV_BuildSoundMsg( sizebuf_t *msg, edict_t *ent, int chan, const char *sample pitch = bound( 0, pitch, 255 ); } - if( !COM_CheckString( sample )) + if( COM_StringEmptyOrNULL( sample )) { Con_Reportf( S_ERROR "%s: passed NULL sample\n", __func__ ); return 0; @@ -2469,7 +2469,7 @@ int GAME_EXPORT pfnDecalIndex( const char *m ) { int i; - if( !COM_CheckString( m )) + if( COM_StringEmptyOrNULL( m )) return -1; for( i = 1; i < MAX_DECALS && host.draw_decals[i][0]; i++ ) @@ -2524,7 +2524,7 @@ static qboolean SV_RewriteMessage( void ) else if( idx >= 0 && idx < MAX_SOUNDS ) sample = sv.sound_precache[idx]; - if( !COM_CheckString( sample )) + if( COM_StringEmptyOrNULL( sample )) { Con_Printf( S_ERROR "%s: unrecognized sample in svc_spawnstaticsound, index %d, flags 0x%x\n", __func__, idx, flags ); return false; @@ -3501,7 +3501,7 @@ static int GAME_EXPORT pfnRegUserMsg( const char *pszName, int iSize ) { int i; - if( !COM_CheckString( pszName )) + if( COM_StringEmptyOrNULL( pszName )) return svc_bad; if( Q_strlen( pszName ) >= sizeof( svgame.msg[0].name )) @@ -4058,7 +4058,7 @@ void GAME_EXPORT SV_PlaybackEventFull( int flags, const edict_t *pInvoker, word } // check event for precached - if( !COM_CheckString( sv.event_precache[eventindex] )) + if( COM_StringEmptyOrNULL( sv.event_precache[eventindex] )) { Con_Printf( S_ERROR "%s: event %i was not precached\n", __func__, eventindex ); return; @@ -4511,7 +4511,7 @@ static void GAME_EXPORT pfnForceUnmodified( FORCE_TYPE type, float *mins, float consistency_t *pc; int i; - if( !COM_CheckString( filename )) + if( COM_StringEmptyOrNULL( filename )) return; if( sv.state == ss_loading ) @@ -4609,7 +4609,7 @@ static void GAME_EXPORT pfnQueryClientCvarValue( const edict_t *player, const ch { sv_client_t *cl; - if( !COM_CheckString( cvarName )) + if( COM_StringEmptyOrNULL( cvarName )) return; if(( cl = SV_ClientFromEdict( player, false )) != NULL ) @@ -4636,7 +4636,7 @@ static void GAME_EXPORT pfnQueryClientCvarValue2( const edict_t *player, const c { sv_client_t *cl; - if( !COM_CheckString( cvarName )) + if( COM_StringEmptyOrNULL( cvarName )) return; if(( cl = SV_ClientFromEdict( player, false )) != NULL ) diff --git a/engine/server/sv_init.c b/engine/server/sv_init.c index c3906023..e8e34f94 100644 --- a/engine/server/sv_init.c +++ b/engine/server/sv_init.c @@ -72,7 +72,7 @@ static void SV_SendSingleResource( const char *name, resourcetype_t type, int in resource_t *pResource = &sv.resources[sv.num_resources]; int nSize = 0; - if( !COM_CheckString( name )) + if( COM_StringEmptyOrNULL( name )) return; switch( type ) @@ -105,7 +105,7 @@ int SV_ModelIndex( const char *filename ) char name[MAX_QPATH]; int i; - if( !COM_CheckString( filename )) + if( COM_StringEmptyOrNULL( filename )) return 0; if( *filename == '\\' || *filename == '/' ) @@ -150,7 +150,7 @@ int GAME_EXPORT SV_SoundIndex( const char *filename ) char name[MAX_QPATH]; int i; - if( !COM_CheckString( filename )) + if( COM_StringEmptyOrNULL( filename )) return 0; if( filename[0] == '!' ) @@ -201,7 +201,7 @@ int SV_EventIndex( const char *filename ) char name[MAX_QPATH]; int i; - if( !COM_CheckString( filename )) + if( COM_StringEmptyOrNULL( filename )) return 0; Q_strncpy( name, filename, sizeof( name )); @@ -243,7 +243,7 @@ int GAME_EXPORT SV_GenericIndex( const char *filename ) char name[MAX_QPATH]; int i; - if( !COM_CheckString( filename )) + if( COM_StringEmptyOrNULL( filename )) return 0; Q_strncpy( name, filename, sizeof( name )); @@ -385,7 +385,7 @@ static void SV_CreateResourceList( void ) for( i = 1; i < MAX_CUSTOM; i++ ) { s = sv.files_precache[i]; - if( !COM_CheckString( s )) break; // end of list + if( COM_StringEmptyOrNULL( s )) break; // end of list nSize = FS_FileSize( s, false ); SV_AddResource( t_generic, s, nSize, RES_FATALIFMISSING, i ); } @@ -393,7 +393,7 @@ static void SV_CreateResourceList( void ) for( i = 1; i < MAX_SOUNDS; i++ ) { s = sv.sound_precache[i]; - if( !COM_CheckString( s )) + if( COM_StringEmptyOrNULL( s )) break; // end of list if( s[0] == '!' ) @@ -414,7 +414,7 @@ static void SV_CreateResourceList( void ) for( i = 1; i < MAX_MODELS; i++ ) { s = sv.model_precache[i]; - if( !COM_CheckString( s )) break; // end of list + if( COM_StringEmptyOrNULL( s )) break; // end of list nSize = ( s[0] != '*' ) ? FS_FileSize( s, false ) : 0; SV_AddResource( t_model, s, nSize, sv.model_precache_flags[i], i ); } @@ -428,7 +428,7 @@ static void SV_CreateResourceList( void ) for( i = 1; i < MAX_EVENTS; i++ ) { s = sv.event_precache[i]; - if( !COM_CheckString( s )) break; // end of list + if( COM_StringEmptyOrNULL( s )) break; // end of list nSize = FS_FileSize( s, false ); SV_AddResource( t_eventscript, s, nSize, RES_FATALIFMISSING, i ); } @@ -685,10 +685,10 @@ void SV_DeactivateServer( void ) int i; const char *cycle = Cvar_VariableString( "disconcfgfile" ); - if( COM_CheckString( cycle )) + if( !COM_StringEmptyOrNULL( cycle )) Cbuf_AddTextf( "exec %s\n", cycle ); - if( COM_CheckStringEmpty( sv.name )) + if( !COM_StringEmpty( sv.name )) Cbuf_AddTextf( "exec maps/%s_unload.cfg\n", sv.name ); if( !svs.initialized || sv.state == ss_dead ) @@ -1037,13 +1037,13 @@ qboolean SV_SpawnServer( const char *mapname, const char *startspot, qboolean ba cycle = Cvar_VariableString( "mapchangecfgfile" ); - if( COM_CheckString( cycle )) + if( !COM_StringEmptyOrNULL( cycle )) Cbuf_AddTextf( "exec %s\n", cycle ); Cbuf_AddTextf( "exec maps/%s_load.cfg\n", mapname ); // let's not have any servers with no name - if( !COM_CheckString( hostname.string )) + if( COM_StringEmptyOrNULL( hostname.string )) Cvar_Set( "hostname", svgame.dllFuncs.pfnGetGameDescription ? svgame.dllFuncs.pfnGetGameDescription() : FS_Title( )); if( startspot ) diff --git a/engine/server/sv_log.c b/engine/server/sv_log.c index f58a31a5..bd49756b 100644 --- a/engine/server/sv_log.c +++ b/engine/server/sv_log.c @@ -45,9 +45,10 @@ void Log_Open( void ) today = localtime( <ime ); temp = Cvar_VariableString( "logsdir" ); - if( COM_CheckString( temp ) && !Q_strchr( temp, ':' ) && !Q_strstr( temp, ".." )) + if( !COM_StringEmptyOrNULL( temp ) && !Q_strchr( temp, ':' ) && !Q_strstr( temp, ".." )) Q_snprintf( szFileBase, sizeof( szFileBase ), "%s/L%02i%02i", temp, today->tm_mon + 1, today->tm_mday ); - else Q_snprintf( szFileBase, sizeof( szFileBase ), "logs/L%02i%02i", today->tm_mon + 1, today->tm_mday ); + else + Q_snprintf( szFileBase, sizeof( szFileBase ), "logs/L%02i%02i", today->tm_mon + 1, today->tm_mday ); for ( i = 0; i < 1000; i++ ) { @@ -197,7 +198,7 @@ void SV_SetLogAddress_f( void ) } s = Cmd_Argv( 1 ); - if( !COM_CheckString( s )) + if( COM_StringEmptyOrNULL( s )) { Con_Printf( "logaddress: unparseable address\n" ); return; diff --git a/engine/server/sv_main.c b/engine/server/sv_main.c index 5fd89177..9bb065f8 100644 --- a/engine/server/sv_main.c +++ b/engine/server/sv_main.c @@ -1030,7 +1030,7 @@ void SV_FinalMessage( const char *message, qboolean reconnect ) MSG_Init( &msg, "FinalMessage", msg_buf, sizeof( msg_buf )); - if( COM_CheckString( message )) + if( !COM_StringEmptyOrNULL( message )) { MSG_BeginServerCmd( &msg, svc_print ); MSG_WriteString( &msg, message ); @@ -1112,7 +1112,7 @@ void SV_Shutdown( const char *finalmsg ) // don't forget to reset sv_background state Cvar_DirectFullSet( &sv_background, "0", FCVAR_READ_ONLY ); - if( COM_CheckString( finalmsg )) + if( !COM_StringEmptyOrNULL( finalmsg )) Con_Printf( "%s", finalmsg ); // rcon will be disconnected diff --git a/engine/server/sv_query.c b/engine/server/sv_query.c index 7f3a4048..2bed6ab1 100644 --- a/engine/server/sv_query.c +++ b/engine/server/sv_query.c @@ -94,7 +94,7 @@ static void SV_SourceQuery_Rules( netadr_t from ) if( FBitSet( cvar->flags, FCVAR_PROTECTED )) { - if( COM_CheckStringEmpty( cvar->string ) && Q_stricmp( cvar->string, "none" )) + if( !COM_StringEmpty( cvar->string ) && Q_stricmp( cvar->string, "none" )) MSG_WriteString( &buf, "1" ); else MSG_WriteString( &buf, "0" ); } diff --git a/engine/server/sv_save.c b/engine/server/sv_save.c index b051a184..42c80d2c 100644 --- a/engine/server/sv_save.c +++ b/engine/server/sv_save.c @@ -1383,7 +1383,7 @@ static void LoadClientState( SAVERESTOREDATA *pSaveData, const char *level, qboo // restore camera view here edict_t *pent = pSaveData->pTable[bound( 0, (word)header.viewentity, pSaveData->tableCount )].pent; - if( COM_CheckStringEmpty( header.introTrack ) ) + if( !COM_StringEmpty( header.introTrack )) { // NOTE: music is automatically goes across transition, never restore it on changelevel MSG_BeginServerCmd( &sv.signon, svc_stufftext ); @@ -2134,7 +2134,7 @@ qboolean SV_LoadGame( const char *pPath ) if( UI_CreditsActive( )) return false; - if( !COM_CheckString( pPath )) + if( COM_StringEmptyOrNULL( pPath )) return false; // silently ignore if missed @@ -2201,7 +2201,7 @@ qboolean SV_SaveGame( const char *pName ) char comment[80]; string savename; - if( !COM_CheckString( pName )) + if( COM_StringEmptyOrNULL( pName )) return false; // can we save at this point? @@ -2441,7 +2441,7 @@ int GAME_EXPORT SV_GetSaveComment( const char *savename, char *comment ) FS_Close( f ); // at least mapname should be filled - if( COM_CheckStringEmpty( mapName ) ) + if( !COM_StringEmpty( mapName )) { time_t fileTime; const struct tm *file_tm;