Inherit Plugin from libespm

This cuts down on data and method duplication
This commit is contained in:
Oliver Hamlet
2015-12-05 17:48:33 +00:00
parent a2813f0e4d
commit 5dced2d42d
7 changed files with 140 additions and 151 deletions
+4 -3
View File
@@ -100,7 +100,7 @@ namespace loot {
//Compare name string.
bool operator == (const std::string& rhs) const;
bool operator != (const std::string& rhs) const;
protected:
private:
std::string name;
bool enabled; //Default to true.
bool _isPriorityExplicit; //If false and priority is 0, then priority was not explicitly set as such.
@@ -108,10 +108,11 @@ namespace loot {
std::set<File> loadAfter;
std::set<File> requirements;
std::set<File> incompatibilities;
std::list<Message> messages;
std::set<Tag> tags;
std::set<PluginDirtyInfo> _dirtyInfo;
std::set<Location> _locations;
protected:
std::list<Message> messages;
std::set<Tag> tags;
};
}
+47 -57
View File
@@ -33,8 +33,6 @@
#include <boost/locale.hpp>
#include <regex>
#include <libespm/Plugin.h>
using namespace std;
using libespm::FormId;
@@ -92,62 +90,59 @@ namespace loot {
regex(regex7, regex::ECMAScript | regex::icase)
});
// TODO: Remove the name-only constructor.
Plugin::Plugin(const std::string& n) :
PluginMetadata(n),
libespm::Plugin(libespm::GameId::SKYRIM),
_isEmpty(true),
_loadsBsa(false),
isMaster(false),
crc(0),
numOverrideRecords(0) {}
Plugin::Plugin(Game& game, const std::string& n, const bool headerOnly) :
PluginMetadata(n),
Plugin::Plugin(Game& game, const std::string& name, const bool headerOnly) :
PluginMetadata(name),
libespm::Plugin(game.LibespmId()),
_isEmpty(true),
_loadsBsa(false),
isMaster(false),
crc(0),
numOverrideRecords(0) {
try {
boost::filesystem::path filepath = game.DataPath() / name;
boost::filesystem::path filepath = game.DataPath() / Name();
// In case the plugin is ghosted.
if (!boost::filesystem::exists(filepath) && boost::filesystem::exists(filepath.string() + ".ghost"))
filepath += ".ghost";
libespm::Plugin plugin(game.LibespmId());
plugin.load(filepath, headerOnly);
load(filepath, headerOnly);
isMaster = plugin.isMasterFile();
masters = plugin.getMasters();
formIDs = plugin.getFormIds();
_isEmpty = plugin.getRecordAndGroupCount() == 0;
_isEmpty = getRecordAndGroupCount() == 0;
if (!headerOnly) {
BOOST_LOG_TRIVIAL(trace) << name << ": Caching CRC value.";
BOOST_LOG_TRIVIAL(trace) << Name() << ": Caching CRC value.";
crc = GetCrc32(filepath);
game.CacheCrc(name, crc);
game.CacheCrc(Name(), crc);
}
BOOST_LOG_TRIVIAL(trace) << name << ": Counting override FormIDs.";
for (const auto& formID : formIDs) {
if (!boost::iequals(formID.getPluginName(), name))
BOOST_LOG_TRIVIAL(trace) << Name() << ": Counting override FormIDs.";
for (const auto& formID : getFormIds()) {
if (!boost::iequals(formID.getPluginName(), Name()))
++numOverrideRecords;
}
//Also read Bash Tags applied and version string in description.
string text = plugin.getDescription();
BOOST_LOG_TRIVIAL(trace) << name << ": " << "Attempting to read the version from the description.";
string text = getDescription();
BOOST_LOG_TRIVIAL(trace) << Name() << ": " << "Attempting to read the version from the description.";
for (size_t i = 0; i < version_checks.size(); ++i) {
smatch what;
if (regex_search(text, what, version_checks[i])) {
//Use the first sub-expression match.
version = string(what[1].first, what[1].second);
boost::trim(version);
BOOST_LOG_TRIVIAL(info) << name << ": " << "Extracted version \"" << version << "\" using regex " << i + 1;
BOOST_LOG_TRIVIAL(info) << Name() << ": " << "Extracted version \"" << version << "\" using regex " << i + 1;
break;
}
}
BOOST_LOG_TRIVIAL(trace) << name << ": " << "Attempting to extract Bash Tags from the description.";
BOOST_LOG_TRIVIAL(trace) << Name() << ": " << "Attempting to extract Bash Tags from the description.";
size_t pos1 = text.find("{{BASH:");
if (pos1 != string::npos && pos1 + 7 != text.length()) {
pos1 += 7;
@@ -161,7 +156,7 @@ namespace loot {
for (auto &tag : bashTags) {
boost::trim(tag);
BOOST_LOG_TRIVIAL(trace) << name << ": " << "Extracted Bash Tag: " << tag;
BOOST_LOG_TRIVIAL(trace) << Name() << ": " << "Extracted Bash Tag: " << tag;
tags.insert(Tag(tag));
}
}
@@ -170,11 +165,11 @@ namespace loot {
// Get whether the plugin loads a BSA or not.
if (game.Id() == Game::tes5) {
// Skyrim plugins only load BSAs that exactly match their basename.
_loadsBsa = boost::filesystem::exists(game.DataPath() / (name.substr(0, name.length() - 3) + "bsa"));
_loadsBsa = boost::filesystem::exists(game.DataPath() / (Name().substr(0, Name().length() - 3) + "bsa"));
}
else if (game.Id() != Game::tes4 || boost::iends_with(name, ".esp")) {
else if (game.Id() != Game::tes4 || boost::iends_with(Name(), ".esp")) {
//Oblivion .esp files and FO3, FNV plugins can load BSAs which begin with the plugin basename.
string basename = name.substr(0, name.length() - 4);
string basename = Name().substr(0, Name().length() - 4);
for (boost::filesystem::directory_iterator it(game.DataPath()); it != boost::filesystem::directory_iterator(); ++it) {
if (it->path().extension().string() == ".bsa" && boost::istarts_with(it->path().filename().string(), basename)) {
_loadsBsa = true;
@@ -184,25 +179,23 @@ namespace loot {
}
}
catch (std::exception& e) {
BOOST_LOG_TRIVIAL(error) << "Cannot read plugin file \"" << name << "\". Details: " << e.what();
BOOST_LOG_TRIVIAL(error) << "Cannot read plugin file \"" << Name() << "\". Details: " << e.what();
messages.push_back(loot::Message(loot::Message::error, (boost::format(boost::locale::translate("Cannot read \"%1%\". Details: %2%")) % name % e.what()).str()));
}
BOOST_LOG_TRIVIAL(trace) << name << ": " << "Plugin loading complete.";
}
const std::set<libespm::FormId>& Plugin::FormIDs() const {
return formIDs;
BOOST_LOG_TRIVIAL(trace) << Name() << ": " << "Plugin loading complete.";
}
bool Plugin::DoFormIDsOverlap(const Plugin& plugin) const {
//Basically std::set_intersection except with an early exit instead of an append to results.
//BOOST_LOG_TRIVIAL(trace) << "Checking for FormID overlap between \"" << name << "\" and \"" << plugin.Name() << "\".";
set<FormId>::const_iterator i = formIDs.begin(),
j = plugin.FormIDs().begin(),
iend = formIDs.end(),
jend = plugin.FormIDs().end();
set<FormId> formIds(getFormIds());
set<FormId> otherFormIds(plugin.getFormIds());
auto i = begin(formIds);
auto j = begin(otherFormIds);
auto iend = end(formIds);
auto jend = end(otherFormIds);
while (i != iend && j != jend) {
if (*i < *j)
@@ -221,22 +214,19 @@ namespace loot {
}
std::set<FormId> Plugin::OverlapFormIDs(const Plugin& plugin) const {
set<FormId> otherFormIDs = plugin.FormIDs();
set<FormId> formIds(getFormIds());
set<FormId> otherFormIds(plugin.getFormIds());
set<FormId> overlap;
set_intersection(formIDs.begin(), formIDs.end(), otherFormIDs.begin(), otherFormIDs.end(), inserter(overlap, overlap.end()));
set_intersection(begin(formIds),
end(formIds),
begin(otherFormIds),
end(otherFormIds),
inserter(overlap, end(overlap)));
return overlap;
}
std::vector<std::string> Plugin::Masters() const {
return masters;
}
bool Plugin::IsMaster() const {
return isMaster;
}
bool Plugin::IsEmpty() const {
return _isEmpty;
}
@@ -268,7 +258,7 @@ namespace loot {
}
bool Plugin::IsActive(const Game& game) const {
return game.IsPluginActive(name);
return game.IsPluginActive(Name());
}
std::string Plugin::Version() const {
@@ -280,45 +270,45 @@ namespace loot {
}
bool Plugin::CheckInstallValidity(const Game& game) {
BOOST_LOG_TRIVIAL(trace) << "Checking that the current install is valid according to " << name << "'s data.";
BOOST_LOG_TRIVIAL(trace) << "Checking that the current install is valid according to " << Name() << "'s data.";
if (IsActive(game)) {
auto pluginExists = [](const Game& game, const std::string& file) {
return boost::filesystem::exists(game.DataPath() / file)
|| ((boost::iends_with(file, ".esp") || boost::iends_with(file, ".esm")) && boost::filesystem::exists(game.DataPath() / (file + ".ghost")));
};
if (tags.find(Tag("Filter")) == tags.end()) {
for (const auto &master : masters) {
for (const auto &master : getMasters()) {
if (!pluginExists(game, master)) {
BOOST_LOG_TRIVIAL(error) << "\"" << name << "\" requires \"" << master << "\", but it is missing.";
BOOST_LOG_TRIVIAL(error) << "\"" << Name() << "\" requires \"" << master << "\", but it is missing.";
messages.push_back(Message(Message::error, (boost::format(boost::locale::translate("This plugin requires \"%1%\" to be installed, but it is missing.")) % master).str()));
}
else if (!Plugin(master).IsActive(game)) {
BOOST_LOG_TRIVIAL(error) << "\"" << name << "\" requires \"" << master << "\", but it is inactive.";
BOOST_LOG_TRIVIAL(error) << "\"" << Name() << "\" requires \"" << master << "\", but it is inactive.";
messages.push_back(Message(Message::error, (boost::format(boost::locale::translate("This plugin requires \"%1%\" to be active, but it is inactive.")) % master).str()));
}
}
}
for (const auto &req : requirements) {
for (const auto &req : Reqs()) {
if (!pluginExists(game, req.Name())) {
BOOST_LOG_TRIVIAL(error) << "\"" << name << "\" requires \"" << req.Name() << "\", but it is missing.";
BOOST_LOG_TRIVIAL(error) << "\"" << Name() << "\" requires \"" << req.Name() << "\", but it is missing.";
messages.push_back(loot::Message(Message::error, (boost::format(boost::locale::translate("This plugin requires \"%1%\" to be installed, but it is missing.")) % req.Name()).str()));
}
}
for (const auto &inc : incompatibilities) {
for (const auto &inc : Incs()) {
if (pluginExists(game, inc.Name()) && Plugin(inc.Name()).IsActive(game)) {
BOOST_LOG_TRIVIAL(error) << "\"" << name << "\" is incompatible with \"" << inc.Name() << "\", but both are present.";
BOOST_LOG_TRIVIAL(error) << "\"" << Name() << "\" is incompatible with \"" << inc.Name() << "\", but both are present.";
messages.push_back(loot::Message(Message::error, (boost::format(boost::locale::translate("This plugin is incompatible with \"%1%\", but both are present.")) % inc.Name()).str()));
}
}
}
// Also generate dirty messages.
for (const auto &element : _dirtyInfo) {
for (const auto &element : DirtyInfo()) {
messages.push_back(element.AsMessage());
}
return !_dirtyInfo.empty();
return !DirtyInfo().empty();
}
bool Plugin::LoadsBSA() const {
+6 -8
View File
@@ -34,19 +34,20 @@
#include <boost/locale.hpp>
#include <libespm/FormId.h>
#include <libespm/Plugin.h>
namespace loot {
class Game;
class Plugin : public PluginMetadata {
class Plugin : public PluginMetadata, private libespm::Plugin {
public:
Plugin(const std::string& name);
Plugin(Game& game, const std::string& name, const bool headerOnly);
const std::set<libespm::FormId>& FormIDs() const;
std::vector<std::string> Masters() const;
bool IsMaster() const; //Checks master bit flag.
using libespm::Plugin::getFormIds;
using libespm::Plugin::getMasters;
using libespm::Plugin::isMasterFile;
bool IsEmpty() const;
std::string Version() const;
uint32_t Crc() const;
@@ -65,10 +66,7 @@ namespace loot {
private:
bool _isEmpty; // Does the plugin contain any records other than the TES4 header?
bool _loadsBsa;
std::vector<std::string> masters;
std::set<libespm::FormId> formIDs;
std::string version; //Obtained from description field.
bool isMaster;
uint32_t crc;
//Useful caches.
+4 -4
View File
@@ -268,13 +268,13 @@ namespace loot {
loot::vertex_it vit2 = vit;
++vit2;
while (vit2 != vitend) {
if (graph[*vit].IsMaster() == graph[*vit2].IsMaster()) {
if (graph[*vit].isMasterFile() == graph[*vit2].isMasterFile()) {
++vit2;
continue;
}
vertex_t vertex, parentVertex;
if (graph[*vit2].IsMaster()) {
if (graph[*vit2].isMasterFile()) {
parentVertex = *vit2;
vertex = *vit;
}
@@ -292,7 +292,7 @@ namespace loot {
}
BOOST_LOG_TRIVIAL(trace) << "Adding in-edges for masters.";
vector<string> strVec(graph[*vit].Masters());
vector<string> strVec(graph[*vit].getMasters());
for (const auto &master : strVec) {
if (GetVertexByName(master, parentVertex) &&
!boost::edge(parentVertex, *vit, graph).second) {
@@ -361,7 +361,7 @@ namespace loot {
for (boost::tie(vit2, vitend2) = boost::vertices(graph); vit2 != vitend2; ++vit2) {
if (graph[*vit].Priority() == graph[*vit2].Priority()
|| (abs(graph[*vit].Priority()) < max_priority && abs(graph[*vit2].Priority()) < max_priority
&& !graph[*vit].FormIDs().empty() && !graph[*vit2].FormIDs().empty() && !graph[*vit].DoFormIDsOverlap(graph[*vit2])
&& !graph[*vit].getFormIds().empty() && !graph[*vit2].getFormIds().empty() && !graph[*vit].DoFormIDsOverlap(graph[*vit2])
)
) {
continue;
+1 -1
View File
@@ -742,7 +742,7 @@ namespace loot {
pluginNode["name"] = plugin.Name();
pluginNode["isActive"] = plugin.IsActive(_lootState.CurrentGame());
pluginNode["isEmpty"] = plugin.IsEmpty();
pluginNode["isMaster"] = plugin.IsMaster();
pluginNode["isMaster"] = plugin.isMasterFile();
pluginNode["loadsBSA"] = plugin.LoadsBSA();
pluginNode["crc"] = IntToHexString(plugin.Crc());
pluginNode["version"] = plugin.Version();
+66 -66
View File
@@ -274,7 +274,7 @@ TEST_F(Game, LoadPlugins) {
loot::Plugin plugin = game.plugins.find("skyrim.esm")->second;
EXPECT_EQ("Skyrim.esm", plugin.Name());
EXPECT_FALSE(plugin.IsEmpty());
EXPECT_TRUE(plugin.IsMaster());
EXPECT_TRUE(plugin.isMasterFile());
EXPECT_EQ(std::set<libespm::FormId>({
libespm::FormId("Skyrim.esm", std::vector<std::string>(), 0xCF0),
libespm::FormId("Skyrim.esm", std::vector<std::string>(), 0xCF1),
@@ -286,8 +286,8 @@ TEST_F(Game, LoadPlugins) {
libespm::FormId("Skyrim.esm", std::vector<std::string>(), 0xCF7),
libespm::FormId("Skyrim.esm", std::vector<std::string>(), 0xCF8),
libespm::FormId("Skyrim.esm", std::vector<std::string>(), 0xCF9),
}), plugin.FormIDs());
EXPECT_TRUE(plugin.Masters().empty());
}), plugin.getFormIds());
EXPECT_TRUE(plugin.getMasters().empty());
EXPECT_EQ("5.0", plugin.Version());
EXPECT_EQ(0x187BE342, plugin.Crc());
EXPECT_EQ(0, plugin.NumOverrideFormIDs());
@@ -296,7 +296,7 @@ TEST_F(Game, LoadPlugins) {
plugin = game.plugins.find("blank.esm")->second;
EXPECT_EQ("Blank.esm", plugin.Name());
EXPECT_FALSE(plugin.IsEmpty());
EXPECT_TRUE(plugin.IsMaster());
EXPECT_TRUE(plugin.isMasterFile());
EXPECT_EQ(std::set<libespm::FormId>({
libespm::FormId("Blank.esm", std::vector<std::string>(), 0xCF0),
libespm::FormId("Blank.esm", std::vector<std::string>(), 0xCF1),
@@ -308,8 +308,8 @@ TEST_F(Game, LoadPlugins) {
libespm::FormId("Blank.esm", std::vector<std::string>(), 0xCF7),
libespm::FormId("Blank.esm", std::vector<std::string>(), 0xCF8),
libespm::FormId("Blank.esm", std::vector<std::string>(), 0xCF9),
}), plugin.FormIDs());
EXPECT_TRUE(plugin.Masters().empty());
}), plugin.getFormIds());
EXPECT_TRUE(plugin.getMasters().empty());
EXPECT_EQ("5.0", plugin.Version());
EXPECT_EQ(0x187BE342, plugin.Crc());
EXPECT_EQ(0, plugin.NumOverrideFormIDs());
@@ -318,7 +318,7 @@ TEST_F(Game, LoadPlugins) {
plugin = game.plugins.find("blank - different.esm")->second;
EXPECT_EQ("Blank - Different.esm", plugin.Name());
EXPECT_FALSE(plugin.IsEmpty());
EXPECT_TRUE(plugin.IsMaster());
EXPECT_TRUE(plugin.isMasterFile());
EXPECT_EQ(std::set<libespm::FormId>({
libespm::FormId("Blank - Different.esm", std::vector<std::string>(), 0xCEF),
libespm::FormId("Blank - Different.esm", std::vector<std::string>(), 0xCF0),
@@ -329,8 +329,8 @@ TEST_F(Game, LoadPlugins) {
libespm::FormId("Blank - Different.esm", std::vector<std::string>(), 0xCF5),
libespm::FormId("Blank - Different.esm", std::vector<std::string>(), 0xCF6),
libespm::FormId("Blank - Different.esm", std::vector<std::string>(), 0xCF7),
}), plugin.FormIDs());
EXPECT_TRUE(plugin.Masters().empty());
}), plugin.getFormIds());
EXPECT_TRUE(plugin.getMasters().empty());
EXPECT_EQ("", plugin.Version());
EXPECT_EQ(0x64B9F757, plugin.Crc());
EXPECT_EQ(0, plugin.NumOverrideFormIDs());
@@ -339,7 +339,7 @@ TEST_F(Game, LoadPlugins) {
plugin = game.plugins.find("blank - master dependent.esm")->second;
EXPECT_EQ("Blank - Master Dependent.esm", plugin.Name());
EXPECT_FALSE(plugin.IsEmpty());
EXPECT_TRUE(plugin.IsMaster());
EXPECT_TRUE(plugin.isMasterFile());
EXPECT_EQ(std::set<libespm::FormId>({
libespm::FormId("Blank.esm", std::vector<std::string>(), 0xCF0),
libespm::FormId("Blank.esm", std::vector<std::string>(), 0xCF1),
@@ -349,10 +349,10 @@ TEST_F(Game, LoadPlugins) {
libespm::FormId("Blank - Master Dependent.esm", std::vector<std::string>(), 0xCEB),
libespm::FormId("Blank - Master Dependent.esm", std::vector<std::string>(), 0xCEC),
libespm::FormId("Blank - Master Dependent.esm", std::vector<std::string>(), 0xCED),
}), plugin.FormIDs());
}), plugin.getFormIds());
EXPECT_EQ(std::vector<std::string>({
"Blank.esm"
}), plugin.Masters());
}), plugin.getMasters());
EXPECT_EQ("", plugin.Version());
EXPECT_EQ(0xB2D4119E, plugin.Crc());
EXPECT_EQ(4, plugin.NumOverrideFormIDs());
@@ -361,7 +361,7 @@ TEST_F(Game, LoadPlugins) {
plugin = game.plugins.find("blank - different master dependent.esm")->second;
EXPECT_EQ("Blank - Different Master Dependent.esm", plugin.Name());
EXPECT_FALSE(plugin.IsEmpty());
EXPECT_TRUE(plugin.IsMaster());
EXPECT_TRUE(plugin.isMasterFile());
EXPECT_EQ(std::set<libespm::FormId>({
libespm::FormId("Blank - Different.esm", std::vector<std::string>(), 0xCEF),
libespm::FormId("Blank - Different.esm", std::vector<std::string>(), 0xCF0),
@@ -370,10 +370,10 @@ TEST_F(Game, LoadPlugins) {
libespm::FormId("Blank - Different Master Dependent.esm", std::vector<std::string>(), 0xCE9),
libespm::FormId("Blank - Different Master Dependent.esm", std::vector<std::string>(), 0xCEA),
libespm::FormId("Blank - Different Master Dependent.esm", std::vector<std::string>(), 0xCEB),
}), plugin.FormIDs());
}), plugin.getFormIds());
EXPECT_EQ(std::vector<std::string>({
"Blank - Different.esm"
}), plugin.Masters());
}), plugin.getMasters());
EXPECT_EQ("", plugin.Version());
EXPECT_EQ(0xAADF6710, plugin.Crc());
EXPECT_EQ(4, plugin.NumOverrideFormIDs());
@@ -382,7 +382,7 @@ TEST_F(Game, LoadPlugins) {
plugin = game.plugins.find("blank.esp")->second;
EXPECT_EQ("Blank.esp", plugin.Name());
EXPECT_FALSE(plugin.IsEmpty());
EXPECT_FALSE(plugin.IsMaster());
EXPECT_FALSE(plugin.isMasterFile());
EXPECT_EQ(std::set<libespm::FormId>({
libespm::FormId("Blank.esp", std::vector<std::string>(), 0xCEC),
libespm::FormId("Blank.esp", std::vector<std::string>(), 0xCED),
@@ -390,8 +390,8 @@ TEST_F(Game, LoadPlugins) {
libespm::FormId("Blank.esp", std::vector<std::string>(), 0xCEF),
libespm::FormId("Blank.esp", std::vector<std::string>(), 0xCF0),
libespm::FormId("Blank.esp", std::vector<std::string>(), 0xCF1),
}), plugin.FormIDs());
EXPECT_TRUE(plugin.Masters().empty());
}), plugin.getFormIds());
EXPECT_TRUE(plugin.getMasters().empty());
EXPECT_EQ("", plugin.Version());
EXPECT_EQ(0x24F0E2A1, plugin.Crc());
EXPECT_EQ(0, plugin.NumOverrideFormIDs());
@@ -400,15 +400,15 @@ TEST_F(Game, LoadPlugins) {
plugin = game.plugins.find("blank - different.esp")->second;
EXPECT_EQ("Blank - Different.esp", plugin.Name());
EXPECT_FALSE(plugin.IsEmpty());
EXPECT_FALSE(plugin.IsMaster());
EXPECT_FALSE(plugin.isMasterFile());
EXPECT_EQ(std::set<libespm::FormId>({
libespm::FormId("Blank - Different.esp", std::vector<std::string>(), 0xCEB),
libespm::FormId("Blank - Different.esp", std::vector<std::string>(), 0xCEC),
libespm::FormId("Blank - Different.esp", std::vector<std::string>(), 0xCED),
libespm::FormId("Blank - Different.esp", std::vector<std::string>(), 0xCEE),
libespm::FormId("Blank - Different.esp", std::vector<std::string>(), 0xCEF),
}), plugin.FormIDs());
EXPECT_TRUE(plugin.Masters().empty());
}), plugin.getFormIds());
EXPECT_TRUE(plugin.getMasters().empty());
EXPECT_EQ("", plugin.Version());
EXPECT_EQ(0xD4C9B7AE, plugin.Crc());
EXPECT_EQ(0, plugin.NumOverrideFormIDs());
@@ -417,16 +417,16 @@ TEST_F(Game, LoadPlugins) {
plugin = game.plugins.find("blank - master dependent.esp")->second;
EXPECT_EQ("Blank - Master Dependent.esp", plugin.Name());
EXPECT_FALSE(plugin.IsEmpty());
EXPECT_FALSE(plugin.IsMaster());
EXPECT_FALSE(plugin.isMasterFile());
EXPECT_EQ(std::set<libespm::FormId>({
libespm::FormId("Blank.esm", std::vector<std::string>(), 0xCF0),
libespm::FormId("Blank.esm", std::vector<std::string>(), 0xCF1),
libespm::FormId("Blank - Master Dependent.esp", std::vector<std::string>(), 0xCE9),
libespm::FormId("Blank - Master Dependent.esp", std::vector<std::string>(), 0xCEA),
}), plugin.FormIDs());
}), plugin.getFormIds());
EXPECT_EQ(std::vector<std::string>({
"Blank.esm"
}), plugin.Masters());
}), plugin.getMasters());
EXPECT_EQ("", plugin.Version());
EXPECT_EQ(0x832152DC, plugin.Crc());
EXPECT_EQ(2, plugin.NumOverrideFormIDs());
@@ -435,15 +435,15 @@ TEST_F(Game, LoadPlugins) {
plugin = game.plugins.find("blank - different master dependent.esp")->second;
EXPECT_EQ("Blank - Different Master Dependent.esp", plugin.Name());
EXPECT_FALSE(plugin.IsEmpty());
EXPECT_FALSE(plugin.IsMaster());
EXPECT_FALSE(plugin.isMasterFile());
EXPECT_EQ(std::set<libespm::FormId>({
libespm::FormId("Blank - Different.esm", std::vector<std::string>(), 0xCEF),
libespm::FormId("Blank - Different.esm", std::vector<std::string>(), 0xCF0),
libespm::FormId("Blank - Different Master Dependent.esp", std::vector<std::string>(), 0xCE7),
}), plugin.FormIDs());
}), plugin.getFormIds());
EXPECT_EQ(std::vector<std::string>({
"Blank - Different.esm"
}), plugin.Masters());
}), plugin.getMasters());
EXPECT_EQ("", plugin.Version());
EXPECT_EQ(0x3AD17683, plugin.Crc());
EXPECT_EQ(2, plugin.NumOverrideFormIDs());
@@ -452,14 +452,14 @@ TEST_F(Game, LoadPlugins) {
plugin = game.plugins.find("blank - plugin dependent.esp")->second;
EXPECT_EQ("Blank - Plugin Dependent.esp", plugin.Name());
EXPECT_FALSE(plugin.IsEmpty());
EXPECT_FALSE(plugin.IsMaster());
EXPECT_FALSE(plugin.isMasterFile());
EXPECT_EQ(std::set<libespm::FormId>({
libespm::FormId("Blank.esp", std::vector<std::string>(), 0xCEC),
libespm::FormId("Blank - Plugin Dependent.esp", std::vector<std::string>(), 0xCE7),
}), plugin.FormIDs());
}), plugin.getFormIds());
EXPECT_EQ(std::vector<std::string>({
"Blank.esp"
}), plugin.Masters());
}), plugin.getMasters());
EXPECT_EQ("", plugin.Version());
EXPECT_EQ(0x28EF26DB, plugin.Crc());
EXPECT_EQ(1, plugin.NumOverrideFormIDs());
@@ -468,13 +468,13 @@ TEST_F(Game, LoadPlugins) {
plugin = game.plugins.find("blank - different plugin dependent.esp")->second;
EXPECT_EQ("Blank - Different Plugin Dependent.esp", plugin.Name());
EXPECT_FALSE(plugin.IsEmpty());
EXPECT_FALSE(plugin.IsMaster());
EXPECT_FALSE(plugin.isMasterFile());
EXPECT_EQ(std::set<libespm::FormId>({
libespm::FormId("Blank - Different.esp", std::vector<std::string>(), 0xCEB),
}), plugin.FormIDs());
}), plugin.getFormIds());
EXPECT_EQ(std::vector<std::string>({
"Blank - Different.esp"
}), plugin.Masters());
}), plugin.getMasters());
EXPECT_EQ("", plugin.Version());
EXPECT_EQ(0xEB47BE63, plugin.Crc());
EXPECT_EQ(1, plugin.NumOverrideFormIDs());
@@ -492,9 +492,9 @@ TEST_F(Game, LoadPlugins_HeadersOnly) {
loot::Plugin plugin = game.plugins.find("skyrim.esm")->second;
EXPECT_EQ("Skyrim.esm", plugin.Name());
EXPECT_FALSE(plugin.IsEmpty());
EXPECT_TRUE(plugin.IsMaster());
EXPECT_TRUE(plugin.FormIDs().empty());
EXPECT_TRUE(plugin.Masters().empty());
EXPECT_TRUE(plugin.isMasterFile());
EXPECT_TRUE(plugin.getFormIds().empty());
EXPECT_TRUE(plugin.getMasters().empty());
EXPECT_EQ("5.0", plugin.Version());
EXPECT_EQ(0, plugin.Crc());
EXPECT_EQ(0, plugin.NumOverrideFormIDs());
@@ -503,9 +503,9 @@ TEST_F(Game, LoadPlugins_HeadersOnly) {
plugin = game.plugins.find("blank.esm")->second;
EXPECT_EQ("Blank.esm", plugin.Name());
EXPECT_FALSE(plugin.IsEmpty());
EXPECT_TRUE(plugin.IsMaster());
EXPECT_TRUE(plugin.FormIDs().empty());
EXPECT_TRUE(plugin.Masters().empty());
EXPECT_TRUE(plugin.isMasterFile());
EXPECT_TRUE(plugin.getFormIds().empty());
EXPECT_TRUE(plugin.getMasters().empty());
EXPECT_EQ("5.0", plugin.Version());
EXPECT_EQ(0, plugin.Crc());
EXPECT_EQ(0, plugin.NumOverrideFormIDs());
@@ -514,9 +514,9 @@ TEST_F(Game, LoadPlugins_HeadersOnly) {
plugin = game.plugins.find("blank - different.esm")->second;
EXPECT_EQ("Blank - Different.esm", plugin.Name());
EXPECT_FALSE(plugin.IsEmpty());
EXPECT_TRUE(plugin.IsMaster());
EXPECT_TRUE(plugin.FormIDs().empty());
EXPECT_TRUE(plugin.Masters().empty());
EXPECT_TRUE(plugin.isMasterFile());
EXPECT_TRUE(plugin.getFormIds().empty());
EXPECT_TRUE(plugin.getMasters().empty());
EXPECT_EQ("", plugin.Version());
EXPECT_EQ(0, plugin.Crc());
EXPECT_EQ(0, plugin.NumOverrideFormIDs());
@@ -525,11 +525,11 @@ TEST_F(Game, LoadPlugins_HeadersOnly) {
plugin = game.plugins.find("blank - master dependent.esm")->second;
EXPECT_EQ("Blank - Master Dependent.esm", plugin.Name());
EXPECT_FALSE(plugin.IsEmpty());
EXPECT_TRUE(plugin.IsMaster());
EXPECT_TRUE(plugin.FormIDs().empty());
EXPECT_TRUE(plugin.isMasterFile());
EXPECT_TRUE(plugin.getFormIds().empty());
EXPECT_EQ(std::vector<std::string>({
"Blank.esm"
}), plugin.Masters());
}), plugin.getMasters());
EXPECT_EQ("", plugin.Version());
EXPECT_EQ(0, plugin.Crc());
EXPECT_EQ(0, plugin.NumOverrideFormIDs());
@@ -538,11 +538,11 @@ TEST_F(Game, LoadPlugins_HeadersOnly) {
plugin = game.plugins.find("blank - different master dependent.esm")->second;
EXPECT_EQ("Blank - Different Master Dependent.esm", plugin.Name());
EXPECT_FALSE(plugin.IsEmpty());
EXPECT_TRUE(plugin.IsMaster());
EXPECT_TRUE(plugin.FormIDs().empty());
EXPECT_TRUE(plugin.isMasterFile());
EXPECT_TRUE(plugin.getFormIds().empty());
EXPECT_EQ(std::vector<std::string>({
"Blank - Different.esm"
}), plugin.Masters());
}), plugin.getMasters());
EXPECT_EQ("", plugin.Version());
EXPECT_EQ(0, plugin.Crc());
EXPECT_EQ(0, plugin.NumOverrideFormIDs());
@@ -551,9 +551,9 @@ TEST_F(Game, LoadPlugins_HeadersOnly) {
plugin = game.plugins.find("blank.esp")->second;
EXPECT_EQ("Blank.esp", plugin.Name());
EXPECT_FALSE(plugin.IsEmpty());
EXPECT_FALSE(plugin.IsMaster());
EXPECT_TRUE(plugin.FormIDs().empty());
EXPECT_TRUE(plugin.Masters().empty());
EXPECT_FALSE(plugin.isMasterFile());
EXPECT_TRUE(plugin.getFormIds().empty());
EXPECT_TRUE(plugin.getMasters().empty());
EXPECT_EQ("", plugin.Version());
EXPECT_EQ(0, plugin.Crc());
EXPECT_EQ(0, plugin.NumOverrideFormIDs());
@@ -562,9 +562,9 @@ TEST_F(Game, LoadPlugins_HeadersOnly) {
plugin = game.plugins.find("blank - different.esp")->second;
EXPECT_EQ("Blank - Different.esp", plugin.Name());
EXPECT_FALSE(plugin.IsEmpty());
EXPECT_FALSE(plugin.IsMaster());
EXPECT_TRUE(plugin.FormIDs().empty());
EXPECT_TRUE(plugin.Masters().empty());
EXPECT_FALSE(plugin.isMasterFile());
EXPECT_TRUE(plugin.getFormIds().empty());
EXPECT_TRUE(plugin.getMasters().empty());
EXPECT_EQ("", plugin.Version());
EXPECT_EQ(0, plugin.Crc());
EXPECT_EQ(0, plugin.NumOverrideFormIDs());
@@ -573,11 +573,11 @@ TEST_F(Game, LoadPlugins_HeadersOnly) {
plugin = game.plugins.find("blank - master dependent.esp")->second;
EXPECT_EQ("Blank - Master Dependent.esp", plugin.Name());
EXPECT_FALSE(plugin.IsEmpty());
EXPECT_FALSE(plugin.IsMaster());
EXPECT_TRUE(plugin.FormIDs().empty());
EXPECT_FALSE(plugin.isMasterFile());
EXPECT_TRUE(plugin.getFormIds().empty());
EXPECT_EQ(std::vector<std::string>({
"Blank.esm"
}), plugin.Masters());
}), plugin.getMasters());
EXPECT_EQ("", plugin.Version());
EXPECT_EQ(0, plugin.Crc());
EXPECT_EQ(0, plugin.NumOverrideFormIDs());
@@ -586,11 +586,11 @@ TEST_F(Game, LoadPlugins_HeadersOnly) {
plugin = game.plugins.find("blank - different master dependent.esp")->second;
EXPECT_EQ("Blank - Different Master Dependent.esp", plugin.Name());
EXPECT_FALSE(plugin.IsEmpty());
EXPECT_FALSE(plugin.IsMaster());
EXPECT_TRUE(plugin.FormIDs().empty());
EXPECT_FALSE(plugin.isMasterFile());
EXPECT_TRUE(plugin.getFormIds().empty());
EXPECT_EQ(std::vector<std::string>({
"Blank - Different.esm"
}), plugin.Masters());
}), plugin.getMasters());
EXPECT_EQ("", plugin.Version());
EXPECT_EQ(0, plugin.Crc());
EXPECT_EQ(0, plugin.NumOverrideFormIDs());
@@ -599,11 +599,11 @@ TEST_F(Game, LoadPlugins_HeadersOnly) {
plugin = game.plugins.find("blank - plugin dependent.esp")->second;
EXPECT_EQ("Blank - Plugin Dependent.esp", plugin.Name());
EXPECT_FALSE(plugin.IsEmpty());
EXPECT_FALSE(plugin.IsMaster());
EXPECT_TRUE(plugin.FormIDs().empty());
EXPECT_FALSE(plugin.isMasterFile());
EXPECT_TRUE(plugin.getFormIds().empty());
EXPECT_EQ(std::vector<std::string>({
"Blank.esp"
}), plugin.Masters());
}), plugin.getMasters());
EXPECT_EQ("", plugin.Version());
EXPECT_EQ(0, plugin.Crc());
EXPECT_EQ(0, plugin.NumOverrideFormIDs());
@@ -612,11 +612,11 @@ TEST_F(Game, LoadPlugins_HeadersOnly) {
plugin = game.plugins.find("blank - different plugin dependent.esp")->second;
EXPECT_EQ("Blank - Different Plugin Dependent.esp", plugin.Name());
EXPECT_FALSE(plugin.IsEmpty());
EXPECT_FALSE(plugin.IsMaster());
EXPECT_TRUE(plugin.FormIDs().empty());
EXPECT_FALSE(plugin.isMasterFile());
EXPECT_TRUE(plugin.getFormIds().empty());
EXPECT_EQ(std::vector<std::string>({
"Blank - Different.esp"
}), plugin.Masters());
}), plugin.getMasters());
EXPECT_EQ("", plugin.Version());
EXPECT_EQ(0, plugin.Crc());
EXPECT_EQ(0, plugin.NumOverrideFormIDs());
+12 -12
View File
@@ -33,9 +33,9 @@ class Plugin : public SkyrimTest {};
TEST_F(Plugin, ConstructorsAndDataAccess) {
loot::Plugin plugin("Blank.esm");
EXPECT_EQ("Blank.esm", plugin.Name());
EXPECT_TRUE(plugin.FormIDs().empty());
EXPECT_TRUE(plugin.Masters().empty());
EXPECT_FALSE(plugin.IsMaster());
EXPECT_TRUE(plugin.getFormIds().empty());
EXPECT_TRUE(plugin.getMasters().empty());
EXPECT_FALSE(plugin.isMasterFile());
EXPECT_TRUE(plugin.IsEmpty());
EXPECT_EQ("", plugin.Version());
EXPECT_EQ(0, plugin.Crc());
@@ -46,9 +46,9 @@ TEST_F(Plugin, ConstructorsAndDataAccess) {
plugin = loot::Plugin(game, "Blank.esm", true);
EXPECT_EQ("Blank.esm", plugin.Name());
EXPECT_TRUE(plugin.FormIDs().empty());
EXPECT_TRUE(plugin.Masters().empty());
EXPECT_TRUE(plugin.IsMaster());
EXPECT_TRUE(plugin.getFormIds().empty());
EXPECT_TRUE(plugin.getMasters().empty());
EXPECT_TRUE(plugin.isMasterFile());
EXPECT_FALSE(plugin.IsEmpty());
EXPECT_EQ("5.0", plugin.Version());
EXPECT_EQ(0, plugin.Crc());
@@ -66,9 +66,9 @@ TEST_F(Plugin, ConstructorsAndDataAccess) {
libespm::FormId("Blank.esm", std::vector<std::string>(), 0xCF7),
libespm::FormId("Blank.esm", std::vector<std::string>(), 0xCF8),
libespm::FormId("Blank.esm", std::vector<std::string>(), 0xCF9),
}), plugin.FormIDs());
EXPECT_TRUE(plugin.Masters().empty());
EXPECT_TRUE(plugin.IsMaster());
}), plugin.getFormIds());
EXPECT_TRUE(plugin.getMasters().empty());
EXPECT_TRUE(plugin.isMasterFile());
EXPECT_FALSE(plugin.IsEmpty());
EXPECT_EQ("5.0", plugin.Version());
EXPECT_EQ(0x187BE342, plugin.Crc());
@@ -76,16 +76,16 @@ TEST_F(Plugin, ConstructorsAndDataAccess) {
plugin = loot::Plugin(game, "Blank - Master Dependent.esp", false);
EXPECT_EQ("Blank - Master Dependent.esp", plugin.Name());
EXPECT_FALSE(plugin.IsEmpty());
EXPECT_FALSE(plugin.IsMaster());
EXPECT_FALSE(plugin.isMasterFile());
EXPECT_EQ(std::set<libespm::FormId>({
libespm::FormId("Blank.esm", std::vector<std::string>(), 0xCF0),
libespm::FormId("Blank.esm", std::vector<std::string>(), 0xCF1),
libespm::FormId("Blank - Master Dependent.esp", std::vector<std::string>(), 0xCE9),
libespm::FormId("Blank - Master Dependent.esp", std::vector<std::string>(), 0xCEA),
}), plugin.FormIDs());
}), plugin.getFormIds());
EXPECT_EQ(std::vector<std::string>({
"Blank.esm"
}), plugin.Masters());
}), plugin.getMasters());
EXPECT_EQ("", plugin.Version());
EXPECT_EQ(0x832152DC, plugin.Crc());
}