engine: add size argument to COM_FileBase calls

This commit is contained in:
Alibek Omarov 2023-04-26 04:04:48 +03:00
parent fbdd79644b
commit 8c7db8499f
11 changed files with 34 additions and 32 deletions

View File

@ -2007,7 +2007,7 @@ void CL_ParseExec( sizebuf_t *msg )
{
Cbuf_AddText( "exec mapdefault.cfg\n" );
COM_FileBase( clgame.mapname, mapname );
COM_FileBase( clgame.mapname, mapname, sizeof( mapname ));
if ( COM_CheckString( mapname ) )
Cbuf_AddTextf( "exec %s.cfg\n", mapname );

View File

@ -157,7 +157,7 @@ void CL_UpdateStudioTexture( cl_entity_t *entity, mstudiotexture_t *ptexture, in
// build name of original texture
Q_strncpy( mdlname, entity->model->name, sizeof( mdlname ));
COM_FileBase( ptexture->name, name );
COM_FileBase( ptexture->name, name, sizeof( name ));
COM_StripExtension( mdlname );
Q_snprintf( texname, sizeof( texname ), "#%s/%s.mdl", mdlname, name );

View File

@ -340,7 +340,7 @@ static void Touch_ExportConfig_f( void )
if( Q_strstr( name, "touch_presets/" ))
{
COM_FileBase( name, profilebase );
COM_FileBase( name, profilebase, sizeof( profilebase ));
Q_snprintf( profilename, sizeof( profilebase ), "touch_profiles/%s (copy).cfg", profilebase );
}
else Q_strncpy( profilename, name, sizeof( profilename ));

View File

@ -146,7 +146,7 @@ int Cmd_ListMaps( search_t *t, char *lastmapname, size_t len )
}
if( f ) FS_Close(f);
COM_FileBase( t->filenames[i], mapname );
COM_FileBase( t->filenames[i], mapname, sizeof( mapname ));
switch( ver )
{
@ -194,7 +194,7 @@ qboolean Cmd_GetMapList( const char *s, char *completedname, int length )
t = FS_Search( va( "maps/%s*.bsp", s ), true, con_gamemaps->value );
if( !t ) return false;
COM_FileBase( t->filenames[0], matchbuf );
COM_FileBase( t->filenames[0], matchbuf, sizeof( matchbuf ));
if( completedname && length )
Q_strncpy( completedname, matchbuf, length );
if( t->numfilenames == 1 ) return true;
@ -231,7 +231,7 @@ qboolean Cmd_GetDemoList( const char *s, char *completedname, int length )
t = FS_Search( va( "%s*.dem", s ), true, true );
if( !t ) return false;
COM_FileBase( t->filenames[0], matchbuf );
COM_FileBase( t->filenames[0], matchbuf, sizeof( matchbuf ));
if( completedname && length )
Q_strncpy( completedname, matchbuf, length );
if( t->numfilenames == 1 ) return true;
@ -241,7 +241,7 @@ qboolean Cmd_GetDemoList( const char *s, char *completedname, int length )
if( Q_stricmp( COM_FileExtension( t->filenames[i] ), "dem" ))
continue;
COM_FileBase( t->filenames[i], matchbuf );
COM_FileBase( t->filenames[i], matchbuf, sizeof( matchbuf ));
Con_Printf( "%16s\n", matchbuf );
numdems++;
}
@ -277,7 +277,7 @@ qboolean Cmd_GetMovieList( const char *s, char *completedname, int length )
t = FS_Search( va( "media/%s*.avi", s ), true, false );
if( !t ) return false;
COM_FileBase( t->filenames[0], matchbuf );
COM_FileBase( t->filenames[0], matchbuf, sizeof( matchbuf ));
if( completedname && length )
Q_strncpy( completedname, matchbuf, length );
if( t->numfilenames == 1 ) return true;
@ -287,7 +287,7 @@ qboolean Cmd_GetMovieList( const char *s, char *completedname, int length )
if( Q_stricmp( COM_FileExtension( t->filenames[i] ), "avi" ))
continue;
COM_FileBase( t->filenames[i], matchbuf );
COM_FileBase( t->filenames[i], matchbuf, sizeof( matchbuf ));
Con_Printf( "%16s\n", matchbuf );
nummovies++;
}
@ -324,7 +324,7 @@ qboolean Cmd_GetMusicList( const char *s, char *completedname, int length )
t = FS_Search( va( "media/%s*.*", s ), true, false );
if( !t ) return false;
COM_FileBase( t->filenames[0], matchbuf );
COM_FileBase( t->filenames[0], matchbuf, sizeof( matchbuf ));
if( completedname && length )
Q_strncpy( completedname, matchbuf, length );
if( t->numfilenames == 1 ) return true;
@ -336,7 +336,7 @@ qboolean Cmd_GetMusicList( const char *s, char *completedname, int length )
if( Q_stricmp( ext, "wav" ) && Q_stricmp( ext, "mp3" ))
continue;
COM_FileBase( t->filenames[i], matchbuf );
COM_FileBase( t->filenames[i], matchbuf, sizeof( matchbuf ));
Con_Printf( "%16s\n", matchbuf );
numtracks++;
}
@ -372,7 +372,7 @@ qboolean Cmd_GetSavesList( const char *s, char *completedname, int length )
t = FS_Search( va( DEFAULT_SAVE_DIRECTORY "%s*.sav", s ), true, true ); // lookup only in gamedir
if( !t ) return false;
COM_FileBase( t->filenames[0], matchbuf );
COM_FileBase( t->filenames[0], matchbuf, sizeof( matchbuf ));
if( completedname && length )
Q_strncpy( completedname, matchbuf, length );
if( t->numfilenames == 1 ) return true;
@ -382,7 +382,7 @@ qboolean Cmd_GetSavesList( const char *s, char *completedname, int length )
if( Q_stricmp( COM_FileExtension( t->filenames[i] ), "sav" ))
continue;
COM_FileBase( t->filenames[i], matchbuf );
COM_FileBase( t->filenames[i], matchbuf, sizeof( matchbuf ));
Con_Printf( "%16s\n", matchbuf );
numsaves++;
}
@ -419,7 +419,7 @@ qboolean Cmd_GetConfigList( const char *s, char *completedname, int length )
t = FS_Search( va( "%s*.cfg", s ), true, false );
if( !t ) return false;
COM_FileBase( t->filenames[0], matchbuf );
COM_FileBase( t->filenames[0], matchbuf, sizeof( matchbuf ));
if( completedname && length )
Q_strncpy( completedname, matchbuf, length );
if( t->numfilenames == 1 ) return true;
@ -429,7 +429,7 @@ qboolean Cmd_GetConfigList( const char *s, char *completedname, int length )
if( Q_stricmp( COM_FileExtension( t->filenames[i] ), "cfg" ))
continue;
COM_FileBase( t->filenames[i], matchbuf );
COM_FileBase( t->filenames[i], matchbuf, sizeof( matchbuf ));
Con_Printf( "%16s\n", matchbuf );
numconfigs++;
}
@ -519,7 +519,7 @@ qboolean Cmd_GetItemsList( const char *s, char *completedname, int length )
t = FS_Search( va( "%s/%s*.txt", clgame.itemspath, s ), true, false );
if( !t ) return false;
COM_FileBase( t->filenames[0], matchbuf );
COM_FileBase( t->filenames[0], matchbuf, sizeof( matchbuf ));
if( completedname && length )
Q_strncpy( completedname, matchbuf, length );
if( t->numfilenames == 1 ) return true;
@ -529,7 +529,7 @@ qboolean Cmd_GetItemsList( const char *s, char *completedname, int length )
if( Q_stricmp( COM_FileExtension( t->filenames[i] ), "txt" ))
continue;
COM_FileBase( t->filenames[i], matchbuf );
COM_FileBase( t->filenames[i], matchbuf, sizeof( matchbuf ));
Con_Printf( "%16s\n", matchbuf );
numitems++;
}
@ -711,7 +711,7 @@ qboolean Cmd_GetCustomList( const char *s, char *completedname, int length )
t = FS_Search( va( "%s*.hpk", s ), true, false );
if( !t ) return false;
COM_FileBase( t->filenames[0], matchbuf );
COM_FileBase( t->filenames[0], matchbuf, sizeof( matchbuf ));
if( completedname && length )
Q_strncpy( completedname, matchbuf, length );
if( t->numfilenames == 1 ) return true;
@ -721,7 +721,7 @@ qboolean Cmd_GetCustomList( const char *s, char *completedname, int length )
if( Q_stricmp( COM_FileExtension( t->filenames[i] ), "hpk" ))
continue;
COM_FileBase( t->filenames[i], matchbuf );
COM_FileBase( t->filenames[i], matchbuf, sizeof( matchbuf ));
Con_Printf( "%16s\n", matchbuf );
numitems++;
}
@ -901,7 +901,7 @@ qboolean Cmd_CheckMapsList_R( qboolean fRefresh, qboolean onlyingamedir )
continue;
f = FS_Open( t->filenames[i], "rb", onlyingamedir );
COM_FileBase( t->filenames[i], mapname );
COM_FileBase( t->filenames[i], mapname, sizeof( mapname ));
if( f )
{

View File

@ -193,8 +193,10 @@ static void Sys_StackTrace( PEXCEPTION_POINTERS pInfo )
static void Sys_GetProcessName( char *processName, size_t bufferSize )
{
GetModuleBaseName( GetCurrentProcess(), NULL, processName, bufferSize - 1 );
COM_FileBase( processName, processName );
char fullpath[MAX_PATH];
GetModuleBaseName( GetCurrentProcess(), NULL, fullpath, sizeof( fullpath ) - 1 );
COM_FileBase( fullpath, processName, bufferSize );
}
static void Sys_GetMinidumpFileName( const char *processName, char *mdmpFileName, size_t bufferSize )

View File

@ -509,7 +509,7 @@ qboolean Host_RegisterDecal( const char *name, int *count )
if( !COM_CheckString( name ))
return 0;
COM_FileBase( name, shortname );
COM_FileBase( name, shortname, sizeof( shortname ));
for( i = 1; i < MAX_DECALS && host.draw_decals[i][0]; i++ )
{

View File

@ -938,7 +938,7 @@ void HPAK_List_f( void )
for( nCurrent = 0; nCurrent < directory.count; nCurrent++ )
{
entry = &directory.entries[nCurrent];
COM_FileBase( entry->resource.szFileName, lumpname );
COM_FileBase( entry->resource.szFileName, lumpname, sizeof( lumpname ));
type = HPAK_TypeFromIndex( entry->resource.type );
size = Q_memprint( entry->resource.nDownloadSize );
@ -1033,7 +1033,7 @@ void HPAK_Extract_f( void )
if( nIndex != -1 && nIndex != nCurrent )
continue;
COM_FileBase( entry->resource.szFileName, lumpname );
COM_FileBase( entry->resource.szFileName, lumpname, sizeof( lumpname ) );
type = HPAK_TypeFromIndex( entry->resource.type );
size = Q_memprint( entry->resource.nDownloadSize );

View File

@ -1483,7 +1483,7 @@ static qboolean Mod_LoadColoredLighting( dbspmodel_t *bmod )
fs_offset_t litdatasize;
byte *in;
COM_FileBase( loadmodel->name, modelname );
COM_FileBase( loadmodel->name, modelname, sizeof( modelname ));
Q_snprintf( path, sizeof( path ), "maps/%s.lit", modelname );
// make sure what deluxemap is actual
@ -1538,7 +1538,7 @@ static void Mod_LoadDeluxemap( dbspmodel_t *bmod )
if( !FBitSet( host.features, ENGINE_LOAD_DELUXEDATA ))
return;
COM_FileBase( loadmodel->name, modelname );
COM_FileBase( loadmodel->name, modelname, sizeof( modelname ));
Q_snprintf( path, sizeof( path ), "maps/%s.dlit", modelname );
// make sure what deluxemap is actual
@ -1833,7 +1833,7 @@ static void Mod_LoadEntities( dbspmodel_t *bmod )
for( pszWadFile = strtok( wadstring, ";" ); pszWadFile != NULL; pszWadFile = strtok( NULL, ";" ))
{
COM_FixSlashes( pszWadFile );
COM_FileBase( pszWadFile, token );
COM_FileBase( pszWadFile, token, sizeof( token ));
// make sure what wad is really exist
if( FS_FileExists( va( "%s.wad", token ), false ))

View File

@ -429,7 +429,7 @@ void *R_StudioGetAnim( studiohdr_t *m_pStudioHeader, model_t *m_pSubModel, mstud
{
string filepath, modelname, modelpath;
COM_FileBase( m_pSubModel->name, modelname );
COM_FileBase( m_pSubModel->name, modelname, sizeof( modelname ));
COM_ExtractFilePath( m_pSubModel->name, modelpath );
// NOTE: here we build real sub-animation filename because stupid user may rename model without recompile

View File

@ -337,12 +337,12 @@ void SV_NextMap_f( void )
if( Q_stricmp( ext, "bsp" ))
continue;
COM_FileBase( t->filenames[i], nextmap );
COM_FileBase( t->filenames[i], nextmap, sizeof( nextmap ));
if( Q_stricmp( sv_hostmap->string, nextmap ))
continue;
next = ( i + 1 ) % t->numfilenames;
COM_FileBase( t->filenames[next], nextmap );
COM_FileBase( t->filenames[next], nextmap, sizeof( nextmap ));
Cvar_DirectSet( sv_hostmap, nextmap );
// found current point, check for valid

View File

@ -973,7 +973,7 @@ qboolean SV_SpawnServer( const char *mapname, const char *startspot, qboolean ba
if( svs.maxclients == 1 ) Cvar_SetValue( "sv_clienttrace", 1 );
// make sure what server name doesn't contain path and extension
COM_FileBase( mapname, sv.name );
COM_FileBase( mapname, sv.name, sizeof( sv.name ));
// precache and static commands can be issued during map initialization
Host_SetServerState( ss_loading );