From 03757de83fe523ced5010fb68a961058b7082c41 Mon Sep 17 00:00:00 2001 From: Oliver Hamlet Date: Tue, 24 Nov 2015 21:16:06 +0000 Subject: [PATCH] Update libloadorder and libespm Libespm is now at v2.4.0, and libloadorder is at the latest master, so that it can be built using the same version of libespm. --- CMakeLists.txt | 6 - README.md | 2 +- scripts/install-step.travis.sh | 8 +- src/backend/game/game_settings.cpp | 11 ++ src/backend/game/game_settings.h | 3 + src/backend/metadata/formid.cpp | 67 -------- src/backend/metadata/formid.h | 54 ------ src/backend/metadata/plugin_metadata.h | 1 - src/backend/plugin/plugin.cpp | 61 +++---- src/backend/plugin/plugin.h | 9 +- src/backend/plugin/plugin_loader.cpp | 155 ------------------ src/backend/plugin/plugin_loader.h | 62 ------- src/tests/backend/game/test_game.h | 152 ++++++++--------- src/tests/backend/metadata/test_formid.h | 96 ----------- src/tests/backend/plugin/test_plugin.h | 52 +++--- src/tests/backend/plugin/test_plugin_loader.h | 148 ----------------- src/tests/main.cpp | 2 - src/tests/printers.h | 9 - 18 files changed, 159 insertions(+), 739 deletions(-) delete mode 100644 src/backend/metadata/formid.cpp delete mode 100644 src/backend/metadata/formid.h delete mode 100644 src/backend/plugin/plugin_loader.cpp delete mode 100644 src/backend/plugin/plugin_loader.h delete mode 100644 src/tests/backend/metadata/test_formid.h delete mode 100644 src/tests/backend/plugin/test_plugin_loader.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 6c1042f0..3197eefd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -92,7 +92,6 @@ find_package(GTest) set (LOOT_SRC "${CMAKE_SOURCE_DIR}/src/backend/metadata/conditional_metadata.cpp" "${CMAKE_SOURCE_DIR}/src/backend/metadata/file.cpp" - "${CMAKE_SOURCE_DIR}/src/backend/metadata/formid.cpp" "${CMAKE_SOURCE_DIR}/src/backend/metadata/location.cpp" "${CMAKE_SOURCE_DIR}/src/backend/metadata/message.cpp" "${CMAKE_SOURCE_DIR}/src/backend/metadata/message_content.cpp" @@ -106,7 +105,6 @@ set (LOOT_SRC "${CMAKE_SOURCE_DIR}/src/backend/metadata/conditional_metadata.c "${CMAKE_SOURCE_DIR}/src/backend/metadata_list.cpp" "${CMAKE_SOURCE_DIR}/src/backend/masterlist.cpp" "${CMAKE_SOURCE_DIR}/src/backend/plugin/plugin.cpp" - "${CMAKE_SOURCE_DIR}/src/backend/plugin/plugin_loader.cpp" "${CMAKE_SOURCE_DIR}/src/backend/helpers/git_helper.cpp" "${CMAKE_SOURCE_DIR}/src/backend/helpers/helpers.cpp" "${CMAKE_SOURCE_DIR}/src/backend/helpers/language.cpp" @@ -117,7 +115,6 @@ set (LOOT_SRC "${CMAKE_SOURCE_DIR}/src/backend/metadata/conditional_metadata.c set (LOOT_HEADERS "${CMAKE_SOURCE_DIR}/src/backend/metadata/condition_grammar.h" "${CMAKE_SOURCE_DIR}/src/backend/metadata/conditional_metadata.h" "${CMAKE_SOURCE_DIR}/src/backend/metadata/file.h" - "${CMAKE_SOURCE_DIR}/src/backend/metadata/formid.h" "${CMAKE_SOURCE_DIR}/src/backend/metadata/location.h" "${CMAKE_SOURCE_DIR}/src/backend/metadata/message.h" "${CMAKE_SOURCE_DIR}/src/backend/metadata/message_content.h" @@ -131,7 +128,6 @@ set (LOOT_HEADERS "${CMAKE_SOURCE_DIR}/src/backend/metadata/condition_grammar.h" "${CMAKE_SOURCE_DIR}/src/backend/metadata_list.h" "${CMAKE_SOURCE_DIR}/src/backend/masterlist.h" "${CMAKE_SOURCE_DIR}/src/backend/plugin/plugin.h" - "${CMAKE_SOURCE_DIR}/src/backend/plugin/plugin_loader.h" "${CMAKE_SOURCE_DIR}/src/backend/helpers/git_helper.h" "${CMAKE_SOURCE_DIR}/src/backend/helpers/helpers.h" "${CMAKE_SOURCE_DIR}/src/backend/helpers/language.h" @@ -190,7 +186,6 @@ set (LOOT_TESTS_HEADERS "${CMAKE_SOURCE_DIR}/src/tests/fixtures.h" "${CMAKE_SOURCE_DIR}/src/tests/backend/metadata/test_condition_grammar.h" "${CMAKE_SOURCE_DIR}/src/tests/backend/metadata/test_conditional_metadata.h" "${CMAKE_SOURCE_DIR}/src/tests/backend/metadata/test_file.h" - "${CMAKE_SOURCE_DIR}/src/tests/backend/metadata/test_formid.h" "${CMAKE_SOURCE_DIR}/src/tests/backend/metadata/test_location.h" "${CMAKE_SOURCE_DIR}/src/tests/backend/metadata/test_message.h" "${CMAKE_SOURCE_DIR}/src/tests/backend/metadata/test_message_content.h" @@ -198,7 +193,6 @@ set (LOOT_TESTS_HEADERS "${CMAKE_SOURCE_DIR}/src/tests/fixtures.h" "${CMAKE_SOURCE_DIR}/src/tests/backend/metadata/test_plugin_metadata.h" "${CMAKE_SOURCE_DIR}/src/tests/backend/metadata/test_tag.h" "${CMAKE_SOURCE_DIR}/src/tests/backend/plugin/test_plugin.h" - "${CMAKE_SOURCE_DIR}/src/tests/backend/plugin/test_plugin_loader.h" "${CMAKE_SOURCE_DIR}/src/tests/backend/test_metadata_list.h" "${CMAKE_SOURCE_DIR}/src/tests/backend/test_masterlist.h" "${CMAKE_SOURCE_DIR}/src/tests/backend/test_plugin_sorter.h") diff --git a/README.md b/README.md index 748a9bab..8c5c632c 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,7 @@ LOOT requires the following C/C++ libraries (version numbers used in latest deve * [Boost](http://www.boost.org) v1.59.0 * [Chromium Embedded Framework](https://bitbucket.org/chromiumembedded/cef) branch 2454: Required to build the GUI, but not the API or tests. * [Google Test](https://github.com/google/googletest) v1.7: Required to build the tests, but not the API or the GUI. -* [Libespm](http://github.com/WrinklyNinja/libespm) v1.0.0 +* [Libespm](http://github.com/WrinklyNinja/libespm) v2.4.0 * [Libgit2](http://libgit2.github.com/) v0.23.3 * [Libloadorder](http://github.com/WrinklyNinja/libloadorder) revision 50342d7 * [Pseudosem](http://github.com/WrinklyNinja/pseudosem): v1.0.1 diff --git a/scripts/install-step.travis.sh b/scripts/install-step.travis.sh index cd7fbd66..57a175b8 100644 --- a/scripts/install-step.travis.sh +++ b/scripts/install-step.travis.sh @@ -8,8 +8,8 @@ wget -P build https://raw.githubusercontent.com/rpavlik/cmake-modules/master/Get cd ../.. # Install libespm. -wget https://github.com/WrinklyNinja/libespm/archive/1.0.0.tar.gz -O - | tar -xz -mv libespm-1.0.0 libespm +wget https://github.com/WrinklyNinja/libespm/archive/2.4.0.tar.gz -O - | tar -xz +mv libespm-2.4.0 libespm # Build yaml-cpp wget https://github.com/WrinklyNinja/yaml-cpp/archive/patched-for-loot.tar.gz -O - | tar -xz @@ -28,8 +28,8 @@ make git2 cd ../.. # Build libloadorder -wget https://github.com/WrinklyNinja/libloadorder/archive/50342d7298f27a6a4366175119bd17aaf09000c7.tar.gz -O - | tar -xz -mv libloadorder-50342d7298f27a6a4366175119bd17aaf09000c7 libloadorder +wget https://github.com/WrinklyNinja/libloadorder/archive/e1ea3c8ceb741f4eae39ae6320e8f37f778bc335.tar.gz -O - | tar -xz +mv libloadorder-e1ea3c8ceb741f4eae39ae6320e8f37f778bc335 libloadorder mkdir libloadorder/build && cd libloadorder/build cmake .. -DPROJECT_ARCH=64 -DPROJECT_STATIC_RUNTIME=OFF -DBUILD_SHARED_LIBS=OFF -DGTEST_ROOT=../gtest-1.7.0 make loadorder64 diff --git a/src/backend/game/game_settings.cpp b/src/backend/game/game_settings.cpp index 0c95ddcf..fce082a1 100644 --- a/src/backend/game/game_settings.cpp +++ b/src/backend/game/game_settings.cpp @@ -120,6 +120,17 @@ namespace loot { return _id; } + libespm::GameId GameSettings::LibespmId() const { + if (_id == GameSettings::tes4) + return libespm::GameId::OBLIVION; + else if (_id == GameSettings::tes5) + return libespm::GameId::SKYRIM; + else if (_id == GameSettings::fo3) + return libespm::GameId::FALLOUT3; + else + return libespm::GameId::FALLOUTNV; + } + string GameSettings::Name() const { return _name; } diff --git a/src/backend/game/game_settings.h b/src/backend/game/game_settings.h index a5189ede..635f71fa 100644 --- a/src/backend/game/game_settings.h +++ b/src/backend/game/game_settings.h @@ -32,6 +32,8 @@ #include +#include + namespace loot { class GameSettings { public: @@ -44,6 +46,7 @@ namespace loot { bool operator == (const GameSettings& rhs) const; //Compares names and folder names. unsigned int Id() const; + libespm::GameId LibespmId() const; std::string Name() const; //Returns the game's name, eg. "TES IV: Oblivion". std::string FolderName() const; std::string Master() const; diff --git a/src/backend/metadata/formid.cpp b/src/backend/metadata/formid.cpp deleted file mode 100644 index 50f623fc..00000000 --- a/src/backend/metadata/formid.cpp +++ /dev/null @@ -1,67 +0,0 @@ -/* LOOT - - A load order optimisation tool for Oblivion, Skyrim, Fallout 3 and - Fallout: New Vegas. - - Copyright (C) 2012-2015 WrinklyNinja - - This file is part of LOOT. - - LOOT is free software: you can redistribute - it and/or modify it under the terms of the GNU General Public License - as published by the Free Software Foundation, either version 3 of - the License, or (at your option) any later version. - - LOOT is distributed in the hope that it will - be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with LOOT. If not, see - . - */ - -#include "formid.h" - -#include -#include - -using namespace std; - -namespace loot { - FormID::FormID() : id(0) {} - - FormID::FormID(const std::string& sourcePlugin, const uint32_t objectID) : plugin(sourcePlugin), id(objectID) {} - - FormID::FormID(const std::vector& sourcePlugins, const uint32_t formID) { - unsigned int index = formID >> 24; - id = formID & ~((uint32_t)index << 24); - - if (index >= sourcePlugins.size()) { - BOOST_LOG_TRIVIAL(trace) << hex << formID << dec << " in " << sourcePlugins.back() << " has a higher modIndex than expected."; - index = sourcePlugins.size() - 1; - } - - plugin = sourcePlugins[index]; - } - - bool FormID::operator == (const FormID& rhs) const { - return (id == rhs.Id() && boost::iequals(plugin, rhs.Plugin())); - } - - bool FormID::operator < (const FormID& rhs) const { - if (id != rhs.Id()) - return id < rhs.Id(); - else - return boost::ilexicographical_compare(plugin, rhs.Plugin()); - } - - std::string FormID::Plugin() const { - return plugin; - } - - uint32_t FormID::Id() const { - return id; - } -} diff --git a/src/backend/metadata/formid.h b/src/backend/metadata/formid.h deleted file mode 100644 index c4621735..00000000 --- a/src/backend/metadata/formid.h +++ /dev/null @@ -1,54 +0,0 @@ -/* LOOT - - A load order optimisation tool for Oblivion, Skyrim, Fallout 3 and - Fallout: New Vegas. - - Copyright (C) 2012-2015 WrinklyNinja - - This file is part of LOOT. - - LOOT is free software: you can redistribute - it and/or modify it under the terms of the GNU General Public License - as published by the Free Software Foundation, either version 3 of - the License, or (at your option) any later version. - - LOOT is distributed in the hope that it will - be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with LOOT. If not, see - . - */ -#ifndef __LOOT_METADATA_FORMID__ -#define __LOOT_METADATA_FORMID__ - -#include -#include -#include - -namespace loot { - // A FormID is a 32 bit unsigned integer of the form xxYYYYYY in hex. - // The xx is the position in the masters list of the plugin that the FormID - // is from, and the YYYYYY is the rest of the FormID. Here the xx bit is - // stored as the corresponding filename to allow comparison between FormIDs - // from different plugins. - class FormID { - public: - FormID(); - FormID(const std::string& pluginName, const uint32_t objectID); - FormID(const std::vector& masters, const uint32_t formID); //The masters here also includes the plugin that they are masters of as the last element. - - bool operator < (const FormID& rhs) const; - bool operator == (const FormID& rhs) const; - - std::string Plugin() const; - uint32_t Id() const; - private: - std::string plugin; - uint32_t id; - }; -} - -#endif diff --git a/src/backend/metadata/plugin_metadata.h b/src/backend/metadata/plugin_metadata.h index b9f69e94..ff74571b 100644 --- a/src/backend/metadata/plugin_metadata.h +++ b/src/backend/metadata/plugin_metadata.h @@ -25,7 +25,6 @@ #define __LOOT_METADATA_PLUGIN_METADATA__ #include "file.h" -#include "formid.h" #include "location.h" #include "message.h" #include "plugin_dirty_info.h" diff --git a/src/backend/plugin/plugin.cpp b/src/backend/plugin/plugin.cpp index 3b559f15..6a9ac204 100644 --- a/src/backend/plugin/plugin.cpp +++ b/src/backend/plugin/plugin.cpp @@ -23,7 +23,6 @@ */ #include "plugin.h" -#include "plugin_loader.h" #include "../game/game.h" #include "../helpers/helpers.h" @@ -34,7 +33,10 @@ #include #include +#include + using namespace std; +using libespm::FormId; namespace loot { /// REGEX expression definition @@ -97,27 +99,34 @@ namespace loot { Plugin::Plugin(loot::Game& game, const std::string& n, const bool headerOnly) : PluginMetadata(n), _isEmpty(true), isMaster(false), crc(0), numOverrideRecords(0) { try { - PluginLoader loader; - loader.Load(game, name, headerOnly, false); - isMaster = loader.IsMaster(); - masters = loader.Masters(); - _isEmpty = loader.IsEmpty(); - formIDs = loader.FormIDs(); + 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); + + isMaster = plugin.isMasterFile(); + masters = plugin.getMasters(); + formIDs = plugin.getFormIds(); + _isEmpty = plugin.getRecordAndGroupCount() == 0; if (!headerOnly) { BOOST_LOG_TRIVIAL(trace) << name << ": Caching CRC value."; - crc = loader.Crc(); + crc = GetCrc32(filepath); game.CacheCrc(name, crc); } BOOST_LOG_TRIVIAL(trace) << name << ": Counting override FormIDs."; for (const auto& formID : formIDs) { - if (!boost::iequals(formID.Plugin(), name)) + if (!boost::iequals(formID.getPluginName(), name)) ++numOverrideRecords; } //Also read Bash Tags applied and version string in description. - string text = loader.Description(); + string text = plugin.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; @@ -165,7 +174,7 @@ namespace loot { return !(*this == rhs); } - const std::set& Plugin::FormIDs() const { + const std::set& Plugin::FormIDs() const { return formIDs; } @@ -173,7 +182,7 @@ namespace loot { //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::const_iterator i = formIDs.begin(), + set::const_iterator i = formIDs.begin(), j = plugin.FormIDs().begin(), iend = formIDs.end(), jend = plugin.FormIDs().end(); @@ -194,9 +203,9 @@ namespace loot { return numOverrideRecords; } - std::set Plugin::OverlapFormIDs(const Plugin& plugin) const { - set otherFormIDs = plugin.FormIDs(); - set overlap; + std::set Plugin::OverlapFormIDs(const Plugin& plugin) const { + set otherFormIDs = plugin.FormIDs(); + set overlap; set_intersection(formIDs.begin(), formIDs.end(), otherFormIDs.begin(), otherFormIDs.end(), inserter(overlap, overlap.end())); @@ -217,21 +226,17 @@ namespace loot { bool Plugin::IsValid(const Game& game) const { BOOST_LOG_TRIVIAL(trace) << "Checking to see if \"" << name << "\" is a valid plugin."; - // Rather than just checking the extension, try also parsing the file header, and see if it fails. - if (!boost::iends_with(name, ".esm") && !boost::iends_with(name, ".esp")) { - return false; - } + boost::filesystem::path filepath = game.DataPath() / name; - try { - PluginLoader loader; - loader.Load(game, name, true, true); + // In case the plugin is ghosted. + if (!boost::filesystem::exists(filepath) && boost::filesystem::exists(filepath.string() + ".ghost")) + filepath += ".ghost"; + + if (libespm::Plugin::isValid(filepath, game.LibespmId(), true)) return true; - } - catch (std::exception& /*e*/) { - BOOST_LOG_TRIVIAL(warning) << "The .es(p|m) file \"" << name << "\" is not a valid plugin."; - return false; - } - return true; + + BOOST_LOG_TRIVIAL(warning) << "The .es(p|m) file \"" << name << "\" is not a valid plugin."; + return false; } bool Plugin::IsActive(const Game& game) const { diff --git a/src/backend/plugin/plugin.h b/src/backend/plugin/plugin.h index 0118c65e..10e46792 100644 --- a/src/backend/plugin/plugin.h +++ b/src/backend/plugin/plugin.h @@ -24,7 +24,6 @@ #ifndef __LOOT_PLUGIN__ #define __LOOT_PLUGIN__ -#include "../metadata/formid.h" #include "../metadata/plugin_metadata.h" #include @@ -35,6 +34,8 @@ #include +#include + namespace loot { class Game; @@ -44,7 +45,7 @@ namespace loot { Plugin(const std::string& name); Plugin(Game& game, const std::string& name, const bool headerOnly); - const std::set& FormIDs() const; + const std::set& FormIDs() const; std::vector Masters() const; bool IsMaster() const; //Checks master bit flag. bool IsEmpty() const; @@ -62,14 +63,14 @@ namespace loot { //Load ordering functions. bool DoFormIDsOverlap(const Plugin& plugin) const; - std::set OverlapFormIDs(const Plugin& plugin) const; + std::set OverlapFormIDs(const Plugin& plugin) const; //Validity checks. bool CheckInstallValidity(const Game& game); //Checks that reqs and masters are all present, and that no incs are present. Returns true if the plugin is dirty. private: bool _isEmpty; // Does the plugin contain any records other than the TES4 header? std::vector masters; - std::set formIDs; + std::set formIDs; std::string version; //Obtained from description field. bool isMaster; uint32_t crc; diff --git a/src/backend/plugin/plugin_loader.cpp b/src/backend/plugin/plugin_loader.cpp deleted file mode 100644 index f6ac5b01..00000000 --- a/src/backend/plugin/plugin_loader.cpp +++ /dev/null @@ -1,155 +0,0 @@ -/* LOOT - - A load order optimisation tool for Oblivion, Skyrim, Fallout 3 and - Fallout: New Vegas. - - Copyright (C) 2012-2015 WrinklyNinja - - This file is part of LOOT. - - LOOT is free software: you can redistribute - it and/or modify it under the terms of the GNU General Public License - as published by the Free Software Foundation, either version 3 of - the License, or (at your option) any later version. - - LOOT is distributed in the hope that it will - be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with LOOT. If not, see - . - */ - -#include "plugin_loader.h" -#include "../game/game.h" -#include "../helpers/helpers.h" - -#include - -#include -#include -#include -#include - -using namespace std; - -namespace loot { - PluginLoader::PluginLoader() : _isEmpty(true), _isMaster(false), _crc(0) {} - - void PluginLoader::Load(const Game& game, - const std::string& name, - const bool headerOnly, - const bool checkValidityOnly) { - espm::File * file = nullptr; - espm::Settings espmSettings; - - // Clear existing data. - _isEmpty = true; - _isMaster = false; - _formIDs.clear(); - _masters.clear(); - _description.clear(); - _crc = 0; - - // Get data from file contents using libespm. - BOOST_LOG_TRIVIAL(trace) << name << ": " << "Opening with libespm..."; - 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"; - - try { - if (game.Id() == Game::tes4) { - espmSettings = espm::Settings("tes4"); - file = new espm::tes4::File(filepath, espmSettings, false, headerOnly); - } - else if (game.Id() == Game::tes5) { - espmSettings = espm::Settings("tes5"); - file = new espm::tes5::File(filepath, espmSettings, false, headerOnly); - } - else if (game.Id() == Game::fo3) { - espmSettings = espm::Settings("fo3"); - file = new espm::fo3::File(filepath, espmSettings, false, headerOnly); - } - else { - espmSettings = espm::Settings("fonv"); - file = new espm::fonv::File(filepath, espmSettings, false, headerOnly); - } - - // If only wanting to test for valid parsing, quit now. - if (checkValidityOnly) { - delete file; - return; - } - - BOOST_LOG_TRIVIAL(trace) << filepath.filename().string() << ": " << "Checking master flag."; - _isMaster = file->isMaster(espmSettings); - - BOOST_LOG_TRIVIAL(trace) << filepath.filename().string() << ": " << "Getting masters."; - for (const auto& master : file->getMasters()) { - _masters.push_back(boost::locale::conv::to_utf(master, "Windows-1252", boost::locale::conv::stop)); - } - - BOOST_LOG_TRIVIAL(trace) << filepath.filename().string() << ": " << "Number of masters: " << _masters.size(); - - if (!headerOnly) { - BOOST_LOG_TRIVIAL(trace) << filepath.filename().string() << ": " << "Getting CRC."; - _crc = file->crc; - } - - BOOST_LOG_TRIVIAL(trace) << name << ": " << "Getting the FormIDs."; - vector records = file->getFormIDs(); - vector plugins = _masters; - plugins.push_back(name); - for (const auto &record : records) { - _formIDs.insert(FormID(plugins, record)); - } - - BOOST_LOG_TRIVIAL(trace) << name << ": " << "Checking if plugin is empty."; - if (headerOnly) { - // Check the header records count. - _isEmpty = file->getNumRecords() == 0; - } - else { - _isEmpty = _formIDs.empty(); - } - - //Also read Bash Tags applied and version string in description. - BOOST_LOG_TRIVIAL(trace) << name << ": " << "Reading the description."; - _description = boost::locale::conv::to_utf(file->getDescription(), "Windows-1252", boost::locale::conv::stop); - } - catch (std::exception&) { - delete file; - throw; - } - - BOOST_LOG_TRIVIAL(trace) << name << ": " << "Plugin loading complete."; - } - - bool PluginLoader::IsEmpty() const { - return _isEmpty; - } - - bool PluginLoader::IsMaster() const { - return _isMaster; - } - - const std::set& PluginLoader::FormIDs() const { - return _formIDs; - } - - std::vector PluginLoader::Masters() const { - return _masters; - } - - std::string PluginLoader::Description() const { - return _description; - } - - uint32_t PluginLoader::Crc() const { - return _crc; - } -} diff --git a/src/backend/plugin/plugin_loader.h b/src/backend/plugin/plugin_loader.h deleted file mode 100644 index 99082d05..00000000 --- a/src/backend/plugin/plugin_loader.h +++ /dev/null @@ -1,62 +0,0 @@ -/* LOOT - - A load order optimisation tool for Oblivion, Skyrim, Fallout 3 and - Fallout: New Vegas. - - Copyright (C) 2012-2015 WrinklyNinja - - This file is part of LOOT. - - LOOT is free software: you can redistribute - it and/or modify it under the terms of the GNU General Public License - as published by the Free Software Foundation, either version 3 of - the License, or (at your option) any later version. - - LOOT is distributed in the hope that it will - be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with LOOT. If not, see - . - */ -#ifndef __LOOT_PLUGIN_LOADER__ -#define __LOOT_PLUGIN_LOADER__ - -#include "../metadata/formid.h" - -#include -#include -#include -#include - -namespace loot { - class Game; - - class PluginLoader { - public: - PluginLoader(); - - void Load(const Game& game, - const std::string& name, - const bool headerOnly, - const bool checkValidityOnly); - - bool IsEmpty() const; - bool IsMaster() const; //Checks master bit flag. - const std::set& FormIDs() const; - std::vector Masters() const; - std::string Description() const; - uint32_t Crc() const; - private: - bool _isEmpty; - bool _isMaster; - std::set _formIDs; - std::vector _masters; - std::string _description; - uint32_t _crc; - }; -} - -#endif diff --git a/src/tests/backend/game/test_game.h b/src/tests/backend/game/test_game.h index a3b52760..6b653de9 100644 --- a/src/tests/backend/game/test_game.h +++ b/src/tests/backend/game/test_game.h @@ -275,17 +275,17 @@ TEST_F(Game, LoadPlugins) { EXPECT_EQ("Skyrim.esm", plugin.Name()); EXPECT_FALSE(plugin.IsEmpty()); EXPECT_TRUE(plugin.IsMaster()); - EXPECT_EQ(std::set({ - loot::FormID("Skyrim.esm", 0xCF0), - loot::FormID("Skyrim.esm", 0xCF1), - loot::FormID("Skyrim.esm", 0xCF2), - loot::FormID("Skyrim.esm", 0xCF3), - loot::FormID("Skyrim.esm", 0xCF4), - loot::FormID("Skyrim.esm", 0xCF5), - loot::FormID("Skyrim.esm", 0xCF6), - loot::FormID("Skyrim.esm", 0xCF7), - loot::FormID("Skyrim.esm", 0xCF8), - loot::FormID("Skyrim.esm", 0xCF9), + EXPECT_EQ(std::set({ + libespm::FormId("Skyrim.esm", std::vector(), 0xCF0), + libespm::FormId("Skyrim.esm", std::vector(), 0xCF1), + libespm::FormId("Skyrim.esm", std::vector(), 0xCF2), + libespm::FormId("Skyrim.esm", std::vector(), 0xCF3), + libespm::FormId("Skyrim.esm", std::vector(), 0xCF4), + libespm::FormId("Skyrim.esm", std::vector(), 0xCF5), + libespm::FormId("Skyrim.esm", std::vector(), 0xCF6), + libespm::FormId("Skyrim.esm", std::vector(), 0xCF7), + libespm::FormId("Skyrim.esm", std::vector(), 0xCF8), + libespm::FormId("Skyrim.esm", std::vector(), 0xCF9), }), plugin.FormIDs()); EXPECT_TRUE(plugin.Masters().empty()); EXPECT_EQ("5.0", plugin.Version()); @@ -297,17 +297,17 @@ TEST_F(Game, LoadPlugins) { EXPECT_EQ("Blank.esm", plugin.Name()); EXPECT_FALSE(plugin.IsEmpty()); EXPECT_TRUE(plugin.IsMaster()); - EXPECT_EQ(std::set({ - loot::FormID("Blank.esm", 0xCF0), - loot::FormID("Blank.esm", 0xCF1), - loot::FormID("Blank.esm", 0xCF2), - loot::FormID("Blank.esm", 0xCF3), - loot::FormID("Blank.esm", 0xCF4), - loot::FormID("Blank.esm", 0xCF5), - loot::FormID("Blank.esm", 0xCF6), - loot::FormID("Blank.esm", 0xCF7), - loot::FormID("Blank.esm", 0xCF8), - loot::FormID("Blank.esm", 0xCF9), + EXPECT_EQ(std::set({ + libespm::FormId("Blank.esm", std::vector(), 0xCF0), + libespm::FormId("Blank.esm", std::vector(), 0xCF1), + libespm::FormId("Blank.esm", std::vector(), 0xCF2), + libespm::FormId("Blank.esm", std::vector(), 0xCF3), + libespm::FormId("Blank.esm", std::vector(), 0xCF4), + libespm::FormId("Blank.esm", std::vector(), 0xCF5), + libespm::FormId("Blank.esm", std::vector(), 0xCF6), + libespm::FormId("Blank.esm", std::vector(), 0xCF7), + libespm::FormId("Blank.esm", std::vector(), 0xCF8), + libespm::FormId("Blank.esm", std::vector(), 0xCF9), }), plugin.FormIDs()); EXPECT_TRUE(plugin.Masters().empty()); EXPECT_EQ("5.0", plugin.Version()); @@ -319,16 +319,16 @@ TEST_F(Game, LoadPlugins) { EXPECT_EQ("Blank - Different.esm", plugin.Name()); EXPECT_FALSE(plugin.IsEmpty()); EXPECT_TRUE(plugin.IsMaster()); - EXPECT_EQ(std::set({ - loot::FormID("Blank - Different.esm", 0xCEF), - loot::FormID("Blank - Different.esm", 0xCF0), - loot::FormID("Blank - Different.esm", 0xCF1), - loot::FormID("Blank - Different.esm", 0xCF2), - loot::FormID("Blank - Different.esm", 0xCF3), - loot::FormID("Blank - Different.esm", 0xCF4), - loot::FormID("Blank - Different.esm", 0xCF5), - loot::FormID("Blank - Different.esm", 0xCF6), - loot::FormID("Blank - Different.esm", 0xCF7), + EXPECT_EQ(std::set({ + libespm::FormId("Blank - Different.esm", std::vector(), 0xCEF), + libespm::FormId("Blank - Different.esm", std::vector(), 0xCF0), + libespm::FormId("Blank - Different.esm", std::vector(), 0xCF1), + libespm::FormId("Blank - Different.esm", std::vector(), 0xCF2), + libespm::FormId("Blank - Different.esm", std::vector(), 0xCF3), + libespm::FormId("Blank - Different.esm", std::vector(), 0xCF4), + libespm::FormId("Blank - Different.esm", std::vector(), 0xCF5), + libespm::FormId("Blank - Different.esm", std::vector(), 0xCF6), + libespm::FormId("Blank - Different.esm", std::vector(), 0xCF7), }), plugin.FormIDs()); EXPECT_TRUE(plugin.Masters().empty()); EXPECT_EQ("", plugin.Version()); @@ -340,15 +340,15 @@ TEST_F(Game, LoadPlugins) { EXPECT_EQ("Blank - Master Dependent.esm", plugin.Name()); EXPECT_FALSE(plugin.IsEmpty()); EXPECT_TRUE(plugin.IsMaster()); - EXPECT_EQ(std::set({ - loot::FormID("Blank.esm", 0xCF0), - loot::FormID("Blank.esm", 0xCF1), - loot::FormID("Blank.esm", 0xCF2), - loot::FormID("Blank.esm", 0xCF3), - loot::FormID("Blank - Master Dependent.esm", 0xCEA), - loot::FormID("Blank - Master Dependent.esm", 0xCEB), - loot::FormID("Blank - Master Dependent.esm", 0xCEC), - loot::FormID("Blank - Master Dependent.esm", 0xCED), + EXPECT_EQ(std::set({ + libespm::FormId("Blank.esm", std::vector(), 0xCF0), + libespm::FormId("Blank.esm", std::vector(), 0xCF1), + libespm::FormId("Blank.esm", std::vector(), 0xCF2), + libespm::FormId("Blank.esm", std::vector(), 0xCF3), + libespm::FormId("Blank - Master Dependent.esm", std::vector(), 0xCEA), + libespm::FormId("Blank - Master Dependent.esm", std::vector(), 0xCEB), + libespm::FormId("Blank - Master Dependent.esm", std::vector(), 0xCEC), + libespm::FormId("Blank - Master Dependent.esm", std::vector(), 0xCED), }), plugin.FormIDs()); EXPECT_EQ(std::vector({ "Blank.esm" @@ -362,14 +362,14 @@ TEST_F(Game, LoadPlugins) { EXPECT_EQ("Blank - Different Master Dependent.esm", plugin.Name()); EXPECT_FALSE(plugin.IsEmpty()); EXPECT_TRUE(plugin.IsMaster()); - EXPECT_EQ(std::set({ - loot::FormID("Blank - Different.esm", 0xCEF), - loot::FormID("Blank - Different.esm", 0xCF0), - loot::FormID("Blank - Different.esm", 0xCF1), - loot::FormID("Blank - Different.esm", 0xCF2), - loot::FormID("Blank - Different Master Dependent.esm", 0xCE9), - loot::FormID("Blank - Different Master Dependent.esm", 0xCEA), - loot::FormID("Blank - Different Master Dependent.esm", 0xCEB), + EXPECT_EQ(std::set({ + libespm::FormId("Blank - Different.esm", std::vector(), 0xCEF), + libespm::FormId("Blank - Different.esm", std::vector(), 0xCF0), + libespm::FormId("Blank - Different.esm", std::vector(), 0xCF1), + libespm::FormId("Blank - Different.esm", std::vector(), 0xCF2), + libespm::FormId("Blank - Different Master Dependent.esm", std::vector(), 0xCE9), + libespm::FormId("Blank - Different Master Dependent.esm", std::vector(), 0xCEA), + libespm::FormId("Blank - Different Master Dependent.esm", std::vector(), 0xCEB), }), plugin.FormIDs()); EXPECT_EQ(std::vector({ "Blank - Different.esm" @@ -383,13 +383,13 @@ TEST_F(Game, LoadPlugins) { EXPECT_EQ("Blank.esp", plugin.Name()); EXPECT_FALSE(plugin.IsEmpty()); EXPECT_FALSE(plugin.IsMaster()); - EXPECT_EQ(std::set({ - loot::FormID("Blank.esp", 0xCEC), - loot::FormID("Blank.esp", 0xCED), - loot::FormID("Blank.esp", 0xCEE), - loot::FormID("Blank.esp", 0xCEF), - loot::FormID("Blank.esp", 0xCF0), - loot::FormID("Blank.esp", 0xCF1), + EXPECT_EQ(std::set({ + libespm::FormId("Blank.esp", std::vector(), 0xCEC), + libespm::FormId("Blank.esp", std::vector(), 0xCED), + libespm::FormId("Blank.esp", std::vector(), 0xCEE), + libespm::FormId("Blank.esp", std::vector(), 0xCEF), + libespm::FormId("Blank.esp", std::vector(), 0xCF0), + libespm::FormId("Blank.esp", std::vector(), 0xCF1), }), plugin.FormIDs()); EXPECT_TRUE(plugin.Masters().empty()); EXPECT_EQ("", plugin.Version()); @@ -401,12 +401,12 @@ TEST_F(Game, LoadPlugins) { EXPECT_EQ("Blank - Different.esp", plugin.Name()); EXPECT_FALSE(plugin.IsEmpty()); EXPECT_FALSE(plugin.IsMaster()); - EXPECT_EQ(std::set({ - loot::FormID("Blank - Different.esp", 0xCEB), - loot::FormID("Blank - Different.esp", 0xCEC), - loot::FormID("Blank - Different.esp", 0xCED), - loot::FormID("Blank - Different.esp", 0xCEE), - loot::FormID("Blank - Different.esp", 0xCEF), + EXPECT_EQ(std::set({ + libespm::FormId("Blank - Different.esp", std::vector(), 0xCEB), + libespm::FormId("Blank - Different.esp", std::vector(), 0xCEC), + libespm::FormId("Blank - Different.esp", std::vector(), 0xCED), + libespm::FormId("Blank - Different.esp", std::vector(), 0xCEE), + libespm::FormId("Blank - Different.esp", std::vector(), 0xCEF), }), plugin.FormIDs()); EXPECT_TRUE(plugin.Masters().empty()); EXPECT_EQ("", plugin.Version()); @@ -418,11 +418,11 @@ TEST_F(Game, LoadPlugins) { EXPECT_EQ("Blank - Master Dependent.esp", plugin.Name()); EXPECT_FALSE(plugin.IsEmpty()); EXPECT_FALSE(plugin.IsMaster()); - EXPECT_EQ(std::set({ - loot::FormID("Blank.esm", 0xCF0), - loot::FormID("Blank.esm", 0xCF1), - loot::FormID("Blank - Master Dependent.esp", 0xCE9), - loot::FormID("Blank - Master Dependent.esp", 0xCEA), + EXPECT_EQ(std::set({ + libespm::FormId("Blank.esm", std::vector(), 0xCF0), + libespm::FormId("Blank.esm", std::vector(), 0xCF1), + libespm::FormId("Blank - Master Dependent.esp", std::vector(), 0xCE9), + libespm::FormId("Blank - Master Dependent.esp", std::vector(), 0xCEA), }), plugin.FormIDs()); EXPECT_EQ(std::vector({ "Blank.esm" @@ -436,10 +436,10 @@ TEST_F(Game, LoadPlugins) { EXPECT_EQ("Blank - Different Master Dependent.esp", plugin.Name()); EXPECT_FALSE(plugin.IsEmpty()); EXPECT_FALSE(plugin.IsMaster()); - EXPECT_EQ(std::set({ - loot::FormID("Blank - Different.esm", 0xCEF), - loot::FormID("Blank - Different.esm", 0xCF0), - loot::FormID("Blank - Different Master Dependent.esp", 0xCE7), + EXPECT_EQ(std::set({ + libespm::FormId("Blank - Different.esm", std::vector(), 0xCEF), + libespm::FormId("Blank - Different.esm", std::vector(), 0xCF0), + libespm::FormId("Blank - Different Master Dependent.esp", std::vector(), 0xCE7), }), plugin.FormIDs()); EXPECT_EQ(std::vector({ "Blank - Different.esm" @@ -453,9 +453,9 @@ TEST_F(Game, LoadPlugins) { EXPECT_EQ("Blank - Plugin Dependent.esp", plugin.Name()); EXPECT_FALSE(plugin.IsEmpty()); EXPECT_FALSE(plugin.IsMaster()); - EXPECT_EQ(std::set({ - loot::FormID("Blank.esp", 0xCEC), - loot::FormID("Blank - Plugin Dependent.esp", 0xCE7), + EXPECT_EQ(std::set({ + libespm::FormId("Blank.esp", std::vector(), 0xCEC), + libespm::FormId("Blank - Plugin Dependent.esp", std::vector(), 0xCE7), }), plugin.FormIDs()); EXPECT_EQ(std::vector({ "Blank.esp" @@ -469,8 +469,8 @@ TEST_F(Game, LoadPlugins) { EXPECT_EQ("Blank - Different Plugin Dependent.esp", plugin.Name()); EXPECT_FALSE(plugin.IsEmpty()); EXPECT_FALSE(plugin.IsMaster()); - EXPECT_EQ(std::set({ - loot::FormID("Blank - Different.esp", 0xCEB), + EXPECT_EQ(std::set({ + libespm::FormId("Blank - Different.esp", std::vector(), 0xCEB), }), plugin.FormIDs()); EXPECT_EQ(std::vector({ "Blank - Different.esp" diff --git a/src/tests/backend/metadata/test_formid.h b/src/tests/backend/metadata/test_formid.h deleted file mode 100644 index 9a4b05ab..00000000 --- a/src/tests/backend/metadata/test_formid.h +++ /dev/null @@ -1,96 +0,0 @@ -/* LOOT - -A load order optimisation tool for Oblivion, Skyrim, Fallout 3 and -Fallout: New Vegas. - -Copyright (C) 2014-2015 WrinklyNinja - -This file is part of LOOT. - -LOOT is free software: you can redistribute -it and/or modify it under the terms of the GNU General Public License -as published by the Free Software Foundation, either version 3 of -the License, or (at your option) any later version. - -LOOT is distributed in the hope that it will -be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with LOOT. If not, see -. -*/ - -#ifndef LOOT_TEST_BACKEND_METADATA_FORMID -#define LOOT_TEST_BACKEND_METADATA_FORMID - -#include "backend/metadata/formid.h" -#include "tests/fixtures.h" - -using loot::FormID; - -TEST(FormID, ConstructorsAndDataAccess) { - FormID fid; - - EXPECT_EQ("", fid.Plugin()); - EXPECT_EQ(0, fid.Id()); - - fid = FormID("plugin.esp", 1); - EXPECT_EQ("plugin.esp", fid.Plugin()); - EXPECT_EQ(1, fid.Id()); - - std::vector masters = { - "master1.esp", - "master2.esp", - "plugin.esp" - }; - fid = FormID(masters, 0x01000001); - EXPECT_EQ("master2.esp", fid.Plugin()); - EXPECT_EQ(1, fid.Id()); - - fid = FormID(masters, 0x0F000001); - EXPECT_EQ("plugin.esp", fid.Plugin()); - EXPECT_EQ(1, fid.Id()); -} - -TEST(FormID, EqualityOperator) { - FormID fid1, fid2; - EXPECT_TRUE(fid1 == fid2); - - // Not valid conditions, but not evaluating them in this test. - fid1 = FormID("plugin.esp", 1); - fid2 = FormID("plugin.esp", 1); - EXPECT_TRUE(fid1 == fid2); - - fid1 = FormID("plugin.esp", 1); - fid2 = FormID("plugin.esp", 2); - EXPECT_FALSE(fid1 == fid2); - - fid1 = FormID("plugin1.esp", 1); - fid2 = FormID("plugin2.esp", 1); - EXPECT_FALSE(fid1 == fid2); -} - -TEST(FormID, LessThanOperator) { - FormID fid1, fid2; - EXPECT_FALSE(fid1 < fid2); - EXPECT_FALSE(fid2 < fid1); - - fid1 = FormID("plugin.esp", 1); - fid2 = FormID("Plugin.esp", 1); - EXPECT_FALSE(fid1 < fid2); - EXPECT_FALSE(fid2 < fid1); - - fid1 = FormID("plugin.esp", 1); - fid2 = FormID("plugin.esp", 2); - EXPECT_TRUE(fid1 < fid2); - EXPECT_FALSE(fid2 < fid1); - - fid1 = FormID("plugin1.esp", 1); - fid2 = FormID("Plugin2.esp", 1); - EXPECT_TRUE(fid1 < fid2); - EXPECT_FALSE(fid2 < fid1); -} - -#endif diff --git a/src/tests/backend/plugin/test_plugin.h b/src/tests/backend/plugin/test_plugin.h index 88311d20..4f060b69 100644 --- a/src/tests/backend/plugin/test_plugin.h +++ b/src/tests/backend/plugin/test_plugin.h @@ -64,17 +64,17 @@ TEST_F(Plugin, ConstructorsAndDataAccess) { plugin = loot::Plugin(game, "Blank.esm", false); EXPECT_EQ("Blank.esm", plugin.Name()); - EXPECT_EQ(std::set({ - loot::FormID("Blank.esm", 0xCF0), - loot::FormID("Blank.esm", 0xCF1), - loot::FormID("Blank.esm", 0xCF2), - loot::FormID("Blank.esm", 0xCF3), - loot::FormID("Blank.esm", 0xCF4), - loot::FormID("Blank.esm", 0xCF5), - loot::FormID("Blank.esm", 0xCF6), - loot::FormID("Blank.esm", 0xCF7), - loot::FormID("Blank.esm", 0xCF8), - loot::FormID("Blank.esm", 0xCF9), + EXPECT_EQ(std::set({ + libespm::FormId("Blank.esm", std::vector(), 0xCF0), + libespm::FormId("Blank.esm", std::vector(), 0xCF1), + libespm::FormId("Blank.esm", std::vector(), 0xCF2), + libespm::FormId("Blank.esm", std::vector(), 0xCF3), + libespm::FormId("Blank.esm", std::vector(), 0xCF4), + libespm::FormId("Blank.esm", std::vector(), 0xCF5), + libespm::FormId("Blank.esm", std::vector(), 0xCF6), + libespm::FormId("Blank.esm", std::vector(), 0xCF7), + libespm::FormId("Blank.esm", std::vector(), 0xCF8), + libespm::FormId("Blank.esm", std::vector(), 0xCF9), }), plugin.FormIDs()); EXPECT_TRUE(plugin.Masters().empty()); EXPECT_TRUE(plugin.IsMaster()); @@ -86,11 +86,11 @@ TEST_F(Plugin, ConstructorsAndDataAccess) { EXPECT_EQ("Blank - Master Dependent.esp", plugin.Name()); EXPECT_FALSE(plugin.IsEmpty()); EXPECT_FALSE(plugin.IsMaster()); - EXPECT_EQ(std::set({ - loot::FormID("Blank.esm", 0xCF0), - loot::FormID("Blank.esm", 0xCF1), - loot::FormID("Blank - Master Dependent.esp", 0xCE9), - loot::FormID("Blank - Master Dependent.esp", 0xCEA), + EXPECT_EQ(std::set({ + libespm::FormId("Blank.esm", std::vector(), 0xCF0), + libespm::FormId("Blank.esm", std::vector(), 0xCF1), + libespm::FormId("Blank - Master Dependent.esp", std::vector(), 0xCE9), + libespm::FormId("Blank - Master Dependent.esp", std::vector(), 0xCEA), }), plugin.FormIDs()); EXPECT_EQ(std::vector({ "Blank.esm" @@ -259,17 +259,17 @@ TEST_F(Plugin, OverlapFormIDs) { plugin1 = loot::Plugin(game, "Blank.esm", false); plugin2 = loot::Plugin(game, "Blank - Master Dependent.esm", false); - EXPECT_EQ(std::set({ - loot::FormID("Blank.esm", 0xCF0), - loot::FormID("Blank.esm", 0xCF1), - loot::FormID("Blank.esm", 0xCF2), - loot::FormID("Blank.esm", 0xCF3), + EXPECT_EQ(std::set({ + libespm::FormId("Blank.esm", std::vector(), 0xCF0), + libespm::FormId("Blank.esm", std::vector(), 0xCF1), + libespm::FormId("Blank.esm", std::vector(), 0xCF2), + libespm::FormId("Blank.esm", std::vector(), 0xCF3), }), plugin1.OverlapFormIDs(plugin2)); - EXPECT_EQ(std::set({ - loot::FormID("Blank.esm", 0xCF0), - loot::FormID("Blank.esm", 0xCF1), - loot::FormID("Blank.esm", 0xCF2), - loot::FormID("Blank.esm", 0xCF3), + EXPECT_EQ(std::set({ + libespm::FormId("Blank.esm", std::vector(), 0xCF0), + libespm::FormId("Blank.esm", std::vector(), 0xCF1), + libespm::FormId("Blank.esm", std::vector(), 0xCF2), + libespm::FormId("Blank.esm", std::vector(), 0xCF3), }), plugin2.OverlapFormIDs(plugin1)); } diff --git a/src/tests/backend/plugin/test_plugin_loader.h b/src/tests/backend/plugin/test_plugin_loader.h deleted file mode 100644 index 60064f75..00000000 --- a/src/tests/backend/plugin/test_plugin_loader.h +++ /dev/null @@ -1,148 +0,0 @@ -/* LOOT - -A load order optimisation tool for Oblivion, Skyrim, Fallout 3 and -Fallout: New Vegas. - -Copyright (C) 2014-2015 WrinklyNinja - -This file is part of LOOT. - -LOOT is free software: you can redistribute -it and/or modify it under the terms of the GNU General Public License -as published by the Free Software Foundation, either version 3 of -the License, or (at your option) any later version. - -LOOT is distributed in the hope that it will -be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with LOOT. If not, see -. -*/ - -#ifndef LOOT_TEST_BACKEND_PLUGIN_LOADER -#define LOOT_TEST_BACKEND_PLUGIN_LOADER - -#include "backend/plugin/plugin_loader.h" -#include "tests/fixtures.h" - -class PluginLoader : public SkyrimTest {}; - -TEST_F(PluginLoader, Constructor) { - loot::PluginLoader pl; - EXPECT_TRUE(pl.IsEmpty()); - EXPECT_FALSE(pl.IsMaster()); - EXPECT_TRUE(pl.FormIDs().empty()); - EXPECT_TRUE(pl.Masters().empty()); - EXPECT_EQ("", pl.Description()); - EXPECT_EQ(0, pl.Crc()); -} - -TEST_F(PluginLoader, Load_CheckValidityOnly) { - loot::Game game(loot::Game::tes5); - game.SetGamePath(dataPath.parent_path()); - ASSERT_NO_THROW(game.Init(false, localPath)); - - loot::PluginLoader pl; - EXPECT_NO_THROW(pl.Load(game, "Blank.esm", true, true)); - EXPECT_TRUE(pl.IsEmpty()); - EXPECT_FALSE(pl.IsMaster()); - EXPECT_TRUE(pl.FormIDs().empty()); - EXPECT_TRUE(pl.Masters().empty()); - EXPECT_EQ("", pl.Description()); - EXPECT_EQ(0, pl.Crc()); - - EXPECT_ANY_THROW(pl.Load(game, "NotAPlugin.esm", true, true)); - EXPECT_TRUE(pl.IsEmpty()); - EXPECT_FALSE(pl.IsMaster()); - EXPECT_TRUE(pl.FormIDs().empty()); - EXPECT_TRUE(pl.Masters().empty()); - EXPECT_EQ("", pl.Description()); - EXPECT_EQ(0, pl.Crc()); - - EXPECT_NO_THROW(pl.Load(game, "Blank.esm", false, true)); - EXPECT_TRUE(pl.IsEmpty()); - EXPECT_FALSE(pl.IsMaster()); - EXPECT_TRUE(pl.FormIDs().empty()); - EXPECT_TRUE(pl.Masters().empty()); - EXPECT_EQ("", pl.Description()); - EXPECT_EQ(0, pl.Crc()); - - EXPECT_ANY_THROW(pl.Load(game, "NotAPlugin.esm", false, true)); - EXPECT_TRUE(pl.IsEmpty()); - EXPECT_FALSE(pl.IsMaster()); - EXPECT_TRUE(pl.FormIDs().empty()); - EXPECT_TRUE(pl.Masters().empty()); - EXPECT_EQ("", pl.Description()); - EXPECT_EQ(0, pl.Crc()); -} - -TEST_F(PluginLoader, Load_HeaderOnly) { - loot::Game game(loot::Game::tes5); - game.SetGamePath(dataPath.parent_path()); - ASSERT_NO_THROW(game.Init(false, localPath)); - - loot::PluginLoader pl; - EXPECT_NO_THROW(pl.Load(game, "Blank.esm", true, false)); - EXPECT_FALSE(pl.IsEmpty()); - EXPECT_TRUE(pl.IsMaster()); - EXPECT_TRUE(pl.FormIDs().empty()); - EXPECT_TRUE(pl.Masters().empty()); - EXPECT_EQ("v5.0", pl.Description()); - EXPECT_EQ(0, pl.Crc()); - - EXPECT_NO_THROW(pl.Load(game, "Blank - Master Dependent.esp", true, false)); - EXPECT_FALSE(pl.IsEmpty()); - EXPECT_FALSE(pl.IsMaster()); - EXPECT_TRUE(pl.FormIDs().empty()); - EXPECT_EQ(std::vector({ - "Blank.esm" - }), pl.Masters()); - EXPECT_EQ("", pl.Description()); - EXPECT_EQ(0, pl.Crc()); -} - -TEST_F(PluginLoader, Load) { - loot::Game game(loot::Game::tes5); - game.SetGamePath(dataPath.parent_path()); - ASSERT_NO_THROW(game.Init(false, localPath)); - - loot::PluginLoader pl; - EXPECT_NO_THROW(pl.Load(game, "Blank.esm", false, false)); - EXPECT_FALSE(pl.IsEmpty()); - EXPECT_TRUE(pl.IsMaster()); - EXPECT_EQ(std::set({ - loot::FormID("Blank.esm", 0xCF0), - loot::FormID("Blank.esm", 0xCF1), - loot::FormID("Blank.esm", 0xCF2), - loot::FormID("Blank.esm", 0xCF3), - loot::FormID("Blank.esm", 0xCF4), - loot::FormID("Blank.esm", 0xCF5), - loot::FormID("Blank.esm", 0xCF6), - loot::FormID("Blank.esm", 0xCF7), - loot::FormID("Blank.esm", 0xCF8), - loot::FormID("Blank.esm", 0xCF9), - }), pl.FormIDs()); - EXPECT_TRUE(pl.Masters().empty()); - EXPECT_EQ("v5.0", pl.Description()); - EXPECT_EQ(0x187BE342, pl.Crc()); - - EXPECT_NO_THROW(pl.Load(game, "Blank - Master Dependent.esp", false, false)); - EXPECT_FALSE(pl.IsEmpty()); - EXPECT_FALSE(pl.IsMaster()); - EXPECT_EQ(std::set({ - loot::FormID("Blank.esm", 0xCF0), - loot::FormID("Blank.esm", 0xCF1), - loot::FormID("Blank - Master Dependent.esp", 0xCE9), - loot::FormID("Blank - Master Dependent.esp", 0xCEA), - }), pl.FormIDs()); - EXPECT_EQ(std::vector({ - "Blank.esm" - }), pl.Masters()); - EXPECT_EQ("", pl.Description()); - EXPECT_EQ(0x832152DC, pl.Crc()); -} - -#endif diff --git a/src/tests/main.cpp b/src/tests/main.cpp index 594b52f5..50d3a3ce 100644 --- a/src/tests/main.cpp +++ b/src/tests/main.cpp @@ -39,7 +39,6 @@ #include "backend/metadata/test_condition_grammar.h" #include "backend/metadata/test_conditional_metadata.h" #include "backend/metadata/test_file.h" -#include "backend/metadata/test_formid.h" #include "backend/metadata/test_location.h" #include "backend/metadata/test_message.h" #include "backend/metadata/test_message_content.h" @@ -47,7 +46,6 @@ #include "backend/metadata/test_plugin_metadata.h" #include "backend/metadata/test_tag.h" #include "backend/plugin/test_plugin.h" -#include "backend/plugin/test_plugin_loader.h" #include "backend/test_metadata_list.h" #include "backend/test_masterlist.h" #include "backend/test_plugin_sorter.h" diff --git a/src/tests/printers.h b/src/tests/printers.h index 3431ace3..89fe9f5a 100644 --- a/src/tests/printers.h +++ b/src/tests/printers.h @@ -30,7 +30,6 @@ along with LOOT. If not, see #include #include "backend/metadata/file.h" -#include "backend/metadata/formid.h" #include "backend/metadata/location.h" #include "backend/metadata/message.h" #include "backend/metadata/message_content.h" @@ -47,14 +46,6 @@ namespace loot { << ")"; } - void PrintTo(const FormID& value, ::std::ostream* os) { - *os << "loot::FormID(\"" << value.Plugin() << "\", 0x" - << std::hex << std::uppercase - << value.Id() - << std::nouppercase << std::dec - << ")"; - } - void PrintTo(const Location& value, ::std::ostream* os) { *os << "loot::Location(\"" << value.URL() << "\", " << "\"" << value.Name() << "\", "