mirror of
https://github.com/loot/libloot.git
synced 2026-07-27 14:16:01 -07:00
Add PluginSortingInterface::IsBlueprintPlugin()
Adding it to the sorting interface because it'll be needed by the sorting logic, but I'm not yet sure if it'll be useful as part of PluginInterface (and adding it there would break ABI).
This commit is contained in:
@@ -337,6 +337,15 @@ bool Plugin::IsUpdatePlugin() const {
|
||||
return isUpdatePlugin;
|
||||
}
|
||||
|
||||
bool Plugin::IsBlueprintPlugin() const {
|
||||
bool isBlueprintPlugin = false;
|
||||
const auto ret =
|
||||
esp_plugin_is_blueprint_plugin(esPlugin.get(), &isBlueprintPlugin);
|
||||
HandleEspluginError("check if \"" + name_ + "\" is a blueprint plugin", ret);
|
||||
|
||||
return isBlueprintPlugin;
|
||||
}
|
||||
|
||||
bool Plugin::IsValidAsLightPlugin() const {
|
||||
bool isValid = false;
|
||||
const auto ret =
|
||||
|
||||
@@ -43,6 +43,8 @@ class GameCache;
|
||||
// An interface containing member functions that are used when sorting plugins.
|
||||
class PluginSortingInterface : public PluginInterface {
|
||||
public:
|
||||
virtual bool IsBlueprintPlugin() const = 0;
|
||||
|
||||
virtual size_t GetOverrideRecordCount() const = 0;
|
||||
virtual uint32_t GetRecordAndGroupCount() const = 0;
|
||||
|
||||
@@ -71,6 +73,7 @@ public:
|
||||
bool IsLightPlugin() const override;
|
||||
bool IsMediumPlugin() const override;
|
||||
bool IsUpdatePlugin() const override;
|
||||
bool IsBlueprintPlugin() const override;
|
||||
|
||||
bool IsValidAsLightPlugin() const override;
|
||||
bool IsValidAsMediumPlugin() const override;
|
||||
|
||||
@@ -182,6 +182,7 @@ public:
|
||||
bool IsLightPlugin() const override { return false; }
|
||||
bool IsMediumPlugin() const override { return false; }
|
||||
bool IsUpdatePlugin() const override { return false; }
|
||||
bool IsBlueprintPlugin() const override { return false; }
|
||||
bool IsValidAsLightPlugin() const override { return false; }
|
||||
bool IsValidAsMediumPlugin() const override { return false; }
|
||||
bool IsValidAsUpdatePlugin() const override { return false; }
|
||||
@@ -370,6 +371,21 @@ TEST_P(PluginTest, isUpdatePluginShouldOnlyBeTrueForAStarfieldUpdatePlugin) {
|
||||
EXPECT_EQ(GetParam() == GameType::starfield, plugin2.IsUpdatePlugin());
|
||||
}
|
||||
|
||||
TEST_P(PluginTest,
|
||||
isBlueprintPluginShouldOnlyBeTrueForAStarfieldBlueprintPlugin) {
|
||||
SetBlueprintFlag(dataPath / blankMasterDependentEsp);
|
||||
|
||||
Plugin plugin1(
|
||||
game_.GetType(), game_.GetCache(), game_.DataPath() / blankEsp, true);
|
||||
Plugin plugin2(game_.GetType(),
|
||||
game_.GetCache(),
|
||||
game_.DataPath() / blankMasterDependentEsp,
|
||||
true);
|
||||
|
||||
EXPECT_FALSE(plugin1.IsBlueprintPlugin());
|
||||
EXPECT_EQ(GetParam() == GameType::starfield, plugin2.IsBlueprintPlugin());
|
||||
}
|
||||
|
||||
TEST_P(PluginTest, loadingAPluginWithMastersShouldReadThemCorrectly) {
|
||||
Plugin plugin(game_.GetType(),
|
||||
game_.GetCache(),
|
||||
|
||||
@@ -64,6 +64,8 @@ public:
|
||||
|
||||
bool IsUpdatePlugin() const override { return false; }
|
||||
|
||||
bool IsBlueprintPlugin() const override { return false; }
|
||||
|
||||
bool IsValidAsLightPlugin() const override { return false; }
|
||||
|
||||
bool IsValidAsMediumPlugin() const override { return false; }
|
||||
|
||||
@@ -357,6 +357,12 @@ protected:
|
||||
}
|
||||
}
|
||||
|
||||
void SetBlueprintFlag(const std::filesystem::path& path) {
|
||||
auto bytes = ReadFile(path);
|
||||
bytes[9] = 0x8;
|
||||
WriteFile(path, bytes);
|
||||
}
|
||||
|
||||
private:
|
||||
const std::filesystem::path rootTestPath;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user