From aa7c964fab16b095465905952bca32d8cbc3f0b9 Mon Sep 17 00:00:00 2001 From: Sven Eberhardt Date: Tue, 11 Jul 2017 20:43:21 -0700 Subject: [PATCH] Ignore main exe path for group loading when loading data from planet/ subfolder This fixes a slowdown in scenario selection when some of the dependency folders (e.g. qt) are searched for scenarios. Should also fix a bug where music is loaded from the exe path instead of planet/ if present --- src/config/C4Reloc.cpp | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/src/config/C4Reloc.cpp b/src/config/C4Reloc.cpp index 9e18a4c99..9e68c9442 100644 --- a/src/config/C4Reloc.cpp +++ b/src/config/C4Reloc.cpp @@ -35,10 +35,24 @@ void C4Reloc::Init() StdCopyStrBuf planet(Config.General.ExePath); planet.AppendBackslash(); planet.Append("planet"); - AddPath(planet.getData()); + if (DirectoryExists(planet.getData())) + { + // Only add planet if it's a valid contents folder. + // Because users may create a folder "planet" in their source repos. + StdCopyStrBuf planet_system_check(planet); + planet_system_check.AppendBackslash(); + planet_system_check.Append(C4CFN_System); + if (ItemExists(planet_system_check.getData())) + { + AddPath(planet.getData()); + } + } #endif - // Add main system path - AddPath(Config.General.SystemDataPath); + // Add main system path (unless it's using planet/ anyway, in which we would just slow down scenario enumeration by looking throug hthe whole source folder) + if (!Paths.size()) + { + AddPath(Config.General.SystemDataPath); + } // Add user path for additional data (player files, user scenarios, etc.) AddPath(Config.General.UserDataPath, PATH_PreferredInstallationLocation); }