mirror of
https://github.com/loot/libloot.git
synced 2026-07-27 14:16:01 -07:00
Remove Game usage from Plugin
Pass the bits Plugin needs individually. Also store Game's LoadOrderHandler in a shared pointer for future sharing with ApiDatabase.
This commit is contained in:
+15
-12
@@ -64,10 +64,11 @@ Game::Game(const GameType gameType,
|
||||
type_(gameType),
|
||||
gamePath_(gamePath),
|
||||
localDataPath_(localDataPath),
|
||||
cache_(std::make_shared<GameCache>()) {
|
||||
cache_(std::make_shared<GameCache>()),
|
||||
loadOrderHandler_(std::make_shared<LoadOrderHandler>()) {
|
||||
BOOST_LOG_TRIVIAL(info) << "Initialising load order data for game of type " << (int)type_ << " at: " << gamePath_;
|
||||
|
||||
loadOrderHandler_.Init(type_, gamePath_, localDataPath_);
|
||||
loadOrderHandler_->Init(type_, gamePath_, localDataPath_);
|
||||
|
||||
database_ = std::make_shared<ApiDatabase>(*this);
|
||||
}
|
||||
@@ -84,12 +85,16 @@ std::shared_ptr<GameCache> Game::GetCache() {
|
||||
return cache_;
|
||||
}
|
||||
|
||||
std::shared_ptr<LoadOrderHandler> Game::GetLoadOrderHandler() {
|
||||
return loadOrderHandler_;
|
||||
}
|
||||
|
||||
std::shared_ptr<DatabaseInterface> Game::GetDatabase() {
|
||||
return database_;
|
||||
}
|
||||
|
||||
bool Game::IsValidPlugin(const std::string& plugin) const {
|
||||
return Plugin::IsValid(plugin, *this);
|
||||
return Plugin::IsValid(plugin, Type(), DataPath());
|
||||
}
|
||||
|
||||
void Game::LoadPlugins(const std::vector<std::string>& plugins, bool loadHeadersOnly) {
|
||||
@@ -98,10 +103,10 @@ void Game::LoadPlugins(const std::vector<std::string>& plugins, bool loadHeaders
|
||||
|
||||
// First get the plugin sizes.
|
||||
for (const auto& plugin : plugins) {
|
||||
if (!Plugin::IsValid(plugin, *this))
|
||||
if (!IsValidPlugin(plugin))
|
||||
throw std::invalid_argument("\"" + plugin + "\" is not a valid plugin");
|
||||
|
||||
uintmax_t fileSize = Plugin::GetFileSize(plugin, *this);
|
||||
uintmax_t fileSize = Plugin::GetFileSize(plugin, DataPath());
|
||||
meanFileSize += fileSize;
|
||||
|
||||
// Trim .ghost extension if present.
|
||||
@@ -144,10 +149,8 @@ void Game::LoadPlugins(const std::vector<std::string>& plugins, bool loadHeaders
|
||||
threads.push_back(thread([&]() {
|
||||
for (auto pluginName : pluginGroup) {
|
||||
BOOST_LOG_TRIVIAL(trace) << "Loading " << pluginName;
|
||||
if (boost::iequals(pluginName, masterFile_))
|
||||
cache_->AddPlugin(Plugin(*this, pluginName, true));
|
||||
else
|
||||
cache_->AddPlugin(Plugin(*this, pluginName, loadHeadersOnly));
|
||||
const bool loadHeader = boost::iequals(pluginName, masterFile_) || loadHeadersOnly;
|
||||
cache_->AddPlugin(Plugin(Type(), DataPath(), loadOrderHandler_, pluginName, loadHeader));
|
||||
}
|
||||
}));
|
||||
}
|
||||
@@ -188,15 +191,15 @@ bool Game::IsPluginActive(const std::string& plugin) const {
|
||||
try {
|
||||
return std::static_pointer_cast<const Plugin>(GetPlugin(plugin))->IsActive();
|
||||
} catch (...) {
|
||||
return loadOrderHandler_.IsPluginActive(plugin);
|
||||
return loadOrderHandler_->IsPluginActive(plugin);
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<std::string> Game::GetLoadOrder() const {
|
||||
return loadOrderHandler_.GetLoadOrder();
|
||||
return loadOrderHandler_->GetLoadOrder();
|
||||
}
|
||||
|
||||
void Game::SetLoadOrder(const std::vector<std::string>& loadOrder) {
|
||||
loadOrderHandler_.SetLoadOrder(loadOrder);
|
||||
loadOrderHandler_->SetLoadOrder(loadOrder);
|
||||
}
|
||||
}
|
||||
|
||||
+2
-1
@@ -47,6 +47,7 @@ public:
|
||||
boost::filesystem::path DataPath() const;
|
||||
|
||||
std::shared_ptr<GameCache> GetCache();
|
||||
std::shared_ptr<LoadOrderHandler> GetLoadOrderHandler();
|
||||
|
||||
// Game Interface Methods //
|
||||
////////////////////////////
|
||||
@@ -72,13 +73,13 @@ public:
|
||||
void SetLoadOrder(const std::vector<std::string>& loadOrder);
|
||||
private:
|
||||
std::shared_ptr<GameCache> cache_;
|
||||
std::shared_ptr<LoadOrderHandler> loadOrderHandler_;
|
||||
std::shared_ptr<DatabaseInterface> database_;
|
||||
|
||||
const GameType type_;
|
||||
const boost::filesystem::path gamePath_;
|
||||
const boost::filesystem::path localDataPath_;
|
||||
|
||||
LoadOrderHandler loadOrderHandler_;
|
||||
std::string masterFile_;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -407,8 +407,8 @@ Version ConditionEvaluator::getVersion(const std::string& filePath) const {
|
||||
// The file wasn't in the plugin cache, load it as a plugin
|
||||
// if it appears to be valid, otherwise treat it as a non
|
||||
// plugin file.
|
||||
if (Plugin::IsValid(filePath, *game_))
|
||||
return Version(Plugin(*game_, filePath, true).GetVersion());
|
||||
if (Plugin::IsValid(filePath, game_->Type(), game_->DataPath()))
|
||||
return Version(Plugin(game_->Type(), game_->DataPath(), game_->GetLoadOrderHandler(), filePath, true).GetVersion());
|
||||
|
||||
return Version(game_->DataPath() / filePath);
|
||||
}
|
||||
|
||||
+14
-10
@@ -42,16 +42,20 @@ using std::set;
|
||||
using std::string;
|
||||
|
||||
namespace loot {
|
||||
Plugin::Plugin(const Game& game, const std::string& name, const bool headerOnly) :
|
||||
Plugin::Plugin(const GameType gameType,
|
||||
const boost::filesystem::path& dataPath,
|
||||
std::shared_ptr<LoadOrderHandler> loadOrderHandler,
|
||||
const std::string& name,
|
||||
const bool headerOnly) :
|
||||
name_(name),
|
||||
libespm::Plugin(Plugin::GetLibespmGameId(game.Type())),
|
||||
libespm::Plugin(Plugin::GetLibespmGameId(gameType)),
|
||||
isEmpty_(true),
|
||||
isActive_(false),
|
||||
loadsArchive_(false),
|
||||
crc_(0),
|
||||
numOverrideRecords_(0) {
|
||||
try {
|
||||
boost::filesystem::path filepath = game.DataPath() / name_;
|
||||
boost::filesystem::path filepath = dataPath / name_;
|
||||
|
||||
// In case the plugin is ghosted.
|
||||
if (!boost::filesystem::exists(filepath) && boost::filesystem::exists(filepath.string() + ".ghost"))
|
||||
@@ -94,9 +98,9 @@ Plugin::Plugin(const Game& game, const std::string& name, const bool headerOnly)
|
||||
}
|
||||
}
|
||||
// Get whether the plugin is active or not.
|
||||
isActive_ = game.IsPluginActive(name_);
|
||||
isActive_ = loadOrderHandler->IsPluginActive(name_);
|
||||
|
||||
loadsArchive_ = LoadsArchive(name_, game.Type(), game.DataPath());
|
||||
loadsArchive_ = LoadsArchive(name_, gameType, dataPath);
|
||||
} catch (std::exception& e) {
|
||||
BOOST_LOG_TRIVIAL(error) << "Cannot read plugin file \"" << name << "\". Details: " << e.what();
|
||||
throw FileAccessError((boost::format("Cannot read \"%1%\". Details: %2%") % name % e.what()).str());
|
||||
@@ -186,7 +190,7 @@ std::set<FormId> Plugin::OverlapFormIDs(const Plugin& plugin) const {
|
||||
return overlap;
|
||||
}
|
||||
|
||||
bool Plugin::IsValid(const std::string& filename, const Game& game) {
|
||||
bool Plugin::IsValid(const std::string& filename, const GameType gameType, const boost::filesystem::path& dataPath) {
|
||||
BOOST_LOG_TRIVIAL(trace) << "Checking to see if \"" << filename << "\" is a valid plugin.";
|
||||
|
||||
//If the filename passed ends in '.ghost', that should be trimmed.
|
||||
@@ -201,19 +205,19 @@ bool Plugin::IsValid(const std::string& filename, const Game& game) {
|
||||
return false;
|
||||
|
||||
// Add the ".ghost" file extension if the plugin is ghosted.
|
||||
boost::filesystem::path filepath = game.DataPath() / name;
|
||||
boost::filesystem::path filepath = dataPath / name;
|
||||
if (!boost::filesystem::exists(filepath) && boost::filesystem::exists(filepath.string() + ".ghost"))
|
||||
filepath += ".ghost";
|
||||
|
||||
if (libespm::Plugin::isValid(filepath, GetLibespmGameId(game.Type()), true))
|
||||
if (libespm::Plugin::isValid(filepath, GetLibespmGameId(gameType), true))
|
||||
return true;
|
||||
|
||||
BOOST_LOG_TRIVIAL(warning) << "The .es(p|m) file \"" << filename << "\" is not a valid plugin.";
|
||||
return false;
|
||||
}
|
||||
|
||||
uintmax_t Plugin::GetFileSize(const std::string & filename, const Game & game) {
|
||||
boost::filesystem::path realPath = game.DataPath() / filename;
|
||||
uintmax_t Plugin::GetFileSize(const std::string & filename, const boost::filesystem::path& dataPath) {
|
||||
boost::filesystem::path realPath = dataPath / filename;
|
||||
if (!boost::filesystem::exists(realPath))
|
||||
realPath += ".ghost";
|
||||
|
||||
|
||||
@@ -33,16 +33,19 @@
|
||||
#include <boost/locale.hpp>
|
||||
#include <libespm/Plugin.h>
|
||||
|
||||
#include "api/game/load_order_handler.h"
|
||||
#include "loot/metadata/plugin_metadata.h"
|
||||
#include "loot/enum/game_type.h"
|
||||
#include "loot/plugin_interface.h"
|
||||
|
||||
namespace loot {
|
||||
class Game;
|
||||
|
||||
class Plugin : public PluginInterface, private libespm::Plugin {
|
||||
public:
|
||||
Plugin(const Game& game, const std::string& name, const bool headerOnly);
|
||||
Plugin(const GameType gameType,
|
||||
const boost::filesystem::path& dataPath,
|
||||
std::shared_ptr<LoadOrderHandler> loadOrderHandler,
|
||||
const std::string& name,
|
||||
const bool headerOnly);
|
||||
|
||||
std::string GetName() const;
|
||||
std::string GetLowercasedName() const;
|
||||
@@ -63,8 +66,8 @@ public:
|
||||
std::set<libespm::FormId> OverlapFormIDs(const Plugin& plugin) const;
|
||||
|
||||
// Validity checks.
|
||||
static bool IsValid(const std::string& filename, const Game& game);
|
||||
static uintmax_t GetFileSize(const std::string& filename, const Game& game);
|
||||
static bool IsValid(const std::string& filename, const GameType gameType, const boost::filesystem::path& dataPath);
|
||||
static uintmax_t GetFileSize(const std::string& filename, const boost::filesystem::path& dataPath);
|
||||
|
||||
bool operator < (const Plugin& rhs) const;
|
||||
private:
|
||||
|
||||
@@ -72,15 +72,15 @@ TEST_P(GameCacheTest, gettingANonCachedConditionShouldReturnAFalseFalsePair) {
|
||||
}
|
||||
|
||||
TEST_P(GameCacheTest, addingAPluginThatDoesNotExistShouldSucceed) {
|
||||
cache_.AddPlugin(Plugin(game_, blankEsm, true));
|
||||
cache_.AddPlugin(Plugin(game_.Type(), game_.DataPath(), game_.GetLoadOrderHandler(), blankEsm, true));
|
||||
EXPECT_EQ(blankEsm, cache_.GetPlugin(blankEsm)->GetName());
|
||||
}
|
||||
|
||||
TEST_P(GameCacheTest, addingAPluginThatIsAlreadyCachedShouldOverwriteExistingEntry) {
|
||||
cache_.AddPlugin(Plugin(game_, blankEsm, true));
|
||||
cache_.AddPlugin(Plugin(game_.Type(), game_.DataPath(), game_.GetLoadOrderHandler(), blankEsm, true));
|
||||
EXPECT_EQ(0, cache_.GetPlugin(blankEsm)->GetCRC());
|
||||
|
||||
cache_.AddPlugin(Plugin(game_, blankEsm, false));
|
||||
cache_.AddPlugin(Plugin(game_.Type(), game_.DataPath(), game_.GetLoadOrderHandler(), blankEsm, false));
|
||||
EXPECT_EQ(blankEsmCrc, cache_.GetPlugin(blankEsm)->GetCRC());
|
||||
}
|
||||
|
||||
@@ -89,7 +89,7 @@ TEST_P(GameCacheTest, gettingAPluginThatIsNotCachedShouldThrow) {
|
||||
}
|
||||
|
||||
TEST_P(GameCacheTest, gettingAPluginShouldBeCaseInsensitive) {
|
||||
cache_.AddPlugin(Plugin(game_, blankEsm, true));
|
||||
cache_.AddPlugin(Plugin(game_.Type(), game_.DataPath(), game_.GetLoadOrderHandler(), blankEsm, true));
|
||||
EXPECT_EQ(blankEsm, cache_.GetPlugin(blankEsm)->GetName());
|
||||
}
|
||||
|
||||
@@ -98,8 +98,8 @@ TEST_P(GameCacheTest, gettingPluginsShouldReturnAnEmptySetIfNoPluginsHaveBeenCac
|
||||
}
|
||||
|
||||
TEST_P(GameCacheTest, gettingPluginsShouldReturnASetOfCachedPluginsIfPluginsHaveBeenCached) {
|
||||
cache_.AddPlugin(Plugin(game_, blankEsm, true));
|
||||
cache_.AddPlugin(Plugin(game_, blankMasterDependentEsm, true));
|
||||
cache_.AddPlugin(Plugin(game_.Type(), game_.DataPath(), game_.GetLoadOrderHandler(), blankEsm, true));
|
||||
cache_.AddPlugin(Plugin(game_.Type(), game_.DataPath(), game_.GetLoadOrderHandler(), blankMasterDependentEsm, true));
|
||||
|
||||
EXPECT_FALSE(cache_.GetPlugins().empty());
|
||||
}
|
||||
@@ -121,7 +121,7 @@ TEST_P(GameCacheTest, clearingCachedPluginsShouldNotThrowIfNoPluginsAreCached) {
|
||||
}
|
||||
|
||||
TEST_P(GameCacheTest, clearingCachedPluginsShouldClearAnyCachedPlugins) {
|
||||
cache_.AddPlugin(Plugin(game_, blankEsm, true));
|
||||
cache_.AddPlugin(Plugin(game_.Type(), game_.DataPath(), game_.GetLoadOrderHandler(), blankEsm, true));
|
||||
cache_.ClearCachedPlugins();
|
||||
|
||||
EXPECT_TRUE(cache_.GetPlugins().empty());
|
||||
|
||||
@@ -123,7 +123,7 @@ INSTANTIATE_TEST_CASE_P(,
|
||||
GameType::tes5se));
|
||||
|
||||
TEST_P(PluginTest, loadingHeaderOnlyShouldReadHeaderData) {
|
||||
Plugin plugin(game_, blankEsm, true);
|
||||
Plugin plugin(game_.Type(), game_.DataPath(), game_.GetLoadOrderHandler(), blankEsm, true);
|
||||
|
||||
EXPECT_EQ(blankEsm, plugin.GetName());
|
||||
EXPECT_TRUE(plugin.GetMasters().empty());
|
||||
@@ -133,13 +133,13 @@ TEST_P(PluginTest, loadingHeaderOnlyShouldReadHeaderData) {
|
||||
}
|
||||
|
||||
TEST_P(PluginTest, loadingHeaderOnlyShouldNotReadFieldsOrCalculateCrc) {
|
||||
Plugin plugin(game_, blankEsm, true);
|
||||
Plugin plugin(game_.Type(), game_.DataPath(), game_.GetLoadOrderHandler(), blankEsm, true);
|
||||
|
||||
EXPECT_EQ(0, plugin.GetCRC());
|
||||
}
|
||||
|
||||
TEST_P(PluginTest, loadingWholePluginShouldReadHeaderData) {
|
||||
Plugin plugin(game_, blankEsm, true);
|
||||
Plugin plugin(game_.Type(), game_.DataPath(), game_.GetLoadOrderHandler(), blankEsm, true);
|
||||
|
||||
EXPECT_EQ(blankEsm, plugin.GetName());
|
||||
EXPECT_TRUE(plugin.GetMasters().empty());
|
||||
@@ -149,25 +149,25 @@ TEST_P(PluginTest, loadingWholePluginShouldReadHeaderData) {
|
||||
}
|
||||
|
||||
TEST_P(PluginTest, loadingWholePluginShouldReadFields) {
|
||||
Plugin plugin(game_, blankMasterDependentEsm, false);
|
||||
Plugin plugin(game_.Type(), game_.DataPath(), game_.GetLoadOrderHandler(), blankMasterDependentEsm, false);
|
||||
|
||||
EXPECT_EQ(4, plugin.NumOverrideFormIDs());
|
||||
}
|
||||
|
||||
TEST_P(PluginTest, loadingWholePluginShouldCalculateCrc) {
|
||||
Plugin plugin(game_, blankEsm, false);
|
||||
Plugin plugin(game_.Type(), game_.DataPath(), game_.GetLoadOrderHandler(), blankEsm, false);
|
||||
|
||||
EXPECT_EQ(blankEsmCrc, plugin.GetCRC());
|
||||
}
|
||||
|
||||
TEST_P(PluginTest, loadingANonMasterPluginShouldReadTheMasterFlagAsFalse) {
|
||||
Plugin plugin(game_, blankMasterDependentEsp, true);
|
||||
Plugin plugin(game_.Type(), game_.DataPath(), game_.GetLoadOrderHandler(), blankMasterDependentEsp, true);
|
||||
|
||||
EXPECT_FALSE(plugin.IsMaster());
|
||||
}
|
||||
|
||||
TEST_P(PluginTest, loadingAPluginWithMastersShouldReadThemCorrectly) {
|
||||
Plugin plugin(game_, blankMasterDependentEsp, true);
|
||||
Plugin plugin(game_.Type(), game_.DataPath(), game_.GetLoadOrderHandler(), blankMasterDependentEsp, true);
|
||||
|
||||
EXPECT_EQ(std::vector<std::string>({
|
||||
blankEsm
|
||||
@@ -175,11 +175,11 @@ TEST_P(PluginTest, loadingAPluginWithMastersShouldReadThemCorrectly) {
|
||||
}
|
||||
|
||||
TEST_P(PluginTest, loadingAPluginThatDoesNotExistShouldThrow) {
|
||||
EXPECT_THROW(Plugin(game_, "Blank\\.esp", true), FileAccessError);
|
||||
EXPECT_THROW(Plugin(game_.Type(), game_.DataPath(), game_.GetLoadOrderHandler(), "Blank\\.esp", true), FileAccessError);
|
||||
}
|
||||
|
||||
TEST_P(PluginTest, loadsArchiveForAnArchiveThatExactlyMatchesAnEsmFileBasenameShouldReturnTrueForAllGamesExceptOblivion) {
|
||||
bool loadsArchive = Plugin(game_, blankEsm, true).LoadsArchive();
|
||||
bool loadsArchive = Plugin(game_.Type(), game_.DataPath(), game_.GetLoadOrderHandler(), blankEsm, true).LoadsArchive();
|
||||
|
||||
if (GetParam() == GameType::tes4)
|
||||
EXPECT_FALSE(loadsArchive);
|
||||
@@ -188,11 +188,11 @@ TEST_P(PluginTest, loadsArchiveForAnArchiveThatExactlyMatchesAnEsmFileBasenameSh
|
||||
}
|
||||
|
||||
TEST_P(PluginTest, loadsArchiveForAnArchiveThatExactlyMatchesAnEspFileBasenameShouldReturnTrue) {
|
||||
EXPECT_TRUE(Plugin(game_, blankEsp, true).LoadsArchive());
|
||||
EXPECT_TRUE(Plugin(game_.Type(), game_.DataPath(), game_.GetLoadOrderHandler(), blankEsp, true).LoadsArchive());
|
||||
}
|
||||
|
||||
TEST_P(PluginTest, loadsArchiveForAnArchiveWithAFilenameWhichStartsWithTheEsmFileBasenameShouldReturnTrueForAllGamesExceptOblivionAndSkyrim) {
|
||||
bool loadsArchive = Plugin(game_, blankDifferentEsm, true).LoadsArchive();
|
||||
bool loadsArchive = Plugin(game_.Type(), game_.DataPath(), game_.GetLoadOrderHandler(), blankDifferentEsm, true).LoadsArchive();
|
||||
|
||||
if (GetParam() == GameType::tes4 || GetParam() == GameType::tes5)
|
||||
EXPECT_FALSE(loadsArchive);
|
||||
@@ -201,7 +201,7 @@ TEST_P(PluginTest, loadsArchiveForAnArchiveWithAFilenameWhichStartsWithTheEsmFil
|
||||
}
|
||||
|
||||
TEST_P(PluginTest, loadsArchiveForAnArchiveWithAFilenameWhichStartsWithTheEspFileBasenameShouldReturnTrueForAllGamesExceptSkyrim) {
|
||||
bool loadsArchive = Plugin(game_, blankDifferentEsp, true).LoadsArchive();
|
||||
bool loadsArchive = Plugin(game_.Type(), game_.DataPath(), game_.GetLoadOrderHandler(), blankDifferentEsp, true).LoadsArchive();
|
||||
|
||||
if (GetParam() == GameType::tes5)
|
||||
EXPECT_FALSE(loadsArchive);
|
||||
@@ -210,45 +210,45 @@ TEST_P(PluginTest, loadsArchiveForAnArchiveWithAFilenameWhichStartsWithTheEspFil
|
||||
}
|
||||
|
||||
TEST_P(PluginTest, loadsArchiveShouldReturnFalseForAPluginThatDoesNotLoadAnArchive) {
|
||||
EXPECT_FALSE(Plugin(game_, blankMasterDependentEsp, true).LoadsArchive());
|
||||
EXPECT_FALSE(Plugin(game_.Type(), game_.DataPath(), game_.GetLoadOrderHandler(), blankMasterDependentEsp, true).LoadsArchive());
|
||||
}
|
||||
|
||||
TEST_P(PluginTest, isValidShouldReturnTrueForAValidPlugin) {
|
||||
EXPECT_TRUE(Plugin::IsValid(blankEsm, game_));
|
||||
EXPECT_TRUE(Plugin::IsValid(blankEsm, game_.Type(), game_.DataPath()));
|
||||
}
|
||||
|
||||
TEST_P(PluginTest, isValidShouldReturnFalseForANonPluginFile) {
|
||||
EXPECT_FALSE(Plugin::IsValid(nonPluginFile, game_));
|
||||
EXPECT_FALSE(Plugin::IsValid(nonPluginFile, game_.Type(), game_.DataPath()));
|
||||
}
|
||||
|
||||
TEST_P(PluginTest, isValidShouldReturnFalseForAnEmptyFile) {
|
||||
EXPECT_FALSE(Plugin::IsValid(emptyFile, game_));
|
||||
EXPECT_FALSE(Plugin::IsValid(emptyFile, game_.Type(), game_.DataPath()));
|
||||
}
|
||||
|
||||
TEST_P(PluginTest, isActiveShouldReturnTrueForAPluginThatIsActive) {
|
||||
EXPECT_TRUE(Plugin(game_, blankEsm, true).IsActive());
|
||||
EXPECT_TRUE(Plugin(game_.Type(), game_.DataPath(), game_.GetLoadOrderHandler(), blankEsm, true).IsActive());
|
||||
}
|
||||
|
||||
TEST_P(PluginTest, isActiveShouldReturnFalseForAPluginThatIsNotActive) {
|
||||
EXPECT_FALSE(Plugin(game_, blankEsp, true).IsActive());
|
||||
EXPECT_FALSE(Plugin(game_.Type(), game_.DataPath(), game_.GetLoadOrderHandler(), blankEsp, true).IsActive());
|
||||
}
|
||||
|
||||
TEST_P(PluginTest, lessThanOperatorShouldUseCaseInsensitiveLexicographicalNameComparison) {
|
||||
Plugin plugin1(game_, blankEsp, true);
|
||||
Plugin plugin2(game_, lowercaseBlankEsp, true);
|
||||
Plugin plugin1(game_.Type(), game_.DataPath(), game_.GetLoadOrderHandler(), blankEsp, true);
|
||||
Plugin plugin2(game_.Type(), game_.DataPath(), game_.GetLoadOrderHandler(), lowercaseBlankEsp, true);
|
||||
|
||||
EXPECT_FALSE(plugin1 < plugin2);
|
||||
EXPECT_FALSE(plugin2 < plugin1);
|
||||
|
||||
Plugin plugin3 = Plugin(game_, blankEsm, true);
|
||||
Plugin plugin4 = Plugin(game_, blankEsp, true);
|
||||
Plugin plugin3 = Plugin(game_.Type(), game_.DataPath(), game_.GetLoadOrderHandler(), blankEsm, true);
|
||||
Plugin plugin4 = Plugin(game_.Type(), game_.DataPath(), game_.GetLoadOrderHandler(), blankEsp, true);
|
||||
|
||||
EXPECT_TRUE(plugin3 < plugin4);
|
||||
EXPECT_FALSE(plugin4 < plugin3);
|
||||
}
|
||||
|
||||
TEST_P(PluginTest, doFormIDsOverlapShouldReturnFalseIfTheArgumentIsNotAPluginObject) {
|
||||
Plugin plugin1(game_, blankEsm, false);
|
||||
Plugin plugin1(game_.Type(), game_.DataPath(), game_.GetLoadOrderHandler(), blankEsm, false);
|
||||
OtherPluginType plugin2;
|
||||
|
||||
EXPECT_FALSE(plugin1.DoFormIDsOverlap(plugin2));
|
||||
@@ -256,48 +256,48 @@ TEST_P(PluginTest, doFormIDsOverlapShouldReturnFalseIfTheArgumentIsNotAPluginObj
|
||||
}
|
||||
|
||||
TEST_P(PluginTest, doFormIDsOverlapShouldReturnFalseForTwoPluginsWithOnlyHeadersLoaded) {
|
||||
Plugin plugin1(game_, blankEsm, true);
|
||||
Plugin plugin2(game_, blankMasterDependentEsm, true);
|
||||
Plugin plugin1(game_.Type(), game_.DataPath(), game_.GetLoadOrderHandler(), blankEsm, true);
|
||||
Plugin plugin2(game_.Type(), game_.DataPath(), game_.GetLoadOrderHandler(), blankMasterDependentEsm, true);
|
||||
|
||||
EXPECT_FALSE(plugin1.DoFormIDsOverlap(plugin2));
|
||||
EXPECT_FALSE(plugin2.DoFormIDsOverlap(plugin1));
|
||||
}
|
||||
|
||||
TEST_P(PluginTest, doFormIDsOverlapShouldReturnFalseIfThePluginsHaveUnrelatedRecords) {
|
||||
Plugin plugin1(game_, blankEsm, false);
|
||||
Plugin plugin2(game_, blankEsp, false);
|
||||
Plugin plugin1(game_.Type(), game_.DataPath(), game_.GetLoadOrderHandler(), blankEsm, false);
|
||||
Plugin plugin2(game_.Type(), game_.DataPath(), game_.GetLoadOrderHandler(), blankEsp, false);
|
||||
|
||||
EXPECT_FALSE(plugin1.DoFormIDsOverlap(plugin2));
|
||||
EXPECT_FALSE(plugin2.DoFormIDsOverlap(plugin1));
|
||||
}
|
||||
|
||||
TEST_P(PluginTest, doFormIDsOverlapShouldReturnTrueIfOnePluginOverridesTheOthersRecords) {
|
||||
Plugin plugin1(game_, blankEsm, false);
|
||||
Plugin plugin2(game_, blankMasterDependentEsm, false);
|
||||
Plugin plugin1(game_.Type(), game_.DataPath(), game_.GetLoadOrderHandler(), blankEsm, false);
|
||||
Plugin plugin2(game_.Type(), game_.DataPath(), game_.GetLoadOrderHandler(), blankMasterDependentEsm, false);
|
||||
|
||||
EXPECT_TRUE(plugin1.DoFormIDsOverlap(plugin2));
|
||||
EXPECT_TRUE(plugin2.DoFormIDsOverlap(plugin1));
|
||||
}
|
||||
|
||||
TEST_P(PluginTest, overlapFormIDsShouldReturnAnEmptySetForTwoPluginsWithOnlyHeadersLoaded) {
|
||||
Plugin plugin1(game_, blankEsm, true);
|
||||
Plugin plugin2(game_, blankMasterDependentEsm, true);
|
||||
Plugin plugin1(game_.Type(), game_.DataPath(), game_.GetLoadOrderHandler(), blankEsm, true);
|
||||
Plugin plugin2(game_.Type(), game_.DataPath(), game_.GetLoadOrderHandler(), blankMasterDependentEsm, true);
|
||||
|
||||
EXPECT_TRUE(plugin1.OverlapFormIDs(plugin2).empty());
|
||||
EXPECT_TRUE(plugin2.OverlapFormIDs(plugin1).empty());
|
||||
}
|
||||
|
||||
TEST_P(PluginTest, overlapFormIDsShouldReturnAnEmptySetIfThePluginsHaveUnrelatedRecords) {
|
||||
Plugin plugin1(game_, blankEsm, false);
|
||||
Plugin plugin2(game_, blankEsp, false);
|
||||
Plugin plugin1(game_.Type(), game_.DataPath(), game_.GetLoadOrderHandler(), blankEsm, false);
|
||||
Plugin plugin2(game_.Type(), game_.DataPath(), game_.GetLoadOrderHandler(), blankEsp, false);
|
||||
|
||||
EXPECT_TRUE(plugin1.OverlapFormIDs(plugin2).empty());
|
||||
EXPECT_TRUE(plugin2.OverlapFormIDs(plugin1).empty());
|
||||
}
|
||||
|
||||
TEST_P(PluginTest, overlapFormIDsShouldReturnTheFormIDsOfRecordsAddedByOnePluginAndOverriddenByTheOther) {
|
||||
Plugin plugin1(game_, blankEsm, false);
|
||||
Plugin plugin2(game_, blankMasterDependentEsm, false);
|
||||
Plugin plugin1(game_.Type(), game_.DataPath(), game_.GetLoadOrderHandler(), blankEsm, false);
|
||||
Plugin plugin2(game_.Type(), game_.DataPath(), game_.GetLoadOrderHandler(), blankMasterDependentEsm, false);
|
||||
|
||||
std::set<libespm::FormId> expectedFormIds({
|
||||
libespm::FormId(blankEsm, std::vector<std::string>(), 0xCF0),
|
||||
|
||||
Reference in New Issue
Block a user