From 1e8c26a527f8f8397d0ba3a665787bd7b9c3e5d6 Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Mon, 13 Feb 2023 06:49:29 +0300 Subject: [PATCH] filesystem: wad: fix loading WADs by absolute paths --- filesystem/wad.c | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/filesystem/wad.c b/filesystem/wad.c index 16153429..a456e49f 100644 --- a/filesystem/wad.c +++ b/filesystem/wad.c @@ -287,17 +287,33 @@ open the wad for reading & writing static wfile_t *W_Open( const char *filename, int *error ) { wfile_t *wad = (wfile_t *)Mem_Calloc( fs_mempool, sizeof( wfile_t )); - const char *basename; int i, lumpcount; dlumpinfo_t *srclumps; size_t lat_size; dwadinfo_t header; // NOTE: FS_Open is load wad file from the first pak in the list (while fs_ext_path is false) - if( fs_ext_path ) basename = filename; - else basename = COM_FileWithoutPath( filename ); + if( fs_ext_path ) + { + int ind; + searchpath_t *search = FS_FindFile( filename, &ind, NULL, 0, false ); - wad->handle = FS_Open( basename, "rb", false ); + // allow direct absolute paths + // TODO: catch them in FS_FindFile_DIR! + if( !search || ind < 0 ) + { + wad->handle = FS_SysOpen( filename, "rb" ); + } + else + { + wad->handle = search->pfnOpenFile( search, filename, "rb", ind ); + } + } + else + { + const char *basename = COM_FileWithoutPath( filename ); + wad->handle = FS_Open( basename, "rb", false ); + } if( wad->handle == NULL ) {