Refactor libespm references out of GameSettings

So it's all contained within Plugin now.
This commit is contained in:
Oliver Hamlet
2017-02-06 18:01:55 +00:00
parent 4237895e7c
commit 87965920f9
4 changed files with 17 additions and 17 deletions
-13
View File
@@ -96,19 +96,6 @@ GameType GameSettings::Type() const {
return type_;
}
libespm::GameId GameSettings::LibespmId() const {
if (type_ == GameType::tes4)
return libespm::GameId::OBLIVION;
else if (type_ == GameType::tes5 || type_ == GameType::tes5se)
return libespm::GameId::SKYRIM;
else if (type_ == GameType::fo3)
return libespm::GameId::FALLOUT3;
else if (type_ == GameType::fonv)
return libespm::GameId::FALLOUTNV;
else
return libespm::GameId::FALLOUT4;
}
std::string GameSettings::Name() const {
return name_;
}
-2
View File
@@ -29,7 +29,6 @@
#include <list>
#include <boost/filesystem.hpp>
#include <libespm/GameId.h>
#include <yaml-cpp/yaml.h>
#include "loot/enum/game_type.h"
@@ -45,7 +44,6 @@ public:
bool operator == (const GameSettings& rhs) const; //Compares names and folder names.
GameType Type() 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;
+15 -2
View File
@@ -42,7 +42,7 @@ using std::string;
namespace loot {
Plugin::Plugin(const Game& game, const std::string& name, const bool headerOnly) :
PluginMetadata(name),
libespm::Plugin(game.LibespmId()),
libespm::Plugin(Plugin::GetLibespmGameId(game.Type())),
isEmpty_(true),
isActive_(false),
loadsArchive_(false),
@@ -180,7 +180,7 @@ bool Plugin::IsValid(const std::string& filename, const Game& game) {
if (!boost::filesystem::exists(filepath) && boost::filesystem::exists(filepath.string() + ".ghost"))
filepath += ".ghost";
if (libespm::Plugin::isValid(filepath, game.LibespmId(), true))
if (libespm::Plugin::isValid(filepath, GetLibespmGameId(game.Type()), true))
return true;
BOOST_LOG_TRIVIAL(warning) << "The .es(p|m) file \"" << filename << "\" is not a valid plugin.";
@@ -249,4 +249,17 @@ void Plugin::CheckInstallValidity(const Game& game) {
bool Plugin::LoadsArchive() const {
return loadsArchive_;
}
libespm::GameId Plugin::GetLibespmGameId(GameType gameType) {
if (gameType == GameType::tes4)
return libespm::GameId::OBLIVION;
else if (gameType == GameType::tes5 || gameType == GameType::tes5se)
return libespm::GameId::SKYRIM;
else if (gameType == GameType::fo3)
return libespm::GameId::FALLOUT3;
else if (gameType == GameType::fonv)
return libespm::GameId::FALLOUTNV;
else
return libespm::GameId::FALLOUT4;
}
}
+2
View File
@@ -34,6 +34,7 @@
#include <libespm/Plugin.h>
#include "backend/metadata/plugin_metadata.h"
#include "loot/enum/game_type.h"
namespace loot {
class Game;
@@ -66,6 +67,7 @@ public:
bool operator < (const Plugin& rhs) const;
private:
static libespm::GameId GetLibespmGameId(GameType gameType);
bool isEmpty_; // Does the plugin contain any records other than the TES4 header?
bool isActive_;
bool loadsArchive_;