From eb36fe01551599a89c3ef821205f5d1feb5ce6ea Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Sun, 4 Dec 2022 06:18:34 +0300 Subject: [PATCH] filesystem: fill searchpath DIR functions only if file was found in direct path --- filesystem/filesystem.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/filesystem/filesystem.c b/filesystem/filesystem.c index 557236a9..cea197a5 100644 --- a/filesystem/filesystem.c +++ b/filesystem/filesystem.c @@ -1802,7 +1802,6 @@ and the file index in the package if relevant searchpath_t *FS_FindFile( const char *name, int *index, qboolean gamedironly ) { searchpath_t *search; - char *pEnvPath; // search through the path, one element at a time for( search = fs_searchpaths; search; search = search->next ) @@ -1828,20 +1827,20 @@ searchpath_t *FS_FindFile( const char *name, int *index, qboolean gamedironly ) search = &fs_directpath; memset( search, 0, sizeof( searchpath_t )); - search->printinfo = FS_PrintInfo_DIR; - search->close = FS_Close_DIR; - search->openfile = FS_OpenFile_DIR; - search->filetime = FS_FileTime_DIR; - search->findfile = FS_FindFile_DIR; - search->search = FS_Search_DIR; - // root folder has a more priority than netpath Q_strncpy( search->filename, fs_rootdir, sizeof( search->filename )); Q_strcat( search->filename, PATH_SPLITTER ); - Q_snprintf( netpath, MAX_SYSPATH, "%s%s", search->filename, name ); + Q_snprintf( netpath, sizeof( netpath ), "%s%s", search->filename, name ); - if( FS_SysFileExists( netpath, !( search->flags & FS_CUSTOM_PATH ) )) + if( FS_SysFileExists( netpath, true )) { + search->printinfo = FS_PrintInfo_DIR; + search->close = FS_Close_DIR; + search->openfile = FS_OpenFile_DIR; + search->filetime = FS_FileTime_DIR; + search->findfile = FS_FindFile_DIR; + search->search = FS_Search_DIR; + if( index != NULL ) *index = -1; return search;