diff options
author | Andrey Nazarov <skuller@skuller.net> | 2007-12-01 19:26:11 +0000 |
---|---|---|
committer | Andrey Nazarov <skuller@skuller.net> | 2007-12-01 19:26:11 +0000 |
commit | 59182dc7d73461ed0da66cf903eba0af9c890f9e (patch) | |
tree | cda0699e31e8a4469d7ea6755057e936eb5620ed /source/files.c | |
parent | 686b16c6dbcfd80814595dc06b175c11e9ed6e03 (diff) |
Sort pakXX.pak in numeric order instead of
alphabetical order when building search path.
Diffstat (limited to 'source/files.c')
-rw-r--r-- | source/files.c | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/source/files.c b/source/files.c index 31e43f4..ff24498 100644 --- a/source/files.c +++ b/source/files.c @@ -1302,6 +1302,7 @@ static pack_t *FS_LoadPakFile( const char *packfile ) { } len = strlen( packfile ); + len = ( len + 3 ) & ~3; pack = FS_Malloc( sizeof( pack_t ) + numpackfiles * sizeof( packfile_t ) + hashSize * sizeof( packfile_t * ) + @@ -1460,17 +1461,28 @@ fail: #endif static int QDECL pakcmp( const void *p1, const void *p2 ) { - const char *s1 = *( const char ** )p1; - const char *s2 = *( const char ** )p2; + char *s1 = *( char ** )p1; + char *s2 = *( char ** )p2; if( !strncmp( s1, "pak", 3 ) ) { - if( strncmp( s2, "pak", 3 ) ) { - return -1; + if( !strncmp( s2, "pak", 3 ) ) { + int n1 = strtoul( s1 + 3, &s1, 10 ); + int n2 = strtoul( s2 + 3, &s2, 10 ); + if( n1 > n2 ) { + return 1; + } + if( n1 < n2 ) { + return -1; + } + goto alphacmp; } - } else if( !strncmp( s2, "pak", 3 ) ) { + return -1; + } + if( !strncmp( s2, "pak", 3 ) ) { return 1; } +alphacmp: return strcmp( s1, s2 ); } |