mirror of
https://github.com/loot/libloot.git
synced 2026-07-27 14:16:01 -07:00
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:
+15
-7
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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"));
|
||||
}
|
||||
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user