Browse Source

engine: add size argument to COM_FileBase calls

pull/2/head
Alibek Omarov 2 years ago
parent
commit
8c7db8499f
  1. 2
      engine/client/cl_parse.c
  2. 2
      engine/client/cl_remap.c
  3. 2
      engine/client/in_touch.c
  4. 34
      engine/common/con_utils.c
  5. 6
      engine/common/crashhandler.c
  6. 2
      engine/common/host.c
  7. 4
      engine/common/hpak.c
  8. 6
      engine/common/mod_bmodel.c
  9. 2
      engine/common/mod_studio.c
  10. 4
      engine/server/sv_cmds.c
  11. 2
      engine/server/sv_init.c

2
engine/client/cl_parse.c

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

2
engine/client/cl_remap.c

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

2
engine/client/in_touch.c

@ -340,7 +340,7 @@ static void Touch_ExportConfig_f( void )
if( Q_strstr( name, "touch_presets/" )) 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 ); Q_snprintf( profilename, sizeof( profilebase ), "touch_profiles/%s (copy).cfg", profilebase );
} }
else Q_strncpy( profilename, name, sizeof( profilename )); else Q_strncpy( profilename, name, sizeof( profilename ));

34
engine/common/con_utils.c

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

6
engine/common/crashhandler.c

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

2
engine/common/host.c

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

4
engine/common/hpak.c

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

6
engine/common/mod_bmodel.c

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

2
engine/common/mod_studio.c

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

4
engine/server/sv_cmds.c

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

2
engine/server/sv_init.c

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

Loading…
Cancel
Save