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:
Oliver Hamlet
2024-08-24 16:23:29 +01:00
parent 96b3f08498
commit 715d1dce75
5 changed files with 36 additions and 0 deletions
+9
View File
@@ -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 =
+3
View File
@@ -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;
+16
View File
@@ -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; }
+6
View File
@@ -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;