From 6ff3231daba5b75d6c35679b5b630860cba867a8 Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Tue, 9 Jul 2024 08:45:27 +0300 Subject: [PATCH] engine: change current working directory before initializing filesystem_stdio --- engine/common/filesystem_engine.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/engine/common/filesystem_engine.c b/engine/common/filesystem_engine.c index 2457b0cca..c1c99a307 100644 --- a/engine/common/filesystem_engine.c +++ b/engine/common/filesystem_engine.c @@ -224,16 +224,20 @@ void FS_Init( const char *basedir ) Q_strncpy( gamedir, basedir, sizeof( gamedir )); // gamedir == basedir FS_LoadProgs(); + + // TODO: this function will cause engine to stop in case of fail + // when it will have an option to return string error, restore Sys_Error + // FIXME: why do we call this function before InitStdio? + // because InitStdio immediately scans all available game directories + // and this better be reworked at some point + g_fsapi.SetCurrentDirectory( rootdir ); + if( !g_fsapi.InitStdio( true, rootdir, basedir, gamedir, rodir )) { Sys_Error( "Can't init filesystem_stdio!\n" ); return; } - // TODO: this function will cause engine to stop in case of fail - // when it will have an option to return string error, restore Sys_Error - g_fsapi.SetCurrentDirectory( rootdir ); - Cmd_AddRestrictedCommand( "fs_rescan", FS_Rescan_f, "rescan filesystem search pathes" ); Cmd_AddRestrictedCommand( "fs_path", FS_Path_f_, "show filesystem search pathes" ); Cmd_AddRestrictedCommand( "fs_clearpaths", FS_ClearPaths_f, "clear filesystem search pathes" );