Skip to content

Commit

Permalink
Add PluginInterface::IsBlueprintPlugin()
Browse files Browse the repository at this point in the history
  • Loading branch information
Ortham committed Aug 9, 2024
1 parent e67a141 commit ac366ac
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 0 deletions.
6 changes: 6 additions & 0 deletions include/loot/plugin_interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,12 @@ class PluginInterface {
*/
virtual bool IsUpdatePlugin() const = 0;

/**
* Check if the plugin is a blueprint plugin.
* @return True if plugin is a blueprint plugin, false otherwise.
*/
virtual bool IsBlueprintPlugin() const = 0;

/**
* Check if the plugin is or would be valid as a light plugin.
* @return True if the plugin is a valid light plugin or would be a valid
Expand Down
9 changes: 9 additions & 0 deletions src/api/plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,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 =
Expand Down
1 change: 1 addition & 0 deletions src/api/plugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ class Plugin final : public PluginSortingInterface {
bool IsLightPlugin() const override;
bool IsMediumPlugin() const override;
bool IsUpdatePlugin() const override;
bool IsBlueprintPlugin() const override;

bool IsValidAsLightPlugin() const override;
bool IsValidAsMediumPlugin() const override;
Expand Down
17 changes: 17 additions & 0 deletions src/tests/api/internals/plugin_test.h
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ class OtherPluginType final : public PluginSortingInterface {
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; }
Expand Down Expand Up @@ -389,6 +390,22 @@ TEST_P(PluginTest,
EXPECT_EQ(GetParam() == GameType::starfield, plugin2.IsUpdatePlugin());
}

TEST_P(PluginTest, isBlueprintPluginShouldOnlyBeTrueForAStarfieldBlueprintPlugin) {
auto bytes = ReadFile(dataPath / blankMasterDependentEsp);
bytes[9] = 0x8;
WriteFile(dataPath / blankMasterDependentEsp, bytes);

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(),
Expand Down
2 changes: 2 additions & 0 deletions src/tests/api/internals/sorting/plugin_graph_test.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ class TestPlugin : public PluginSortingInterface {

bool IsUpdatePlugin() const override { return false; }

bool IsBlueprintPlugin() const override { return false; }

bool IsValidAsLightPlugin() const override { return false; }

bool IsValidAsMediumPlugin() const override { return false; }
Expand Down

0 comments on commit ac366ac

Please sign in to comment.