From: Thomas Debesse Date: Fri, 22 May 2020 08:34:43 +0000 (+0200) Subject: radiant/vfs: do not load enginepath twice X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=4d309f54ecfa248000f5a6fe88d0b7713bde4715;p=xonotic%2Fnetradiant.git radiant/vfs: do not load enginepath twice Do not load engine path twice when the home path and the engine path is the same, This happens when a game does not have home path. Also rework a bit that code, and prints useful information on console. --- diff --git a/radiant/qe3.cpp b/radiant/qe3.cpp index bc1b6ed8..e5881bb0 100644 --- a/radiant/qe3.cpp +++ b/radiant/qe3.cpp @@ -79,44 +79,58 @@ void QE_InitVFS(){ // we need to call in order, the mod ones first, then the base ones .. they will be searched in this order // *nix systems have a dual filesystem in ~/.q3a, which is searched first .. so we need to add that too - const char* gamename = gamename_get(); + const char* enginepath = EnginePath_get(); + const char* homepath = g_qeglobals.m_userEnginePath.c_str(); // returns enginepath if not homepath is not set + const char* basegame = basegame_get(); - const char* userRoot = g_qeglobals.m_userEnginePath.c_str(); - const char* globalRoot = EnginePath_get(); + const char* gamename = gamename_get(); // returns basegame if gamename is not set // editor builtin VFS StringOutputStream editorGamePath( 256 ); editorGamePath << GlobalRadiant().getDataPath() << DEFAULT_EDITORVFS_DIRNAME; GlobalFileSystem().initDirectory( editorGamePath.c_str() ); + globalOutputStream() << "engine path: " << enginepath << "\n"; + globalOutputStream() << "home path: " << homepath << "\n"; + globalOutputStream() << "base game: " << basegame << "\n"; + globalOutputStream() << "game name: " << gamename << "\n"; + // if we have a mod dir if ( !string_equal( gamename, basegame ) ) { - // ~/./ - if ( userRoot && !g_disableHomePath ) { - StringOutputStream userGamePath( 256 ); - userGamePath << userRoot << gamename << '/'; - GlobalFileSystem().initDirectory( userGamePath.c_str() ); + // if we have a home dir + if ( !string_equal( homepath, enginepath ) ) + { + // ~/./ + if ( homepath && !g_disableHomePath ) { + StringOutputStream userGamePath( 256 ); + userGamePath << homepath << gamename << '/'; + GlobalFileSystem().initDirectory( userGamePath.c_str() ); + } } // / if ( !g_disableEnginePath ) { StringOutputStream globalGamePath( 256 ); - globalGamePath << globalRoot << gamename << '/'; + globalGamePath << enginepath << gamename << '/'; GlobalFileSystem().initDirectory( globalGamePath.c_str() ); } } - // ~/./ - if ( userRoot && !g_disableHomePath ) { - StringOutputStream userBasePath( 256 ); - userBasePath << userRoot << basegame << '/'; - GlobalFileSystem().initDirectory( userBasePath.c_str() ); + // if we have a home dir + if ( !string_equal( homepath, enginepath ) ) + { + // ~/./ + if ( homepath && !g_disableHomePath ) { + StringOutputStream userBasePath( 256 ); + userBasePath << homepath << basegame << '/'; + GlobalFileSystem().initDirectory( userBasePath.c_str() ); + } } // / if ( !g_disableEnginePath ) { StringOutputStream globalBasePath( 256 ); - globalBasePath << globalRoot << basegame << '/'; + globalBasePath << enginepath << basegame << '/'; GlobalFileSystem().initDirectory( globalBasePath.c_str() ); }