libloot 0.18.x compatibility

* On startup, migrate old LOOT data folders to new directory path
* Incorporate GameSettings data changes
* Update settings parser and migration code
* Manually update/download masterlist.yaml to LOOT game directory

TODO: Improve performace of masterlist updater
This commit is contained in:
Jeremy Rimpo
2022-05-02 02:03:55 -05:00
parent 5825c7a77b
commit 2b0eef7aec
4 changed files with 495 additions and 98 deletions
+15 -31
View File
@@ -77,7 +77,7 @@ namespace loot {
"1435828767_is1\\InstallLocation" };
lootFolderName_ = "Morrowind";
masterFile_ = "Morrowind.esm";
mininumHeaderVersion_ = MORROWIND_MINIMUM_HEADER_VERSION;
minimumHeaderVersion_ = MORROWIND_MINIMUM_HEADER_VERSION;
} else if (Type() == GameType::tes4) {
name_ = "TES IV: Oblivion";
registryKeys_ = { "Software\\Bethesda Softworks\\Oblivion\\Installed Path",
@@ -93,7 +93,7 @@ namespace loot {
"1458058109_is1\\InstallLocation" };
lootFolderName_ = "Oblivion";
masterFile_ = "Oblivion.esm";
mininumHeaderVersion_ = OBLIVION_MINIMUM_HEADER_VERSION;
minimumHeaderVersion_ = OBLIVION_MINIMUM_HEADER_VERSION;
} else if (Type() == GameType::tes5) {
name_ = "TES V: Skyrim";
registryKeys_ = { "Software\\Bethesda Softworks\\Skyrim\\Installed Path",
@@ -101,7 +101,7 @@ namespace loot {
"Steam App 72850\\InstallLocation" };
lootFolderName_ = "Skyrim";
masterFile_ = "Skyrim.esm";
mininumHeaderVersion_ = SKYRIM_FO3_MINIMUM_HEADER_VERSION;
minimumHeaderVersion_ = SKYRIM_FO3_MINIMUM_HEADER_VERSION;
} else if (Type() == GameType::tes5se) {
name_ = "TES V: Skyrim Special Edition";
registryKeys_ = {
@@ -110,7 +110,7 @@ namespace loot {
"489830\\InstallLocation" };
lootFolderName_ = "Skyrim Special Edition";
masterFile_ = "Skyrim.esm";
mininumHeaderVersion_ = SKYRIM_SE_MINIMUM_HEADER_VERSION;
minimumHeaderVersion_ = SKYRIM_SE_MINIMUM_HEADER_VERSION;
} else if (Type() == GameType::tes5vr) {
name_ = "TES V: Skyrim VR";
registryKeys_ = { "Software\\Bethesda Softworks\\Skyrim VR\\Installed Path",
@@ -118,7 +118,7 @@ namespace loot {
"Steam App 611670\\InstallLocation" };
lootFolderName_ = "Skyrim VR";
masterFile_ = "Skyrim.esm";
mininumHeaderVersion_ = SKYRIM_SE_MINIMUM_HEADER_VERSION;
minimumHeaderVersion_ = SKYRIM_SE_MINIMUM_HEADER_VERSION;
} else if (Type() == GameType::fo3) {
name_ = "Fallout 3";
registryKeys_ = { "Software\\Bethesda Softworks\\Fallout3\\Installed Path",
@@ -134,7 +134,7 @@ namespace loot {
"1248282609_is1\\InstallLocation" };
lootFolderName_ = "Fallout3";
masterFile_ = "Fallout3.esm";
mininumHeaderVersion_ = SKYRIM_FO3_MINIMUM_HEADER_VERSION;
minimumHeaderVersion_ = SKYRIM_FO3_MINIMUM_HEADER_VERSION;
} else if (Type() == GameType::fonv) {
name_ = "Fallout: New Vegas";
registryKeys_ = { "Software\\Bethesda Softworks\\FalloutNV\\Installed Path",
@@ -150,7 +150,7 @@ namespace loot {
"1454587428_is1\\InstallLocation" };
lootFolderName_ = "FalloutNV";
masterFile_ = "FalloutNV.esm";
mininumHeaderVersion_ = FONV_MINIMUM_HEADER_VERSION;
minimumHeaderVersion_ = FONV_MINIMUM_HEADER_VERSION;
} else if (Type() == GameType::fo4) {
name_ = "Fallout 4";
registryKeys_ = { "Software\\Bethesda Softworks\\Fallout4\\Installed Path",
@@ -158,7 +158,7 @@ namespace loot {
"Steam App 377160\\InstallLocation" };
lootFolderName_ = "Fallout4";
masterFile_ = "Fallout4.esm";
mininumHeaderVersion_ = FO4_MINIMUM_HEADER_VERSION;
minimumHeaderVersion_ = FO4_MINIMUM_HEADER_VERSION;
} else if (Type() == GameType::fo4vr) {
name_ = "Fallout 4 VR";
registryKeys_ = {
@@ -167,7 +167,7 @@ namespace loot {
"611660\\InstallLocation" };
lootFolderName_ = "Fallout4VR";
masterFile_ = "Fallout4.esm";
mininumHeaderVersion_ = FO4_MINIMUM_HEADER_VERSION;
minimumHeaderVersion_ = FO4_MINIMUM_HEADER_VERSION;
}
if (!folder.empty()) {
@@ -207,6 +207,8 @@ namespace loot {
return gamePath_ / GetPluginsFolderName(type_);
}
bool GameSettings::IsBaseGameInstance() const { return isBaseGameInstance_; }
GameSettings& GameSettings::SetName(const std::string& name) {
name_ = name;
return *this;
@@ -219,7 +221,7 @@ namespace loot {
GameSettings& GameSettings::SetMinimumHeaderVersion(
float mininumHeaderVersion) {
mininumHeaderVersion_ = mininumHeaderVersion;
minimumHeaderVersion_ = mininumHeaderVersion;
return *this;
}
@@ -260,26 +262,8 @@ namespace loot {
return *this;
}
void GameSettings::MigrateSettings() {
// If the masterlist repository is set to an official repository and the
// masterlist branch is an old default branch, update the masterlist
// branch to the current default.
if (boost::starts_with(repositoryURL_, "https://github.com/loot/") &&
IsRepoBranchOldDefault()) {
SetRepoBranch(currentDefaultBranch);
}
// If the game is Skyrim VR or Fallout 4 VR and the masterlist repository
// is the official Skyrim SE or Fallout 4 repository (respectively),
// switch to the newer VR-specific repositories.
if (Type() == GameType::tes5vr &&
RepoURL() == GameSettings(GameType::tes5se).RepoURL()) {
SetRepoURL(GameSettings(GameType::tes5vr).RepoURL());
}
if (Type() == GameType::fo4vr &&
RepoURL() == GameSettings(GameType::fo4).RepoURL()) {
SetRepoURL(GameSettings(GameType::fo4vr).RepoURL());
}
GameSettings& GameSettings::SetIsBaseGameInstance(bool isInstance) {
isBaseGameInstance_ = isInstance;
return *this;
}
}
+16 -18
View File
@@ -5,6 +5,7 @@
#include <optional>
#include <set>
#include <string>
#include <vector>
#include "loot/enum/game_type.h"
@@ -12,14 +13,17 @@ namespace loot {
constexpr inline std::string_view NEHRIM_STEAM_REGISTRY_KEY =
"Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Steam App "
"1014940\\InstallLocation";
static constexpr const char* DEFAULT_MASTERLIST_BRANCH = "v0.18";
std::string GetPluginsFolderName(GameType gameType);
std::string GetDefaultMasterlistUrl(std::string repoName);
class GameSettings {
public:
GameSettings();
GameSettings() = default;
explicit GameSettings(const GameType gameType,
const std::string& lootFolder = "");
bool IsRepoBranchOldDefault() const;
const std::string& lootFolder = "");
bool operator==(
const GameSettings& rhs) const; // Compares names and folder names.
@@ -30,40 +34,34 @@ namespace loot {
std::string Master() const;
float MinimumHeaderVersion() const;
std::vector<std::string> RegistryKeys() const;
std::string RepoURL() const;
std::string RepoBranch() const;
std::string MasterlistSource() const;
std::filesystem::path GamePath() const;
std::filesystem::path GameLocalPath() const;
std::filesystem::path DataPath() const;
bool IsBaseGameInstance() const;
GameSettings& SetName(const std::string& name);
GameSettings& SetMaster(const std::string& masterFile);
GameSettings& SetMinimumHeaderVersion(float minimumHeaderVersion);
GameSettings& SetRegistryKeys(const std::vector<std::string>& registry);
GameSettings& SetRepoURL(const std::string& repositoryURL);
GameSettings& SetRepoBranch(const std::string& repositoryBranch);
GameSettings& SetMasterlistSource(const std::string& source);
GameSettings& SetGamePath(const std::filesystem::path& path);
GameSettings& SetGameLocalPath(const std::filesystem::path& GameLocalPath);
GameSettings& SetGameLocalFolder(const std::string& folderName);
void MigrateSettings();
GameSettings& SetIsBaseGameInstance(bool isInstance);
private:
static const std::set<std::string> oldDefaultBranches;
static const std::string currentDefaultBranch;
GameType type_;
GameType type_{ GameType::tes4 };
std::string name_;
std::string masterFile_;
float minimumHeaderVersion_;
float minimumHeaderVersion_{ 0.0f };
bool isBaseGameInstance_{ true };
std::vector<std::string> registryKeys_;
std::string pluginsFolderName_;
std::string lootFolderName_;
std::string repositoryURL_;
std::string repositoryBranch_;
std::string masterlistSource_;
std::filesystem::path gamePath_; //Path to the game's folder.
std::filesystem::path gameLocalPath_;
+455 -49
View File
File diff suppressed because it is too large Load Diff
+9
View File
@@ -34,8 +34,17 @@ private:
void progress(Progress p);
void log(loot::LogLevel level, const std::string& message) const;
DWORD GetFile(const WCHAR* szUrl, const CHAR* szFileName);
void getSettings(const std::filesystem::path& file);
std::string getOldDefaultRepoUrl(loot::GameType gameType);
bool isLocalPath(const std::string& location, const std::string& filename);
bool isBranchCheckedOut(const std::filesystem::path& localGitRepo,
const std::string& branch);
std::optional<std::string> migrateMasterlistRepoSettings(loot::GameType gameType, std::string url, std::string branch);
std::optional<std::string> migrateMasterlistRepoSettings(loot::GameType gameType, cpptoml::option<std::string> url, cpptoml::option<std::string> branch);
std::string migrateMasterlistSource(const std::string& source);
std::filesystem::path gamePath() const;
std::filesystem::path masterlistPath() const;
std::filesystem::path settingsPath() const;
std::filesystem::path userlistPath() const;