Update libloadorder to v9.0.0

It adds support for Fallout 4 v1.5's new load order mechanism.
This commit is contained in:
Oliver Hamlet
2016-04-12 17:24:39 +01:00
parent 9e88c70d97
commit dfdb94b0fc
4 changed files with 55 additions and 43 deletions
+1 -1
View File
@@ -70,7 +70,7 @@ set(LIBGIT2_LIBRARIES "${BINARY_DIR}/${CMAKE_CFG_INTDIR}/${CMAKE_STATIC_LIBRARY_
ExternalProject_Add(libloadorder
PREFIX "external"
DEPENDS libespm
URL "https://github.com/WrinklyNinja/libloadorder/archive/8.0.1.tar.gz"
URL "https://github.com/WrinklyNinja/libloadorder/archive/9.0.0.tar.gz"
CMAKE_ARGS -DBOOST_INCLUDEDIR=${Boost_INCLUDE_DIR} -DPROJECT_STATIC_RUNTIME=${PROJECT_STATIC_RUNTIME}
# BUILD_COMMAND ${CMAKE_COMMAND} --build . --target loadorder --config $(CONFIGURATION)
INSTALL_COMMAND "")
+6 -6
View File
@@ -173,16 +173,16 @@ namespace loot {
game.SetGamePath(dataPath.parent_path());
game.Init(false, localPath);
std::vector<std::string> loadOrder = getInitialLoadOrder();
std::vector<std::pair<std::string, bool>> loadOrder = getInitialLoadOrder();
// First set reverse timestamps to be sure.
time_t time = boost::filesystem::last_write_time(dataPath / masterFile);
for (size_t i = 1; i < loadOrder.size(); ++i) {
if (!boost::filesystem::exists(dataPath / loadOrder[i]))
loadOrder[i] += ".ghost";
if (!boost::filesystem::exists(dataPath / loadOrder[i].first))
loadOrder[i].first += ".ghost";
boost::filesystem::last_write_time(dataPath / loadOrder[i], time - i * 60);
ASSERT_EQ(time - i * 60, boost::filesystem::last_write_time(dataPath / loadOrder[i]));
boost::filesystem::last_write_time(dataPath / loadOrder[i].first, time - i * 60);
ASSERT_EQ(time - i * 60, boost::filesystem::last_write_time(dataPath / loadOrder[i].first));
}
EXPECT_NO_THROW(game.RedatePlugins());
@@ -191,7 +191,7 @@ namespace loot {
if (GetParam() != Game::tes5)
interval *= -1;
for (size_t i = 0; i < loadOrder.size(); ++i) {
EXPECT_EQ(time + i * interval, boost::filesystem::last_write_time(dataPath / loadOrder[i]));
EXPECT_EQ(time + i * interval, boost::filesystem::last_write_time(dataPath / loadOrder[i].first));
}
}
@@ -145,8 +145,11 @@ namespace loot {
blankDifferentMasterDependentEsp,
blankPluginDependentEsp,
});
EXPECT_NO_THROW(loh.SetLoadOrder(loadOrder));
if (GetParam() == GameSettings::fo4)
loadOrder.erase(begin(loadOrder));
EXPECT_EQ(loadOrder, getLoadOrder());
}
}
+44 -35
View File
@@ -81,7 +81,6 @@ namespace loot {
// Set initial load order and active plugins.
setLoadOrder(getInitialLoadOrder());
setActivePlugins(getInitialActivePlugins());
// Ghost a plugin.
ASSERT_FALSE(boost::filesystem::exists(dataPath / (blankMasterDependentEsm + ".ghost")));
@@ -116,7 +115,7 @@ namespace loot {
for (const auto& plugin : loadOrder)
actual.push_back(plugin.second);
}
else {
else if (GetParam() == GameSettings::tes5) {
boost::filesystem::ifstream in(localPath / "loadorder.txt");
while (in) {
std::string line;
@@ -126,31 +125,37 @@ namespace loot {
actual.push_back(line);
}
}
else {
boost::filesystem::ifstream in(localPath / "plugins.txt");
while (in) {
std::string line;
std::getline(in, line);
if (!line.empty()) {
if (line[0] == '*')
line = line.substr(1);
actual.push_back(line);
}
}
}
return actual;
}
inline std::vector<std::string> getInitialLoadOrder() const {
return std::vector<std::string>({
masterFile,
blankEsm,
blankDifferentEsm,
blankMasterDependentEsm,
blankDifferentMasterDependentEsm,
blankEsp,
blankDifferentEsp,
blankMasterDependentEsp,
blankDifferentMasterDependentEsp,
blankPluginDependentEsp,
blankDifferentPluginDependentEsp,
});
}
inline std::unordered_set<std::string> getInitialActivePlugins() const {
return std::unordered_set<std::string>({
masterFile,
blankEsm,
blankDifferentMasterDependentEsp,
inline std::vector<std::pair<std::string, bool>> getInitialLoadOrder() const {
return std::vector<std::pair<std::string, bool>>({
{masterFile, true},
{blankEsm, true},
{blankDifferentEsm, false},
{blankMasterDependentEsm, false},
{blankDifferentMasterDependentEsm, false},
{blankEsp, false},
{blankDifferentEsp, false},
{blankMasterDependentEsp, false},
{blankDifferentMasterDependentEsp, true},
{blankPluginDependentEsp, false},
{blankDifferentPluginDependentEsp, false},
});
}
@@ -208,32 +213,36 @@ namespace loot {
return 0x187BE342;
}
inline void setLoadOrder(const std::vector<std::string>& loadOrder) {
inline void setLoadOrder(const std::vector<std::pair<std::string, bool>>& loadOrder) const {
boost::filesystem::ofstream out(localPath / "plugins.txt");
for (const auto &plugin : loadOrder) {
if (GetParam() == GameSettings::fo4 && plugin.second)
out << '*';
else if (GetParam() != GameSettings::fo4 && !plugin.second)
continue;
out << plugin.first << std::endl;
}
if (isLoadOrderTimestampBased(GetParam())) {
time_t modificationTime = time(NULL); // Current time.
for (const auto &plugin : loadOrder) {
if (boost::filesystem::exists(dataPath / boost::filesystem::path(plugin + ".ghost"))) {
boost::filesystem::last_write_time(dataPath / boost::filesystem::path(plugin + ".ghost"), modificationTime);
if (boost::filesystem::exists(dataPath / boost::filesystem::path(plugin.first + ".ghost"))) {
boost::filesystem::last_write_time(dataPath / boost::filesystem::path(plugin.first + ".ghost"), modificationTime);
}
else {
boost::filesystem::last_write_time(dataPath / plugin, modificationTime);
boost::filesystem::last_write_time(dataPath / plugin.first, modificationTime);
}
modificationTime += 60;
}
}
else {
else if (GetParam() == GameSettings::tes5) {
boost::filesystem::ofstream out(localPath / "loadorder.txt");
for (const auto &plugin : loadOrder)
out << plugin << std::endl;
out << plugin.first << std::endl;
}
}
inline void setActivePlugins(const std::unordered_set<std::string>& activePlugins) {
boost::filesystem::ofstream out(localPath / "plugins.txt");
for (const auto &plugin : activePlugins)
out << plugin << std::endl;
}
inline static bool isLoadOrderTimestampBased(unsigned int gameId) {
return gameId == GameSettings::tes4 || gameId == GameSettings::fo3 || gameId == GameSettings::fonv;
}