Deprecate PluginInterface::IsLightMaster() and PluginInterface::IsValidAsLightMaster()

In favour of IsLightPlugin() and IsValidAsLightPlugin() respectively.
The new functions are identical to the old besides their names, which
now more clearly indicate that plugins can be light without being
masters.
This commit is contained in:
Oliver Hamlet
2021-05-06 21:03:02 +01:00
parent 51eec61884
commit 897a303ec7
6 changed files with 51 additions and 19 deletions
+18 -2
View File
@@ -91,18 +91,34 @@ public:
virtual bool IsMaster() const = 0;
/**
* Check if the plugin is a light master.
* @return True if plugin is a light master, false otherwise.
* Check if the plugin is a light plugin.
* @return True if plugin is a light plugin, false otherwise.
* @deprecated Use IsLightPlugin() instead.
*/
[[deprecated("Use IsLightPlugin() instead.")]]
virtual bool IsLightMaster() const = 0;
/**
* Check if the plugin is a light plugin.
* @return True if plugin is a light plugin, false otherwise.
*/
virtual bool IsLightPlugin() const = 0;
/**
* Check if the plugin is or would be valid as a light master.
* @return True if the plugin is a valid light master or would be a valid
* light master, false otherwise.
*/
[[deprecated("Use IsValidAsLightPlugin() instead.")]]
virtual bool IsValidAsLightMaster() const = 0;
/**
* Check if the plugin is or would be valid as a light master.
* @return True if the plugin is a valid light master or would be a valid
* light master, false otherwise.
*/
virtual bool IsValidAsLightPlugin() const = 0;
/**
* Check if the plugin contains any records other than its TES4 header.
* @return True if the plugin only contains a TES4 header, false otherwise.
+15 -7
View File
@@ -136,19 +136,27 @@ bool Plugin::IsMaster() const {
}
bool Plugin::IsLightMaster() const {
bool isLightMaster;
auto ret = esp_plugin_is_light_master(esPlugin.get(), &isLightMaster);
return IsLightPlugin();
}
bool Plugin::IsLightPlugin() const {
bool isLightPlugin;
auto ret = esp_plugin_is_light_plugin(esPlugin.get(), &isLightPlugin);
if (ret != ESP_OK) {
throw FileAccessError(name_ +
" : esplugin error code: " + std::to_string(ret));
}
return isLightMaster;
return isLightPlugin;
}
bool Plugin::IsValidAsLightMaster() const {
return IsValidAsLightPlugin();
}
bool Plugin::IsValidAsLightPlugin() const {
bool isValid;
auto ret = esp_plugin_is_valid_as_light_master(esPlugin.get(), &isValid);
auto ret = esp_plugin_is_valid_as_light_plugin(esPlugin.get(), &isValid);
if (ret != ESP_OK) {
throw FileAccessError(name_ +
" : esplugin error code: " + std::to_string(ret));
@@ -422,13 +430,13 @@ bool hasPluginFileExtension(std::string filename, GameType gameType) {
filename = filename.substr(0, filename.length() - 6);
}
bool espOrEsm = boost::iends_with(filename, ".esp") ||
bool isEspOrEsm = boost::iends_with(filename, ".esp") ||
boost::iends_with(filename, ".esm");
bool lightMaster =
bool isEsl =
(gameType == GameType::fo4 || gameType == GameType::fo4vr ||
gameType == GameType::tes5se || gameType == GameType::tes5vr) &&
boost::iends_with(filename, ".esl");
return espOrEsm || lightMaster;
return isEspOrEsm || isEsl;
}
}
+6
View File
@@ -56,8 +56,14 @@ public:
std::optional<uint32_t> GetCRC() const;
bool IsMaster() const;
[[deprecated("Use IsLightPlugin() instead.")]]
bool IsLightMaster() const;
bool IsLightPlugin() const;
[[deprecated("Use IsValidAsLightPlugin() instead.")]]
bool IsValidAsLightMaster() const;
bool IsValidAsLightPlugin() const;
bool IsEmpty() const;
bool LoadsArchive() const;
bool DoFormIDsOverlap(const PluginInterface& plugin) const;
+1 -1
View File
@@ -103,7 +103,7 @@ PluginSortingData::PluginSortingData(
std::string PluginSortingData::GetName() const { return plugin_.GetName(); }
bool PluginSortingData::IsMaster() const {
return plugin_.IsMaster() || (plugin_.IsLightMaster() &&
return plugin_.IsMaster() || (plugin_.IsLightPlugin() &&
!boost::iends_with(plugin_.GetName(), ".esp"));
}
+8 -6
View File
@@ -150,7 +150,9 @@ public:
bool IsMaster() const { return false; }
bool IsLightMaster() const { return false; }
bool IsLightPlugin() const { return false; }
bool IsValidAsLightMaster() const { return false; }
bool IsValidAsLightPlugin() const { return false; }
bool IsEmpty() const { return false; }
bool LoadsArchive() const { return false; }
bool DoFormIDsOverlap(const PluginInterface& plugin) const { return true; }
@@ -254,7 +256,7 @@ TEST_P(PluginTest, loadingANonMasterPluginShouldReadTheMasterFlagAsFalse) {
TEST_P(
PluginTest,
isLightMasterShouldBeTrueForAPluginWithEslFileExtensionForFallout4AndSkyrimSeAndFalseOtherwise) {
isLightPluginShouldBeTrueForAPluginWithEslFileExtensionForFallout4AndSkyrimSeAndFalseOtherwise) {
Plugin plugin1(
game_.Type(), game_.GetCache(), game_.DataPath() / blankEsm, true);
Plugin plugin2(game_.Type(),
@@ -264,10 +266,10 @@ TEST_P(
Plugin plugin3(
game_.Type(), game_.GetCache(), game_.DataPath() / blankEsl, true);
EXPECT_FALSE(plugin1.IsLightMaster());
EXPECT_FALSE(plugin2.IsLightMaster());
EXPECT_FALSE(plugin1.IsLightPlugin());
EXPECT_FALSE(plugin2.IsLightPlugin());
EXPECT_EQ(GetParam() == GameType::fo4 || GetParam() == GameType::tes5se,
plugin3.IsLightMaster());
plugin3.IsLightPlugin());
}
TEST_P(PluginTest, loadingAPluginWithMastersShouldReadThemCorrectly) {
@@ -410,10 +412,10 @@ TEST_P(PluginTest, isValidShouldReturnFalseForAnEmptyFile) {
TEST_P(
PluginTest,
isValidAsLightMasterShouldReturnTrueOnlyForASkyrimSEOrFallout4PluginWithNewFormIdsBetween0x800And0xFFFInclusive) {
isValidAsLightPluginShouldReturnTrueOnlyForASkyrimSEOrFallout4PluginWithNewFormIdsBetween0x800And0xFFFInclusive) {
bool valid =
Plugin(game_.Type(), game_.GetCache(), game_.DataPath() / blankEsm, true)
.IsValidAsLightMaster();
.IsValidAsLightPlugin();
if (GetParam() == GameType::fo4 || GetParam() == GameType::tes5se) {
EXPECT_TRUE(valid);
} else {
@@ -78,7 +78,7 @@ INSTANTIATE_TEST_CASE_P(,
GameType::fo4));
TEST_P(PluginSortingDataTest,
lightMasterFlaggedEspFilesShouldNotBeTreatedAsMasters) {
lightFlaggedEspFilesShouldNotBeTreatedAsMasters) {
if (GetParam() == GameType::fo4 || GetParam() == GameType::tes5se) {
ASSERT_NO_THROW(
std::filesystem::copy(dataPath / blankEsl, dataPath / blankEslEsp));
@@ -114,14 +114,14 @@ TEST_P(PluginSortingDataTest,
game_.GetCache()->GetPlugins());
EXPECT_TRUE(lightMaster.IsMaster());
auto lightMasterEsp = PluginSortingData(
auto lightPlugin = PluginSortingData(
*dynamic_cast<const Plugin *>(game_.GetPlugin(blankEslEsp).get()),
PluginMetadata(),
PluginMetadata(),
getLoadOrder(),
game_.Type(),
game_.GetCache()->GetPlugins());
EXPECT_FALSE(lightMasterEsp.IsMaster());
EXPECT_FALSE(lightPlugin.IsMaster());
}
}