Browse Source

engine: add size argument to COM_Default/ReplaceExtension calls

pull/2/head
Alibek Omarov 2 years ago
parent
commit
ec2951cf45
  1. 2
      engine/client/avi/avi_win.c
  2. 2
      engine/client/cl_gameui.c
  3. 6
      engine/common/con_utils.c
  4. 2
      engine/common/host.c
  5. 26
      engine/common/hpak.c
  6. 2
      engine/common/mod_bmodel.c
  7. 4
      engine/common/net_chan.c
  8. 5
      engine/platform/sdl/vid_sdl.c
  9. 2
      engine/server/sv_init.c

2
engine/client/avi/avi_win.c

@ -658,7 +658,7 @@ movie_state_t *AVI_LoadVideo( const char *filename, qboolean load_audio )
// open cinematic // open cinematic
Q_snprintf( path, sizeof( path ), "media/%s", filename ); Q_snprintf( path, sizeof( path ), "media/%s", filename );
COM_DefaultExtension( path, ".avi" ); COM_DefaultExtension( path, ".avi", sizeof( path ));
fullpath = FS_GetDiskPath( path, false ); fullpath = FS_GetDiskPath( path, false );
if( FS_FileExists( path, false ) && !fullpath ) if( FS_FileExists( path, false ) && !fullpath )

2
engine/client/cl_gameui.c

@ -309,7 +309,7 @@ static void GAME_EXPORT UI_DrawLogo( const char *filename, float x, float y, flo
// run cinematic if not // run cinematic if not
Q_snprintf( path, sizeof( path ), "media/%s", filename ); Q_snprintf( path, sizeof( path ), "media/%s", filename );
COM_DefaultExtension( path, ".avi" ); COM_DefaultExtension( path, ".avi", sizeof( path ));
fullpath = FS_GetDiskPath( path, false ); fullpath = FS_GetDiskPath( path, false );
if( FS_FileExists( path, false ) && !fullpath ) if( FS_FileExists( path, false ) && !fullpath )

6
engine/common/con_utils.c

@ -101,8 +101,7 @@ int Cmd_ListMaps( search_t *t, char *lastmapname, size_t len )
if( hdrext->id == IDEXTRAHEADER ) version = hdrext->version; if( hdrext->id == IDEXTRAHEADER ) version = hdrext->version;
Q_strncpy( entfilename, t->filenames[i], sizeof( entfilename )); Q_strncpy( entfilename, t->filenames[i], sizeof( entfilename ));
COM_StripExtension( entfilename ); COM_ReplaceExtension( entfilename, ".ent", sizeof( entfilename ));
COM_DefaultExtension( entfilename, ".ent" );
ents = (char *)FS_LoadFile( entfilename, NULL, true ); ents = (char *)FS_LoadFile( entfilename, NULL, true );
if( !ents && lumplen >= 10 ) if( !ents && lumplen >= 10 )
@ -925,8 +924,7 @@ qboolean Cmd_CheckMapsList_R( qboolean fRefresh, qboolean onlyingamedir )
lumplen = entities.filelen; lumplen = entities.filelen;
Q_strncpy( entfilename, t->filenames[i], sizeof( entfilename )); Q_strncpy( entfilename, t->filenames[i], sizeof( entfilename ));
COM_StripExtension( entfilename ); COM_ReplaceExtension( entfilename, ".ent", sizeof( entfilename ));
COM_DefaultExtension( entfilename, ".ent" );
ents = (char *)FS_LoadFile( entfilename, NULL, true ); ents = (char *)FS_LoadFile( entfilename, NULL, true );
if( !ents && lumplen >= 10 ) if( !ents && lumplen >= 10 )

2
engine/common/host.c

@ -415,7 +415,7 @@ void Host_Exec_f( void )
} }
Q_strncpy( cfgpath, arg, sizeof( cfgpath )); Q_strncpy( cfgpath, arg, sizeof( cfgpath ));
COM_DefaultExtension( cfgpath, ".cfg" ); // append as default COM_DefaultExtension( cfgpath, ".cfg", sizeof( cfgpath )); // append as default
f = FS_LoadFile( cfgpath, &len, false ); f = FS_LoadFile( cfgpath, &len, false );
if( !f ) if( !f )

26
engine/common/hpak.c

@ -109,7 +109,7 @@ void HPAK_CreatePak( const char *filename, resource_t *pResource, byte *pData, f
return; return;
Q_strncpy( pakname, filename, sizeof( pakname )); Q_strncpy( pakname, filename, sizeof( pakname ));
COM_ReplaceExtension( pakname, ".hpk" ); COM_ReplaceExtension( pakname, ".hpk", sizeof( pakname ));
Con_Printf( "creating HPAK %s.\n", pakname ); Con_Printf( "creating HPAK %s.\n", pakname );
@ -257,7 +257,7 @@ void HPAK_AddLump( qboolean bUseQueue, const char *name, resource_t *pResource,
} }
Q_strncpy( srcname, name, sizeof( srcname )); Q_strncpy( srcname, name, sizeof( srcname ));
COM_ReplaceExtension( srcname, ".hpk" ); COM_ReplaceExtension( srcname, ".hpk", sizeof( srcname ));
file_src = FS_Open( srcname, "rb", true ); file_src = FS_Open( srcname, "rb", true );
@ -269,7 +269,7 @@ void HPAK_AddLump( qboolean bUseQueue, const char *name, resource_t *pResource,
} }
Q_strncpy( dstname, srcname, sizeof( dstname )); Q_strncpy( dstname, srcname, sizeof( dstname ));
COM_ReplaceExtension( dstname, ".hp2" ); COM_ReplaceExtension( dstname, ".hp2", sizeof( dstname ));
file_dst = FS_Open( dstname, "wb", true ); file_dst = FS_Open( dstname, "wb", true );
@ -395,7 +395,7 @@ static qboolean HPAK_Validate( const char *filename, qboolean quiet, qboolean de
return true; return true;
Q_strncpy( pakname, filename, sizeof( pakname )); Q_strncpy( pakname, filename, sizeof( pakname ));
COM_ReplaceExtension( pakname, ".hpk" ); COM_ReplaceExtension( pakname, ".hpk", sizeof( pakname ));
f = FS_Open( pakname, "rb", true ); f = FS_Open( pakname, "rb", true );
if( !f ) if( !f )
@ -497,7 +497,7 @@ void HPAK_CheckIntegrity( const char *filename )
return; return;
Q_strncpy( pakname, filename, sizeof( pakname )); Q_strncpy( pakname, filename, sizeof( pakname ));
COM_ReplaceExtension( pakname, ".hpk" ); COM_ReplaceExtension( pakname, ".hpk", sizeof( pakname ));
HPAK_Validate( pakname, true, true ); HPAK_Validate( pakname, true, true );
} }
@ -514,7 +514,7 @@ void HPAK_CheckSize( const char *filename )
return; return;
Q_strncpy( pakname, filename, sizeof( pakname )); Q_strncpy( pakname, filename, sizeof( pakname ));
COM_ReplaceExtension( pakname, ".hpk" ); COM_ReplaceExtension( pakname, ".hpk", sizeof( pakname ));
if( FS_FileSize( pakname, false ) > ( maxsize * 1048576 )) if( FS_FileSize( pakname, false ) > ( maxsize * 1048576 ))
{ {
@ -547,7 +547,7 @@ qboolean HPAK_ResourceForHash( const char *filename, byte *hash, resource_t *pRe
} }
Q_strncpy( pakname, filename, sizeof( pakname )); Q_strncpy( pakname, filename, sizeof( pakname ));
COM_ReplaceExtension( pakname, ".hpk" ); COM_ReplaceExtension( pakname, ".hpk", sizeof( pakname ));
f = FS_Open( pakname, "rb", true ); f = FS_Open( pakname, "rb", true );
if( !f ) return false; if( !f ) return false;
@ -595,7 +595,7 @@ static qboolean HPAK_ResourceForIndex( const char *filename, int index, resource
return false; return false;
Q_strncpy( pakname, filename, sizeof( pakname )); Q_strncpy( pakname, filename, sizeof( pakname ));
COM_ReplaceExtension( pakname, ".hpk" ); COM_ReplaceExtension( pakname, ".hpk", sizeof( pakname ));
f = FS_Open( pakname, "rb", true ); f = FS_Open( pakname, "rb", true );
if( !f ) if( !f )
@ -681,7 +681,7 @@ qboolean HPAK_GetDataPointer( const char *filename, resource_t *pResource, byte
} }
Q_strncpy( pakname, filename, sizeof( pakname )); Q_strncpy( pakname, filename, sizeof( pakname ));
COM_ReplaceExtension( pakname, ".hpk" ); COM_ReplaceExtension( pakname, ".hpk", sizeof( pakname ));
f = FS_Open( pakname, "rb", true ); f = FS_Open( pakname, "rb", true );
if( !f ) return false; if( !f ) return false;
@ -764,7 +764,7 @@ void HPAK_RemoveLump( const char *name, resource_t *pResource )
HPAK_FlushHostQueue(); HPAK_FlushHostQueue();
Q_strncpy( read_path, name, sizeof( read_path )); Q_strncpy( read_path, name, sizeof( read_path ));
COM_ReplaceExtension( read_path, ".hpk" ); COM_ReplaceExtension( read_path, ".hpk", sizeof( read_path ));
file_src = FS_Open( read_path, "rb", true ); file_src = FS_Open( read_path, "rb", true );
if( !file_src ) if( !file_src )
@ -774,7 +774,7 @@ void HPAK_RemoveLump( const char *name, resource_t *pResource )
} }
Q_strncpy( save_path, read_path, sizeof( save_path )); Q_strncpy( save_path, read_path, sizeof( save_path ));
COM_ReplaceExtension( save_path, ".hp2" ); COM_ReplaceExtension( save_path, ".hp2", sizeof( save_path ));
file_dst = FS_Open( save_path, "wb", true ); file_dst = FS_Open( save_path, "wb", true );
if( !file_dst ) if( !file_dst )
@ -893,7 +893,7 @@ void HPAK_List_f( void )
HPAK_FlushHostQueue(); HPAK_FlushHostQueue();
Q_strncpy( pakname, Cmd_Argv( 1 ), sizeof( pakname )); Q_strncpy( pakname, Cmd_Argv( 1 ), sizeof( pakname ));
COM_ReplaceExtension( pakname, ".hpk" ); COM_ReplaceExtension( pakname, ".hpk", sizeof( pakname ));
Con_Printf( "Contents for %s.\n", pakname ); Con_Printf( "Contents for %s.\n", pakname );
f = FS_Open( pakname, "rb", true ); f = FS_Open( pakname, "rb", true );
@ -984,7 +984,7 @@ void HPAK_Extract_f( void )
HPAK_FlushHostQueue(); HPAK_FlushHostQueue();
Q_strncpy( pakname, Cmd_Argv( 1 ), sizeof( pakname )); Q_strncpy( pakname, Cmd_Argv( 1 ), sizeof( pakname ));
COM_ReplaceExtension( pakname, ".hpk" ); COM_ReplaceExtension( pakname, ".hpk", sizeof( pakname ));
Con_Printf( "Contents for %s.\n", pakname ); Con_Printf( "Contents for %s.\n", pakname );
f = FS_Open( pakname, "rb", true ); f = FS_Open( pakname, "rb", true );

2
engine/common/mod_bmodel.c

@ -1764,7 +1764,7 @@ static void Mod_LoadEntities( dbspmodel_t *bmod )
// world is check for entfile too // world is check for entfile too
Q_strncpy( entfilename, loadmodel->name, sizeof( entfilename )); Q_strncpy( entfilename, loadmodel->name, sizeof( entfilename ));
COM_ReplaceExtension( entfilename, ".ent" ); COM_ReplaceExtension( entfilename, ".ent", sizeof( entfilename ));
// make sure what entity patch is never than bsp // make sure what entity patch is never than bsp
ft1 = FS_FileTime( loadmodel->name, false ); ft1 = FS_FileTime( loadmodel->name, false );

4
engine/common/net_chan.c

@ -973,7 +973,7 @@ int Netchan_CreateFileFragments( netchan_t *chan, const char *filename )
else chunksize = FRAGMENT_MAX_SIZE; // fallback else chunksize = FRAGMENT_MAX_SIZE; // fallback
Q_strncpy( compressedfilename, filename, sizeof( compressedfilename )); Q_strncpy( compressedfilename, filename, sizeof( compressedfilename ));
COM_ReplaceExtension( compressedfilename, ".ztmp" ); COM_ReplaceExtension( compressedfilename, ".ztmp", sizeof( compressedfilename ));
compressedFileTime = FS_FileTime( compressedfilename, false ); compressedFileTime = FS_FileTime( compressedfilename, false );
fileTime = FS_FileTime( filename, false ); fileTime = FS_FileTime( filename, false );
@ -1559,7 +1559,7 @@ void Netchan_TransmitBits( netchan_t *chan, int length, byte *data )
char compressedfilename[MAX_OSPATH]; char compressedfilename[MAX_OSPATH];
Q_strncpy( compressedfilename, pbuf->filename, sizeof( compressedfilename )); Q_strncpy( compressedfilename, pbuf->filename, sizeof( compressedfilename ));
COM_ReplaceExtension( compressedfilename, ".ztmp" ); COM_ReplaceExtension( compressedfilename, ".ztmp", sizeof( compressedfilename ));
file = FS_Open( compressedfilename, "rb", false ); file = FS_Open( compressedfilename, "rb", false );
} }
else file = FS_Open( pbuf->filename, "rb", false ); else file = FS_Open( pbuf->filename, "rb", false );

5
engine/platform/sdl/vid_sdl.c

@ -736,9 +736,8 @@ qboolean VID_CreateWindow( int width, int height, qboolean fullscreen )
if( !iconLoaded ) if( !iconLoaded )
{ {
Q_strcpy( iconpath, GI->iconpath ); Q_strncpy( iconpath, GI->iconpath, sizeof( iconpath ));
COM_StripExtension( iconpath ); COM_ReplaceExtension( iconpath, ".tga", sizeof( iconpath ));
COM_DefaultExtension( iconpath, ".tga" );
icon = FS_LoadImage( iconpath, NULL, 0 ); icon = FS_LoadImage( iconpath, NULL, 0 );

2
engine/server/sv_init.c

@ -340,7 +340,7 @@ void SV_CreateGenericResources( void )
string filename; string filename;
Q_strncpy( filename, sv.model_precache[1], sizeof( filename )); Q_strncpy( filename, sv.model_precache[1], sizeof( filename ));
COM_ReplaceExtension( filename, ".res" ); COM_ReplaceExtension( filename, ".res", sizeof( filename ));
COM_FixSlashes( filename ); COM_FixSlashes( filename );
SV_ReadResourceList( filename ); SV_ReadResourceList( filename );

Loading…
Cancel
Save