Add medium plugin methods to PluginInterface

This commit is contained in:
Oliver Hamlet
2024-06-28 19:21:00 +01:00
parent 2c81b30352
commit 46c19a4a7a
5 changed files with 70 additions and 0 deletions
+18
View File
@@ -307,6 +307,14 @@ bool Plugin::IsLightPlugin() const {
return isLightPlugin;
}
bool Plugin::IsMediumPlugin() const {
bool isMediumPlugin = false;
const auto ret = esp_plugin_is_medium_plugin(esPlugin.get(), &isMediumPlugin);
HandleEspluginError("check if \"" + name_ + "\" is a medium plugin", ret);
return isMediumPlugin;
}
bool Plugin::IsOverridePlugin() const {
bool isOverridePlugin = false;
const auto ret =
@@ -326,6 +334,16 @@ bool Plugin::IsValidAsLightPlugin() const {
return isValid;
}
bool Plugin::IsValidAsMediumPlugin() const {
bool isValid = false;
const auto ret =
esp_plugin_is_valid_as_medium_plugin(esPlugin.get(), &isValid);
HandleEspluginError("check if \"" + name_ + "\" is valid as a medium plugin",
ret);
return isValid;
}
bool Plugin::IsValidAsOverridePlugin() const {
bool isValid = false;
const auto ret =
+2
View File
@@ -72,9 +72,11 @@ public:
bool IsMaster() const override;
bool IsLightPlugin() const override;
bool IsMediumPlugin() const override;
bool IsOverridePlugin() const override;
bool IsValidAsLightPlugin() const override;
bool IsValidAsMediumPlugin() const override;
bool IsValidAsOverridePlugin() const override;
bool IsEmpty() const override;
bool LoadsArchive() const override;
+33
View File
@@ -197,8 +197,10 @@ public:
bool IsMaster() const override { return false; }
bool IsLightPlugin() const override { return false; }
bool IsMediumPlugin() const override { return false; }
bool IsOverridePlugin() const override { return false; }
bool IsValidAsLightPlugin() const override { return false; }
bool IsValidAsMediumPlugin() const override { return false; }
bool IsValidAsOverridePlugin() const override { return false; }
bool IsEmpty() const override { return false; }
bool LoadsArchive() const override { return false; }
@@ -358,6 +360,23 @@ TEST_P(
plugin3.IsLightPlugin());
}
TEST_P(
PluginTest,
isMediumPluginShouldBeTrueForAMediumFlaggedPluginForStarfield) {
if (GetParam() != GameType::starfield) {
auto bytes = ReadFile(dataPath / blankEsm);
bytes[9] = 0x4;
WriteFile(dataPath / blankEsm, bytes);
}
const auto pluginName =
GetParam() == GameType::starfield ? blankMediumEsm : blankEsm;
Plugin plugin(game_.GetType(), game_.GetCache(), game_.DataPath() / pluginName,
true);
EXPECT_EQ(GetParam() == GameType::starfield, plugin.IsMediumPlugin());
}
TEST_P(PluginTest,
isOverridePluginShouldOnlyBeTrueForAStarfieldOverridePlugin) {
auto bytes = ReadFile(dataPath / blankMasterDependentEsp);
@@ -545,6 +564,20 @@ TEST_P(
}
}
TEST_P(
PluginTest,
isValidAsMediumPluginShouldReturnTrueOnlyForAStarfieldPluginWithNewFormIdsBetween0And0xFFFFInclusive) {
bool valid =
Plugin(
game_.GetType(), game_.GetCache(), dataPath / blankEsm, true)
.IsValidAsMediumPlugin();
if (GetParam() == GameType::starfield) {
EXPECT_TRUE(valid);
} else {
EXPECT_FALSE(valid);
}
}
TEST_P(
PluginTest,
IsValidAsOverridePluginShouldOnlyReturnTrueForAStarfieldPluginWithNoNewRecords) {
@@ -60,10 +60,14 @@ public:
bool IsLightPlugin() const override { return false; }
bool IsMediumPlugin() const override { return false; }
bool IsOverridePlugin() const override { return false; }
bool IsValidAsLightPlugin() const override { return false; }
bool IsValidAsMediumPlugin() const override { return false; }
bool IsValidAsOverridePlugin() const override { return false; }
bool IsEmpty() const override { return false; }