Changed: Try different alternative paths for game folders

--HG--
branch : develop
hg/feature/material-editor
kervala 9 years ago
parent 6a3292c600
commit a4dd37efc9

@ -616,108 +616,90 @@ void initStereoDisplayDevice()
IStereoDisplay::releaseUnusedLibraries(); IStereoDisplay::releaseUnusedLibraries();
} }
void addSearchPaths(IProgressCallback &progress) static void addPaths(IProgressCallback &progress, const std::vector<std::string> &paths, bool recurse)
{ {
// Add search path of UI addon. Allow only a subset of files. // all prefixes for paths
// Must do it first because take precedence other standard files std::vector<std::string> directoryPrefixes;
InterfaceAddOnManager.addSearchFiles("uiaddon", "*.xml;*.lua;*.tga", "login_*.xml;out_v2_*.xml", &progress);
// Add Standard search paths // current directory has priority everywhere
{ directoryPrefixes.push_back("");
H_AUTO(InitRZAddSearchPath2)
for (uint i = 0; i < ClientCfg.DataPath.size(); i++)
{
progress.progress ((float)i/(float)ClientCfg.DataPath.size());
progress.pushCropedValues ((float)i/(float)ClientCfg.DataPath.size(), (float)(i+1)/(float)ClientCfg.DataPath.size());
CPath::addSearchPath(ClientCfg.DataPath[i], true, false, &progress); #if defined(NL_OS_WINDOWS)
char path[MAX_PATH];
GetModuleFileNameA(GetModuleHandleA(NULL), path, MAX_PATH);
progress.popCropedValues (); // check in same directory as executable
} directoryPrefixes.push_back(CPath::standardizePath(CFile::getPath(path)));
#elif defined(NL_OS_MAC)
// check in bundle (Installer)
directoryPrefixes.push_back(CPath::standardizePath(getAppBundlePath() + "/Contents/Resources"));
CPath::loadRemappedFiles("remap_files.csv"); // check in same directory as bundle (Steam)
} directoryPrefixes.push_back(CPath::standardizePath(getAppBundlePath());
#elif defined(NL_OS_UNIX)
if (CFile::isDirectory(getRyzomSharePrefix())) directoryPrefixes.push_back(CPath::standardizePath(getRyzomSharePrefix()));
#endif
for (uint i = 0; i < ClientCfg.DataPathNoRecurse.size(); i++) float total = (float)(directoryPrefixes.size() * paths.size());
float current = 0.f, next = 0.f;
for (uint j = 0; j < directoryPrefixes.size(); j++)
{ {
progress.progress ((float)i/(float)ClientCfg.DataPathNoRecurse.size()); std::string directoryPrefix = directoryPrefixes[j];
progress.pushCropedValues ((float)i/(float)ClientCfg.DataPathNoRecurse.size(), (float)(i+1)/(float)ClientCfg.DataPathNoRecurse.size());
CPath::addSearchPath(ClientCfg.DataPathNoRecurse[i], false, false, &progress); for (uint i = 0; i < paths.size(); i++)
{
std::string directory = NLMISC::expandEnvironmentVariables(paths[i]);
progress.popCropedValues (); // only prepend default directory if path is relative
} if (!directory.empty() && !directoryPrefix.empty() && !CPath::isAbsolutePath(directory))
{
directory = directoryPrefix + directory;
}
std::string defaultDirectory; // update next progress value
next += 1.f;
#ifdef NL_OS_MAC progress.progress (current/total);
defaultDirectory = CPath::standardizePath(getAppBundlePath() + "/Contents/Resources"); progress.pushCropedValues (current/total, next/total);
#elif defined(NL_OS_UNIX)
if (CFile::isDirectory(getRyzomSharePrefix())) defaultDirectory = CPath::standardizePath(getRyzomSharePrefix());
#endif
// add in last position, a specific possibly read only directory // next is current value
if (!defaultDirectory.empty()) current = next;
{
for (uint i = 0; i < ClientCfg.DataPath.size(); i++)
{
// don't prepend default directory if path is absolute
if (!ClientCfg.DataPath[i].empty() && ClientCfg.DataPath[i][0] != '/')
{
progress.progress ((float)i/(float)ClientCfg.DataPath.size());
progress.pushCropedValues ((float)i/(float)ClientCfg.DataPath.size(), (float)(i+1)/(float)ClientCfg.DataPath.size());
CPath::addSearchPath(defaultDirectory + ClientCfg.DataPath[i], true, false, &progress); CPath::addSearchPath(directory, recurse, false, &progress);
progress.popCropedValues (); progress.popCropedValues ();
}
} }
} }
} }
void addPreDataPaths(NLMISC::IProgressCallback &progress) void addSearchPaths(IProgressCallback &progress)
{ {
NLMISC::TTime initPaths = ryzomGetLocalTime (); // Add search path of UI addon. Allow only a subset of files.
// Must do it first because take precedence other standard files
H_AUTO(InitRZAddSearchPaths); InterfaceAddOnManager.addSearchFiles("uiaddon", "*.xml;*.lua;*.tga", "login_*.xml;out_v2_*.xml", &progress);
for (uint i = 0; i < ClientCfg.PreDataPath.size(); i++) // Add Standard search paths
{ {
progress.progress ((float)i/(float)ClientCfg.PreDataPath.size()); H_AUTO(InitRZAddSearchPath2)
progress.pushCropedValues ((float)i/(float)ClientCfg.PreDataPath.size(), (float)(i+1)/(float)ClientCfg.PreDataPath.size());
CPath::addSearchPath(ClientCfg.PreDataPath[i], true, false, &progress); addPaths(progress, ClientCfg.DataPath, true);
progress.popCropedValues (); CPath::loadRemappedFiles("remap_files.csv");
} }
//nlinfo ("PROFILE: %d seconds for Add search paths Predata", (uint32)(ryzomGetLocalTime ()-initPaths)/1000); addPaths(progress, ClientCfg.DataPathNoRecurse, false);
}
std::string defaultDirectory;
#ifdef NL_OS_MAC void addPreDataPaths(NLMISC::IProgressCallback &progress)
defaultDirectory = CPath::standardizePath(getAppBundlePath() + "/Contents/Resources"); {
#elif defined(NL_OS_UNIX) NLMISC::TTime initPaths = ryzomGetLocalTime ();
if (CFile::isDirectory(getRyzomSharePrefix())) defaultDirectory = CPath::standardizePath(getRyzomSharePrefix());
#endif
// add in last position, a specific possibly read only directory H_AUTO(InitRZAddSearchPaths);
if (!defaultDirectory.empty())
{
for (uint i = 0; i < ClientCfg.PreDataPath.size(); i++)
{
// don't prepend default directory if path is absolute
if (!ClientCfg.PreDataPath[i].empty() && ClientCfg.PreDataPath[i][0] != '/')
{
progress.progress ((float)i/(float)ClientCfg.PreDataPath.size());
progress.pushCropedValues ((float)i/(float)ClientCfg.PreDataPath.size(), (float)(i+1)/(float)ClientCfg.PreDataPath.size());
CPath::addSearchPath(defaultDirectory + ClientCfg.PreDataPath[i], true, false, &progress); addPaths(progress, ClientCfg.PreDataPath, true);
progress.popCropedValues (); //nlinfo ("PROFILE: %d seconds for Add search paths Predata", (uint32)(ryzomGetLocalTime ()-initPaths)/1000);
}
}
}
} }
static void addPackedSheetUpdatePaths(NLMISC::IProgressCallback &progress) static void addPackedSheetUpdatePaths(NLMISC::IProgressCallback &progress)
@ -726,7 +708,7 @@ static void addPackedSheetUpdatePaths(NLMISC::IProgressCallback &progress)
{ {
progress.progress((float)i/(float)ClientCfg.UpdatePackedSheetPath.size()); progress.progress((float)i/(float)ClientCfg.UpdatePackedSheetPath.size());
progress.pushCropedValues ((float)i/(float)ClientCfg.UpdatePackedSheetPath.size(), (float)(i+1)/(float)ClientCfg.UpdatePackedSheetPath.size()); progress.pushCropedValues ((float)i/(float)ClientCfg.UpdatePackedSheetPath.size(), (float)(i+1)/(float)ClientCfg.UpdatePackedSheetPath.size());
CPath::addSearchPath(ClientCfg.UpdatePackedSheetPath[i], true, false, &progress); CPath::addSearchPath(NLMISC::expandEnvironmentVariables(ClientCfg.UpdatePackedSheetPath[i]), true, false, &progress);
progress.popCropedValues(); progress.popCropedValues();
} }
} }

Loading…
Cancel
Save