mirror of
https://github.com/loot/libloot.git
synced 2026-07-27 14:16:01 -07:00
Make GameInterface::IdentifyMainMasterFile() take a path
This is a breaking change, but avoids the need for libloot to know anything about how to find the master file for OpenMW.
This commit is contained in:
@@ -147,8 +147,11 @@ public:
|
||||
* @brief Identify the game's main master file.
|
||||
* @details When sorting, LOOT always only loads the headers of the game's
|
||||
* main master file as a performance optimisation.
|
||||
*
|
||||
* A relative path is resolved relative to the game's plugins
|
||||
* directory, while an absolute path is used as given.
|
||||
*/
|
||||
virtual void IdentifyMainMasterFile(const std::string& masterFile) = 0;
|
||||
virtual void IdentifyMainMasterFile(const std::filesystem::path& masterFile) = 0;
|
||||
|
||||
/**
|
||||
* @brief Calculates a new load order for the game's installed plugins
|
||||
|
||||
+3
-38
@@ -161,35 +161,6 @@ std::vector<std::filesystem::path> FindArchives(
|
||||
|
||||
return archivePaths;
|
||||
}
|
||||
|
||||
std::filesystem::path FindPlugin(
|
||||
GameType gameType,
|
||||
const std::filesystem::path& dataPath,
|
||||
const std::vector<std::filesystem::path>& additionalDataPaths,
|
||||
const std::string& pluginName) {
|
||||
const auto relativePath = std::filesystem::u8path(pluginName);
|
||||
|
||||
const auto finder = [&](const auto& path) {
|
||||
const auto resolvedPath = ResolvePluginPath(gameType, path, relativePath);
|
||||
return std::filesystem::exists(resolvedPath);
|
||||
};
|
||||
|
||||
if (gameType == GameType::openmw) {
|
||||
const auto it = std::find_if(
|
||||
additionalDataPaths.rbegin(), additionalDataPaths.rend(), finder);
|
||||
if (it != additionalDataPaths.rend()) {
|
||||
return *it;
|
||||
}
|
||||
} else {
|
||||
const auto it = std::find_if(
|
||||
additionalDataPaths.begin(), additionalDataPaths.end(), finder);
|
||||
if (it != additionalDataPaths.end()) {
|
||||
return *it;
|
||||
}
|
||||
}
|
||||
|
||||
return dataPath / relativePath;
|
||||
}
|
||||
}
|
||||
|
||||
namespace loot {
|
||||
@@ -295,12 +266,6 @@ void Game::LoadPlugins(const std::vector<std::filesystem::path>& pluginPaths,
|
||||
logger->trace("Starting plugin loading.");
|
||||
}
|
||||
|
||||
const auto masterPath = GetType() == GameType::openmw
|
||||
? FindPlugin(GetType(),
|
||||
DataPath(),
|
||||
GetAdditionalDataPaths(),
|
||||
masterFilename_)
|
||||
: DataPath() / u8path(masterFilename_);
|
||||
std::for_each(
|
||||
std::execution::par_unseq,
|
||||
pluginPaths.begin(),
|
||||
@@ -312,7 +277,7 @@ void Game::LoadPlugins(const std::vector<std::filesystem::path>& pluginPaths,
|
||||
|
||||
const bool loadHeader =
|
||||
loadHeadersOnly ||
|
||||
loot::equivalent(resolvedPluginPath, masterPath);
|
||||
loot::equivalent(resolvedPluginPath, masterFilePath_);
|
||||
|
||||
cache_.AddPlugin(
|
||||
Plugin(GetType(), cache_, resolvedPluginPath, loadHeader));
|
||||
@@ -352,8 +317,8 @@ std::vector<const PluginInterface*> Game::GetLoadedPlugins() const {
|
||||
return interfacePointers;
|
||||
}
|
||||
|
||||
void Game::IdentifyMainMasterFile(const std::string& masterFile) {
|
||||
masterFilename_ = masterFile;
|
||||
void Game::IdentifyMainMasterFile(const std::filesystem::path& masterFile) {
|
||||
masterFilePath_ = ResolvePluginPath(GetType(), DataPath(), masterFile);
|
||||
}
|
||||
|
||||
std::vector<std::string> Game::SortPlugins(
|
||||
|
||||
+2
-2
@@ -75,7 +75,7 @@ public:
|
||||
|
||||
std::vector<const PluginInterface*> GetLoadedPlugins() const override;
|
||||
|
||||
void IdentifyMainMasterFile(const std::string& masterFile) override;
|
||||
void IdentifyMainMasterFile(const std::filesystem::path& masterFile) override;
|
||||
|
||||
std::vector<std::string> SortPlugins(
|
||||
const std::vector<std::filesystem::path>& pluginPaths) override;
|
||||
@@ -103,7 +103,7 @@ private:
|
||||
std::shared_ptr<ConditionEvaluator> conditionEvaluator_;
|
||||
ApiDatabase database_;
|
||||
|
||||
std::string masterFilename_;
|
||||
std::filesystem::path masterFilePath_;
|
||||
|
||||
std::vector<std::filesystem::path> additionalDataPaths_;
|
||||
};
|
||||
|
||||
@@ -68,7 +68,7 @@ protected:
|
||||
plugins.push_back(blankEsl);
|
||||
}
|
||||
|
||||
game_.IdentifyMainMasterFile(masterFile);
|
||||
game_.IdentifyMainMasterFile(std::filesystem::u8path(masterFile));
|
||||
game_.LoadCurrentLoadOrderState();
|
||||
game_.LoadPlugins(plugins, true);
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ protected:
|
||||
}
|
||||
}
|
||||
|
||||
game.IdentifyMainMasterFile(masterFile);
|
||||
game.IdentifyMainMasterFile(std::filesystem::u8path(masterFile));
|
||||
game.LoadCurrentLoadOrderState();
|
||||
game.LoadPlugins(plugins, headersOnly);
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ protected:
|
||||
}
|
||||
}
|
||||
|
||||
game.IdentifyMainMasterFile(masterFile);
|
||||
game.IdentifyMainMasterFile(std::filesystem::u8path(masterFile));
|
||||
game.LoadCurrentLoadOrderState();
|
||||
game.LoadPlugins(plugins, headersOnly);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user