Add GameInterface::IsLoadOrderAmbiguous()

It exposes libloadorder's lo_is_ambiguous() function.
This commit is contained in:
Oliver Hamlet
2022-02-23 16:45:26 +00:00
parent ac7d60cc76
commit bc76e83357
7 changed files with 41 additions and 1 deletions
+1 -1
View File
@@ -82,7 +82,7 @@ endif()
ExternalProject_Add(libloadorder
PREFIX "external"
URL "https://github.com/Ortham/libloadorder/archive/13.0.0.tar.gz"
URL "https://github.com/Ortham/libloadorder/archive/13.1.0.tar.gz"
CONFIGURE_COMMAND ""
BUILD_IN_SOURCE 1
BUILD_COMMAND cargo build --release --manifest-path ffi/Cargo.toml --target ${RUST_TARGET} &&
+11
View File
@@ -144,6 +144,17 @@ public:
*/
virtual void LoadCurrentLoadOrderState() = 0;
/**
* @brief Check if the load order is ambiguous.
* @details This checks that all plugins in the current load order state have
* a well-defined position in the "on disk" state, and that all data
* sources are consistent. If the load order is ambiguous, different
* applications may read different load orders from the same source
* data.
* @returns True if the load order is ambiguous, false otherwise.
*/
virtual bool IsLoadOrderAmbiguous() const = 0;
/**
* @brief Check if a plugin is active.
* @param plugin
+4
View File
@@ -216,6 +216,10 @@ void Game::LoadCurrentLoadOrderState() {
loadOrderHandler_.GetActivePlugins());
}
bool Game::IsLoadOrderAmbiguous() const {
return loadOrderHandler_.IsAmbiguous();
}
bool Game::IsPluginActive(const std::string& pluginName) const {
return loadOrderHandler_.IsPluginActive(pluginName);
}
+2
View File
@@ -72,6 +72,8 @@ public:
void LoadCurrentLoadOrderState() override;
bool IsLoadOrderAmbiguous() const override;
bool IsPluginActive(const std::string& pluginName) const override;
std::vector<std::string> GetLoadOrder() const override;
+14
View File
@@ -96,6 +96,20 @@ void LoadOrderHandler::LoadCurrentState() {
HandleError("load the current load order state", ret);
}
bool LoadOrderHandler::IsAmbiguous() const {
auto logger = getLogger();
if (logger) {
logger->trace("Checking if the load order is ambiguous.");
}
bool result = false;
const unsigned int ret = lo_is_ambiguous(gh_.get(), &result);
HandleError("check if the load order is ambiguous", ret);
return result;
}
bool LoadOrderHandler::IsPluginActive(const std::string& pluginName) const {
auto logger = getLogger();
if (logger) {
+2
View File
@@ -43,6 +43,8 @@ public:
void LoadCurrentState();
bool IsAmbiguous() const;
std::vector<std::string> GetLoadOrder() const;
std::vector<std::string> GetActivePlugins() const;
@@ -135,6 +135,13 @@ TEST_P(LoadOrderHandlerTest,
LoadOrderHandler(GetParam(), dataPath.parent_path(), localPath));
}
TEST_P(LoadOrderHandlerTest,
isAmbiguousShouldReturnFalseForAnUnambiguousLoadOrder) {
auto loadOrderHandler = createHandler();
EXPECT_FALSE(loadOrderHandler.IsAmbiguous());
}
TEST_P(LoadOrderHandlerTest,
isPluginActiveShouldReturnFalseIfLoadOrderStateHasNotBeenLoaded) {
auto loadOrderHandler = createHandler();