From c73fa3d7a63b95bbfae01c358d6171c82100d3d7 Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Fri, 28 Jun 2024 18:00:36 +0300 Subject: [PATCH] filesystem: fix mounting wads again Because of the mounting order, VFS fails to automatically find unpacked WADs --- filesystem/filesystem.c | 2 +- filesystem/filesystem.h | 1 + filesystem/wad.c | 15 +++++++++++---- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/filesystem/filesystem.c b/filesystem/filesystem.c index 2a6f4e65..964008f3 100644 --- a/filesystem/filesystem.c +++ b/filesystem/filesystem.c @@ -333,7 +333,7 @@ searchpath_t *FS_AddArchive_Fullpath( const fs_archive_t *archive, const char *f char fullpath[MAX_SYSPATH]; Q_snprintf( fullpath, sizeof( fullpath ), "%s/%s", file, list.strings[i] ); - if(( wad = FS_AddWad_Fullpath( fullpath, flags ))) + if(( wad = FS_AddWad_Fullpath( fullpath, flags | FS_LOAD_PACKED_WAD ))) { wad->next = fs_searchpaths; fs_searchpaths = wad; diff --git a/filesystem/filesystem.h b/filesystem/filesystem.h index 8f001252..c3c9206f 100644 --- a/filesystem/filesystem.h +++ b/filesystem/filesystem.h @@ -45,6 +45,7 @@ enum FS_GAMERODIR_PATH = BIT( 4 ), // gamedir but read-only FS_SKIP_ARCHIVED_WADS = BIT( 5 ), // don't mount wads inside archives automatically + FS_LOAD_PACKED_WAD = BIT( 6 ), // this wad is packed inside other archive FS_GAMEDIRONLY_SEARCH_FLAGS = FS_GAMEDIR_PATH | FS_CUSTOM_PATH | FS_GAMERODIR_PATH }; diff --git a/filesystem/wad.c b/filesystem/wad.c index 14f25dc4..8ca55d8b 100644 --- a/filesystem/wad.c +++ b/filesystem/wad.c @@ -286,16 +286,23 @@ W_Open open the wad for reading & writing =========== */ -static wfile_t *W_Open( const char *filename, int *error ) +static wfile_t *W_Open( const char *filename, int *error, uint flags ) { wfile_t *wad = (wfile_t *)Mem_Calloc( fs_mempool, sizeof( wfile_t )); int i, lumpcount; dlumpinfo_t *srclumps; size_t lat_size; dwadinfo_t header; - const char *basename = COM_FileWithoutPath( filename ); - wad->handle = FS_Open( basename, "rb", false ); + if( FBitSet( flags, FS_LOAD_PACKED_WAD )) + { + const char *basename = COM_FileWithoutPath( filename ); + wad->handle = FS_Open( basename, "rb", false ); + } + else + { + wad->handle = FS_SysOpen( filename, "rb" ); + } if( wad->handle == NULL ) { @@ -629,7 +636,7 @@ searchpath_t *FS_AddWad_Fullpath( const char *wadfile, int flags ) wfile_t *wad; int errorcode = WAD_LOAD_COULDNT_OPEN; - wad = W_Open( wadfile, &errorcode ); + wad = W_Open( wadfile, &errorcode, flags ); if( !wad ) {