Replace Game::HasBeenLoaded()

With Game::ArePluginsFullyLoaded(), which is tracked more precisely, as
it doesn't depend on the game master containing non-TES4 records (which
may not be true for testing purposes).
This commit is contained in:
Oliver Hamlet
2015-07-12 18:37:27 +01:00
parent db63eb83b9
commit ed2c78ab9d
3 changed files with 11 additions and 14 deletions
+7 -12
View File
@@ -40,9 +40,9 @@ namespace fs = boost::filesystem;
namespace lc = boost::locale;
namespace loot {
Game::Game() {}
Game::Game() : _pluginsFullyLoaded(false) {}
Game::Game(const GameSettings& gameSettings) : GameSettings(gameSettings.Id(), gameSettings.FolderName()) {
Game::Game(const GameSettings& gameSettings) : GameSettings(gameSettings.Id(), gameSettings.FolderName()), _pluginsFullyLoaded(false) {
this->SetName(gameSettings.Name())
.SetMaster(gameSettings.Master())
.SetRepoURL(gameSettings.RepoURL())
@@ -51,7 +51,7 @@ namespace loot {
.SetRegistryKey(gameSettings.RegistryKey());
}
Game::Game(const unsigned int gameCode, const std::string& folder) : GameSettings(gameCode, folder) {}
Game::Game(const unsigned int gameCode, const std::string& folder) : GameSettings(gameCode, folder), _pluginsFullyLoaded(false) {}
void Game::Init(bool createFolder, const boost::filesystem::path& gameLocalAppData) {
if (Id() != Game::tes4 && Id() != Game::tes5 && Id() != Game::fo3 && Id() != Game::fonv) {
@@ -183,17 +183,12 @@ namespace loot {
if (thread.joinable())
thread.join();
}
_pluginsFullyLoaded = !headersOnly;
}
bool Game::HasBeenLoaded() {
// Easy way to check is by checking the game's master file,
// which definitely shouldn't be empty.
auto pairIt = plugins.find(boost::locale::to_lower(Master()));
if (pairIt != plugins.end())
return !pairIt->second.FormIDs().empty();
return false;
bool Game::ArePluginsFullyLoaded() const {
return _pluginsFullyLoaded;
}
std::list<Game> ToGames(const std::list<GameSettings>& settings) {
+3 -1
View File
@@ -57,7 +57,7 @@ namespace loot {
void RedatePlugins(); //Change timestamps to match load order (Skyrim only).
void LoadPlugins(bool headersOnly); //Loads all installed plugins.
bool HasBeenLoaded(); // Checks if the game's plugins have already been loaded.
bool ArePluginsFullyLoaded() const; // Checks if the game's plugins have already been loaded.
//Caches for condition results, active plugins and CRCs.
std::unordered_map<std::string, bool> conditionCache; //Holds lowercased strings.
@@ -68,6 +68,8 @@ namespace loot {
Masterlist masterlist;
MetadataList userlist;
std::unordered_map<std::string, Plugin> plugins; //Map so that plugin data can be edited.
private:
bool _pluginsFullyLoaded;
};
std::list<Game> ToGames(const std::list<GameSettings>& settings);
+1 -1
View File
@@ -383,7 +383,7 @@ namespace loot {
// Checking for FormID overlap will only work if the plugins have been loaded, so check if
// the plugins have been fully loaded, and if not load all plugins.
if (!_lootState.CurrentGame().HasBeenLoaded()) {
if (!_lootState.CurrentGame().ArePluginsFullyLoaded()) {
SendProgressUpdate(frame, loc::translate("Loading plugin contents..."));
_lootState.CurrentGame().LoadPlugins(false);
}