mirror of
https://github.com/loot/libloot.git
synced 2026-07-27 14:16:01 -07:00
Don't load plugins twice when sorting
The API loads the plugins it's given to sort.
This commit is contained in:
@@ -44,10 +44,6 @@ public:
|
||||
std::string executeLogic() {
|
||||
BOOST_LOG_TRIVIAL(info) << "Beginning sorting operation.";
|
||||
|
||||
// Always reload all the plugins.
|
||||
sendProgressUpdate(frame_, boost::locale::translate("Loading plugin contents..."));
|
||||
state_.getCurrentGame().LoadAllInstalledPlugins(false);
|
||||
|
||||
//Sort plugins into their load order.
|
||||
sendProgressUpdate(frame_, boost::locale::translate("Sorting load order..."));
|
||||
std::vector<std::string> plugins = state_.getCurrentGame().SortPlugins();
|
||||
|
||||
+18
-18
@@ -204,19 +204,7 @@ void Game::RedatePlugins() {
|
||||
}
|
||||
|
||||
void Game::LoadAllInstalledPlugins(bool headersOnly) {
|
||||
std::vector<std::string> plugins;
|
||||
|
||||
BOOST_LOG_TRIVIAL(trace) << "Scanning for plugins in " << this->DataPath();
|
||||
for (fs::directory_iterator it(this->DataPath()); it != fs::directory_iterator(); ++it) {
|
||||
if (fs::is_regular_file(it->status()) && gameHandle_->IsValidPlugin(it->path().filename().string())) {
|
||||
string name = it->path().filename().string();
|
||||
BOOST_LOG_TRIVIAL(info) << "Found plugin: " << name;
|
||||
|
||||
plugins.push_back(name);
|
||||
}
|
||||
}
|
||||
|
||||
gameHandle_->LoadPlugins(plugins, headersOnly);
|
||||
gameHandle_->LoadPlugins(GetInstalledPluginNames(), headersOnly);
|
||||
|
||||
pluginsFullyLoaded_ = !headersOnly;
|
||||
}
|
||||
@@ -277,12 +265,8 @@ short Game::GetActiveLoadOrderIndex(const std::string& pluginName, const std::ve
|
||||
}
|
||||
|
||||
std::vector<std::string> Game::SortPlugins() {
|
||||
std::vector<std::string> plugins;
|
||||
std::vector<std::string> plugins = GetInstalledPluginNames();
|
||||
try {
|
||||
for (const auto& plugin : gameHandle_->GetLoadedPlugins()) {
|
||||
plugins.push_back(plugin->GetName());
|
||||
}
|
||||
|
||||
// Clear any existing game-specific messages, as these only relate to
|
||||
// state that has been changed by sorting.
|
||||
ClearMessages();
|
||||
@@ -465,6 +449,22 @@ void Game::BackupLoadOrder(const std::vector<std::string>& loadOrder,
|
||||
out << plugin << std::endl;
|
||||
}
|
||||
|
||||
std::vector<std::string> Game::GetInstalledPluginNames() {
|
||||
std::vector<std::string> plugins;
|
||||
|
||||
BOOST_LOG_TRIVIAL(trace) << "Scanning for plugins in " << this->DataPath();
|
||||
for (fs::directory_iterator it(this->DataPath()); it != fs::directory_iterator(); ++it) {
|
||||
if (fs::is_regular_file(it->status()) && gameHandle_->IsValidPlugin(it->path().filename().string())) {
|
||||
string name = it->path().filename().string();
|
||||
BOOST_LOG_TRIVIAL(info) << "Found plugin: " << name;
|
||||
|
||||
plugins.push_back(name);
|
||||
}
|
||||
}
|
||||
|
||||
return plugins;
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
std::string Game::RegKeyStringValue(const std::string& keyStr, const std::string& subkey, const std::string& value) {
|
||||
HKEY hKey = NULL;
|
||||
|
||||
@@ -97,6 +97,7 @@ private:
|
||||
static boost::filesystem::path DetectGamePath(const GameSettings& gameSettings);
|
||||
static void BackupLoadOrder(const std::vector<std::string>& loadOrder,
|
||||
const boost::filesystem::path& backupDirectory);
|
||||
std::vector<std::string> GetInstalledPluginNames();
|
||||
|
||||
boost::filesystem::path lootDataPath_;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user