* sort pk3s, so content of later (zzz) overrides earlier, like in radiant and engine

* fix strong performance penalty with large amount of files in pk3s
store pak file path once per pk3, not per each file inside
This commit is contained in:
Garux
2021-08-13 03:20:07 +03:00
parent 4beae3d362
commit bb1931b745
3 changed files with 90 additions and 103 deletions

View File

@@ -92,7 +92,7 @@ static char g_strDirs[VFS_MAXDIRS][PATH_MAX + 1];
static int g_numDirs;
static char g_strForbiddenDirs[VFS_MAXDIRS][PATH_MAX + 1];
static int g_numForbiddenDirs = 0;
static bool g_bUsePak = true;
static constexpr bool g_bUsePak = true;
ModuleObservers g_observers;
@@ -228,37 +228,6 @@ static GSList* GetListInternal( const char *refdir, const char *ext, bool direct
return files;
}
inline int ascii_to_upper( int c ){
if ( c >= 'a' && c <= 'z' ) {
return c - ( 'a' - 'A' );
}
return c;
}
/*!
This behaves identically to stricmp(a,b), except that ASCII chars
[\]^`_ come AFTER alphabet chars instead of before. This is because
it converts all alphabet chars to uppercase before comparison,
while stricmp converts them to lowercase.
*/
static int string_compare_nocase_upper( const char* a, const char* b ){
for (;; )
{
int c1 = ascii_to_upper( *a++ );
int c2 = ascii_to_upper( *b++ );
if ( c1 < c2 ) {
return -1; // a < b
}
if ( c1 > c2 ) {
return 1; // a > b
}
if ( c1 == 0 ) {
return 0; // a == b
}
}
}
// Arnout: note - sort pakfiles in reverse order. This ensures that
// later pakfiles override earlier ones. This because the vfs module
// returns a filehandle to the first file it can find (while it should