From 9eaa7b83998dfa9fff81b06de2b7dc97ae4c40a4 Mon Sep 17 00:00:00 2001 From: kervala Date: Sat, 23 Jan 2016 19:04:52 +0100 Subject: [PATCH] Changed: Use CCmdArgs to get program path and search data there --- code/ryzom/client/src/init.cpp | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/code/ryzom/client/src/init.cpp b/code/ryzom/client/src/init.cpp index 4f9f2aa09..94376cd3f 100644 --- a/code/ryzom/client/src/init.cpp +++ b/code/ryzom/client/src/init.cpp @@ -34,6 +34,7 @@ #include "nel/misc/system_info.h" #include "nel/misc/block_memory.h" #include "nel/misc/system_utils.h" +#include "nel/misc/cmd_args.h" // 3D Interface. #include "nel/3d/bloom_effect.h" #include "nel/3d/u_driver.h" @@ -616,6 +617,9 @@ void initStereoDisplayDevice() IStereoDisplay::releaseUnusedLibraries(); } +// we want to get executable directory +extern NLMISC::CCmdArgs Args; + static void addPaths(IProgressCallback &progress, const std::vector &paths, bool recurse) { // all prefixes for paths @@ -625,19 +629,19 @@ static void addPaths(IProgressCallback &progress, const std::vector directoryPrefixes.push_back(""); #if defined(NL_OS_WINDOWS) - char path[MAX_PATH]; - GetModuleFileNameA(GetModuleHandleA(NULL), path, MAX_PATH); - // check in same directory as executable - directoryPrefixes.push_back(CPath::standardizePath(CFile::getPath(path))); + directoryPrefixes.push_back(Args.getProgramPath()); #elif defined(NL_OS_MAC) // check in bundle (Installer) - directoryPrefixes.push_back(CPath::standardizePath(getAppBundlePath() + "/Contents/Resources")); + directoryPrefixes.push_back(getAppBundlePath() + "/Contents/Resources/"); // check in same directory as bundle (Steam) - directoryPrefixes.push_back(CPath::standardizePath(getAppBundlePath() + "/..")); + directoryPrefixes.push_back(CPath::makePathAbsolute(getAppBundlePath() + "/..", ".", true)); #elif defined(NL_OS_UNIX) - // TODO: check in same directory as executable + // check in same directory as executable + directoryPrefixes.push_back(Args.getProgramPath()); + + // check in installed directory if (CFile::isDirectory(getRyzomSharePrefix())) directoryPrefixes.push_back(CPath::standardizePath(getRyzomSharePrefix())); #endif