mirror of
https://github.com/loot/libloot.git
synced 2026-07-27 14:16:01 -07:00
Don't cache load order in the API
Leave the load order caching up to libloadorder, which knows when the cache should be expired.
This commit is contained in:
@@ -67,7 +67,6 @@ Game::Game(const GameType gameType,
|
||||
BOOST_LOG_TRIVIAL(info) << "Initialising load order data for game of type " << (int)type_ << " at: " << gamePath_;
|
||||
|
||||
loadOrderHandler_.Init(type_, gamePath_, localDataPath_);
|
||||
StoreLoadOrder(loadOrderHandler_.GetLoadOrder());
|
||||
|
||||
database_ = std::make_shared<ApiDatabase>(*this);
|
||||
}
|
||||
@@ -196,15 +195,10 @@ bool Game::IsPluginActive(const std::string& plugin) const {
|
||||
}
|
||||
|
||||
std::vector<std::string> Game::GetLoadOrder() const {
|
||||
auto loadOrder = GameCache::GetLoadOrder();
|
||||
if (loadOrder.empty())
|
||||
return loadOrderHandler_.GetLoadOrder();
|
||||
|
||||
return loadOrder;
|
||||
return loadOrderHandler_.GetLoadOrder();
|
||||
}
|
||||
|
||||
void Game::SetLoadOrder(const std::vector<std::string>& loadOrder) {
|
||||
loadOrderHandler_.SetLoadOrder(loadOrder);
|
||||
StoreLoadOrder(loadOrder);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -106,18 +106,9 @@ void GameCache::AddPlugin(const Plugin&& plugin) {
|
||||
if (it != end(plugins_))
|
||||
plugins_.erase(it);
|
||||
|
||||
|
||||
plugins_.emplace(plugin.GetLowercasedName(), std::make_shared<Plugin>(std::move(plugin)));
|
||||
}
|
||||
|
||||
std::vector<std::string> GameCache::GetLoadOrder() const {
|
||||
return loadOrder_;
|
||||
}
|
||||
|
||||
void GameCache::StoreLoadOrder(const std::vector<std::string>& loadOrder) {
|
||||
loadOrder_ = loadOrder;
|
||||
}
|
||||
|
||||
void GameCache::ClearCachedConditions() {
|
||||
lock_guard<mutex> guard(mutex_);
|
||||
|
||||
|
||||
@@ -52,9 +52,6 @@ public:
|
||||
std::shared_ptr<const Plugin> GetPlugin(const std::string& pluginName) const;
|
||||
void AddPlugin(const Plugin&& plugin);
|
||||
|
||||
std::vector<std::string> GetLoadOrder() const;
|
||||
void StoreLoadOrder(const std::vector<std::string>& loadOrder);
|
||||
|
||||
void ClearCachedConditions();
|
||||
void ClearCachedPlugins();
|
||||
private:
|
||||
@@ -62,7 +59,6 @@ private:
|
||||
MetadataList userlist_;
|
||||
std::unordered_map<std::string, bool> conditions_;
|
||||
std::unordered_map<std::string, std::shared_ptr<const Plugin>> plugins_;
|
||||
std::vector<std::string> loadOrder_;
|
||||
|
||||
mutable std::mutex mutex_;
|
||||
};
|
||||
@@ -71,7 +67,7 @@ private:
|
||||
namespace std {
|
||||
template<>
|
||||
struct less<std::shared_ptr<const loot::Plugin>> {
|
||||
size_t operator() (const std::shared_ptr<const loot::Plugin>& lhs,
|
||||
size_t operator() (const std::shared_ptr<const loot::Plugin>& lhs,
|
||||
const std::shared_ptr<const loot::Plugin>& rhs) const {
|
||||
return lhs->GetLowercasedName() < rhs->GetLowercasedName();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user