don't use intermediate array for sorting pakfiles. avoids the

MAX_PAKFILES limitation
This commit is contained in:
Ludwig Nussel 2006-12-30 12:19:53 +00:00
parent 1bc190caf1
commit c3a713832c

View file

@ -2483,7 +2483,6 @@ Sets fs_gamedir, adds the directory to the head of the path,
then loads the zip headers then loads the zip headers
================ ================
*/ */
#define MAX_PAKFILES 1024
static void FS_AddGameDirectory( const char *path, const char *dir ) { static void FS_AddGameDirectory( const char *path, const char *dir ) {
searchpath_t *sp; searchpath_t *sp;
int i; int i;
@ -2492,7 +2491,6 @@ static void FS_AddGameDirectory( const char *path, const char *dir ) {
char *pakfile; char *pakfile;
int numfiles; int numfiles;
char **pakfiles; char **pakfiles;
char *sorted[MAX_PAKFILES];
// this fixes the case where fs_basepath is the same as fs_cdpath // this fixes the case where fs_basepath is the same as fs_cdpath
// which happens on full installs // which happens on full installs
@ -2521,20 +2519,11 @@ static void FS_AddGameDirectory( const char *path, const char *dir ) {
pakfiles = Sys_ListFiles( pakfile, ".pk3", NULL, &numfiles, qfalse ); pakfiles = Sys_ListFiles( pakfile, ".pk3", NULL, &numfiles, qfalse );
// sort them so that later alphabetic matches override qsort( pakfiles, numfiles, sizeof(char*), paksort );
// earlier ones. This makes pak1.pk3 override pak0.pk3
if ( numfiles > MAX_PAKFILES ) {
numfiles = MAX_PAKFILES;
}
for ( i = 0 ; i < numfiles ; i++ ) {
sorted[i] = pakfiles[i];
}
qsort( sorted, numfiles, sizeof(char*), paksort );
for ( i = 0 ; i < numfiles ; i++ ) { for ( i = 0 ; i < numfiles ; i++ ) {
pakfile = FS_BuildOSPath( path, dir, sorted[i] ); pakfile = FS_BuildOSPath( path, dir, pakfiles[i] );
if ( ( pak = FS_LoadZipFile( pakfile, sorted[i] ) ) == 0 ) if ( ( pak = FS_LoadZipFile( pakfile, pakfiles[i] ) ) == 0 )
continue; continue;
// store the game name for downloading // store the game name for downloading
strcpy(pak->pakGamename, dir); strcpy(pak->pakGamename, dir);