Skip to content

Commit 2edac2f

Browse files
authored
Dependency Update Meta PR (#25)
* Update for 0.26.1 and OR support
1 parent f747df4 commit 2edac2f

5 files changed

Lines changed: 107 additions & 33 deletions

File tree

src/game_settings.cpp

Lines changed: 66 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,47 @@ static constexpr float FONV_MINIMUM_HEADER_VERSION = 1.32f;
1111
static constexpr float FO4_MINIMUM_HEADER_VERSION = 0.95f;
1212
static constexpr float STARFIELD_MINIMUM_HEADER_VERSION = 0.96f;
1313

14+
std::filesystem::path GetOpenMWDataPath(const std::filesystem::path& gamePath)
15+
{
16+
#ifndef _WIN32
17+
if (gamePath == "/usr/games") {
18+
// Ubuntu, Debian
19+
return "/usr/share/games/openmw/resources/vfs";
20+
} else if (gamePath == "/run/host/usr/games") {
21+
// Ubuntu, Debian from inside a Flatpak sandbox
22+
return "/run/host/usr/share/games/openmw/resources/vfs";
23+
} else if (gamePath == "/usr/bin") {
24+
const auto path = "/usr/share/games/openmw/resources/vfs";
25+
if (std::filesystem::exists(path)) {
26+
// Arch
27+
return path;
28+
}
29+
30+
// OpenSUSE
31+
return "/usr/share/openmw/resources/vfs";
32+
} else if (gamePath == "/run/host/usr/bin") {
33+
const auto path = "/run/host/usr/share/games/openmw/resources/vfs";
34+
if (std::filesystem::exists(path)) {
35+
// Arch from inside a Flatpak sandbox
36+
return path;
37+
}
38+
39+
// OpenSUSE from inside a Flatpak sandbox
40+
return "/run/host/usr/share/openmw/resources/vfs";
41+
} else if (boost::ends_with(gamePath.u8string(),
42+
"/app/org.openmw.OpenMW/current/active/files/bin")) {
43+
// Flatpak
44+
return gamePath / "../share/games/openmw/resources/vfs";
45+
}
46+
#endif
47+
return gamePath / "resources" / "vfs";
48+
}
49+
1450
GameType GetGameType(const GameId gameId)
1551
{
1652
switch (gameId) {
1753
case GameId::tes3:
54+
case GameId::openmw:
1855
return GameType::tes3;
1956
case GameId::tes4:
2057
case GameId::nehrim:
@@ -37,6 +74,8 @@ GameType GetGameType(const GameId gameId)
3774
return GameType::fo4vr;
3875
case GameId::starfield:
3976
return GameType::starfield;
77+
case GameId::oblivionRemastered:
78+
return GameType::oblivionRemastered;
4079
default:
4180
throw std::logic_error("Unrecognised game ID");
4281
}
@@ -46,9 +85,11 @@ float GetMinimumHeaderVersion(const GameId gameId)
4685
{
4786
switch (gameId) {
4887
case GameId::tes3:
88+
case GameId::openmw:
4989
return MORROWIND_MINIMUM_HEADER_VERSION;
5090
case GameId::tes4:
5191
case GameId::nehrim:
92+
case GameId::oblivionRemastered:
5293
return OBLIVION_MINIMUM_HEADER_VERSION;
5394
case GameId::tes5:
5495
case GameId::enderal:
@@ -71,11 +112,12 @@ float GetMinimumHeaderVersion(const GameId gameId)
71112
}
72113
}
73114

74-
std::string GetPluginsFolderName(GameId gameId)
115+
std::filesystem::path GetDataPath(const GameId gameId,
116+
const std::filesystem::path& gamePath)
75117
{
76118
switch (gameId) {
77119
case GameId::tes3:
78-
return "Data Files";
120+
return gamePath / "Data Files";
79121
case GameId::tes4:
80122
case GameId::nehrim:
81123
case GameId::tes5:
@@ -88,7 +130,11 @@ std::string GetPluginsFolderName(GameId gameId)
88130
case GameId::fo4:
89131
case GameId::fo4vr:
90132
case GameId::starfield:
91-
return "Data";
133+
return gamePath / "Data";
134+
case GameId::openmw:
135+
return GetOpenMWDataPath(gamePath);
136+
case GameId::oblivionRemastered:
137+
return gamePath / "OblivionRemastered" / "Content" / "Dev" / "ObvData" / "Data";
92138
default:
93139
throw std::logic_error("Unrecognised game ID");
94140
}
@@ -123,6 +169,10 @@ std::string ToString(const GameId gameId)
123169
return "Fallout4VR";
124170
case GameId::starfield:
125171
return "Starfield";
172+
case GameId::openmw:
173+
return "OpenMW";
174+
case GameId::oblivionRemastered:
175+
return "Oblivion Remastered";
126176
default:
127177
throw std::logic_error("Unrecognised game ID");
128178
}
@@ -140,6 +190,7 @@ std::string GetMasterFilename(const GameId gameId)
140190
case GameId::tes3:
141191
return "Morrowind.esm";
142192
case GameId::tes4:
193+
case GameId::oblivionRemastered:
143194
return "Oblivion.esm";
144195
case GameId::nehrim:
145196
return "Nehrim.esm";
@@ -158,6 +209,12 @@ std::string GetMasterFilename(const GameId gameId)
158209
return "Fallout4.esm";
159210
case GameId::starfield:
160211
return "Starfield.esm";
212+
case GameId::openmw:
213+
// This isn't actually a master file, but it's hardcoded to load first,
214+
// and the value is only used to check the game is installed and to
215+
// skip fully loading this file before sorting - and omwscripts files
216+
// don't get loaded anyway.
217+
return "builtin.omwscripts";
161218
default:
162219
throw std::logic_error("Unrecognised game ID");
163220
}
@@ -192,6 +249,10 @@ std::string GetGameName(const GameId gameId)
192249
return "Fallout 4 VR";
193250
case GameId::starfield:
194251
return "Starfield";
252+
case GameId::openmw:
253+
return "OpenMW";
254+
case GameId::oblivionRemastered:
255+
return "TES IV: Oblivion Remastered";
195256
default:
196257
throw std::logic_error("Unrecognised game ID");
197258
}
@@ -204,6 +265,7 @@ std::string GetDefaultMasterlistRepositoryName(const GameId gameId)
204265
return "morrowind";
205266
case GameId::tes4:
206267
case GameId::nehrim:
268+
case GameId::oblivionRemastered:
207269
return "oblivion";
208270
case GameId::tes5:
209271
return "skyrim";
@@ -301,7 +363,7 @@ std::filesystem::path GameSettings::GameLocalPath() const
301363

302364
std::filesystem::path GameSettings::DataPath() const
303365
{
304-
return gamePath_ / GetPluginsFolderName(id_);
366+
return GetDataPath(id_, gamePath_);
305367
}
306368

307369
GameSettings& GameSettings::SetName(const std::string& name)

src/game_settings.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ namespace loot
1414
constexpr inline std::string_view NEHRIM_STEAM_REGISTRY_KEY =
1515
"Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Steam App "
1616
"1014940\\InstallLocation";
17-
static constexpr const char* DEFAULT_MASTERLIST_BRANCH = "v0.21";
17+
static constexpr const char* DEFAULT_MASTERLIST_BRANCH = "v0.26";
1818

1919
enum struct GameId : uint8_t
2020
{
@@ -30,14 +30,17 @@ enum struct GameId : uint8_t
3030
fonv,
3131
fo4,
3232
fo4vr,
33-
starfield
33+
starfield,
34+
openmw,
35+
oblivionRemastered
3436
};
3537

3638
GameType GetGameType(const GameId gameId);
3739

3840
float GetMinimumHeaderVersion(const GameId gameId);
3941

40-
std::string GetPluginsFolderName(GameId gamiId);
42+
std::filesystem::path GetDataPath(const GameId gamiId,
43+
const std::filesystem::path& gamePath);
4144

4245
std::string ToString(const GameId gameId);
4346

src/lootthread.cpp

Lines changed: 32 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ using std::recursive_mutex;
1717

1818
namespace lootcli
1919
{
20-
static const std::set<std::string> oldDefaultBranches({"master", "v0.7", "v0.8",
21-
"v0.10", "v0.13", "v0.14",
22-
"v0.15", "v0.17", "v0.18"});
20+
static const std::set<std::string>
21+
oldDefaultBranches({"master", "v0.7", "v0.8", "v0.10", "v0.13", "v0.14", "v0.15",
22+
"v0.17", "v0.18", "v0.21"});
2323
static const std::regex GITHUB_REPO_URL_REGEX =
2424
std::regex(R"(^https://github\.com/([^/]+)/([^/]+?)(?:\.git)?/?$)",
2525
std::regex::ECMAScript | std::regex::icase);
@@ -55,13 +55,20 @@ std::string ToLower(std::string text)
5555
void LOOTWorker::setGame(const std::string& gameName)
5656
{
5757
static std::map<std::string, loot::GameId> gameMap = {
58-
{"morrowind", loot::GameId::tes3}, {"oblivion", loot::GameId::tes4},
59-
{"fallout3", loot::GameId::fo3}, {"fallout4", loot::GameId::fo4},
60-
{"fallout4vr", loot::GameId::fo4vr}, {"falloutnv", loot::GameId::fonv},
61-
{"skyrim", loot::GameId::tes5}, {"skyrimse", loot::GameId::tes5se},
62-
{"skyrimvr", loot::GameId::tes5vr}, {"nehrim", loot::GameId::nehrim},
63-
{"enderal", loot::GameId::enderal}, {"enderalse", loot::GameId::enderalse},
64-
{"starfield", loot::GameId::starfield}};
58+
{"morrowind", loot::GameId::tes3},
59+
{"oblivion", loot::GameId::tes4},
60+
{"fallout3", loot::GameId::fo3},
61+
{"fallout4", loot::GameId::fo4},
62+
{"fallout4vr", loot::GameId::fo4vr},
63+
{"falloutnv", loot::GameId::fonv},
64+
{"skyrim", loot::GameId::tes5},
65+
{"skyrimse", loot::GameId::tes5se},
66+
{"skyrimvr", loot::GameId::tes5vr},
67+
{"nehrim", loot::GameId::nehrim},
68+
{"enderal", loot::GameId::enderal},
69+
{"enderalse", loot::GameId::enderalse},
70+
{"starfield", loot::GameId::starfield},
71+
{"oblivionremastered", loot::GameId::oblivionRemastered}};
6572

6673
auto iter = gameMap.find(ToLower(gameName));
6774

@@ -197,6 +204,12 @@ void LOOTWorker::getSettings(const fs::path& file)
197204
gameId = GameId::fo4;
198205
} else if (gameType == "Fallout4VR") {
199206
gameId = GameId::fo4vr;
207+
} else if (gameType == "Starfield") {
208+
gameId = GameId::starfield;
209+
} else if (gameType == "OpenMW") {
210+
gameId = GameId::openmw;
211+
} else if (gameType == "Oblivion Remastered") {
212+
gameId = GameId::oblivionRemastered;
200213
} else {
201214
throw std::runtime_error(
202215
"invalid value for 'type' key in game settings table");
@@ -667,7 +680,7 @@ int LOOTWorker::run()
667680
std::locale::global(gen("en.UTF-8"));
668681
}
669682

670-
loot::SetLoggingCallback([&](loot::LogLevel level, const char* message) {
683+
loot::SetLoggingCallback([&](loot::LogLevel level, std::string_view message) {
671684
log(level, message);
672685
});
673686

@@ -784,21 +797,23 @@ int LOOTWorker::run()
784797

785798
progress(Progress::LoadingLists);
786799

800+
gameHandle->GetDatabase().LoadMasterlist(masterlistPath().string());
787801
fs::path userlist = userlistPath();
788-
gameHandle->GetDatabase().LoadLists(masterlistPath().string(),
789-
fs::exists(userlist) ? userlistPath().string()
790-
: fs::path());
802+
if (fs::exists(userlist))
803+
gameHandle->GetDatabase().LoadUserlist(userlist.string());
791804

792805
progress(Progress::ReadingPlugins);
793806
gameHandle->LoadCurrentLoadOrderState();
807+
auto loadOrder = gameHandle->GetLoadOrder();
794808
std::vector<std::filesystem::path> pluginsList;
795809
for (auto plugin : gameHandle->GetLoadOrder()) {
796810
std::filesystem::path pluginPath(plugin);
797811
pluginsList.push_back(pluginPath);
798812
}
813+
gameHandle->LoadPlugins(pluginsList, false);
799814

800815
progress(Progress::SortingPlugins);
801-
std::vector<std::string> sortedPlugins = gameHandle->SortPlugins(pluginsList);
816+
std::vector<std::string> sortedPlugins = gameHandle->SortPlugins(loadOrder);
802817

803818
progress(Progress::WritingLoadorder);
804819

@@ -1040,14 +1055,7 @@ void LOOTWorker::progress(Progress p)
10401055
std::cout.flush();
10411056
}
10421057

1043-
std::string escapeNewlines(const std::string& s)
1044-
{
1045-
auto ss = boost::replace_all_copy(s, "\n", "\\n");
1046-
boost::replace_all(ss, "\r", "\\r");
1047-
return ss;
1048-
}
1049-
1050-
void LOOTWorker::log(loot::LogLevel level, const std::string& message) const
1058+
void LOOTWorker::log(loot::LogLevel level, const std::string_view message) const
10511059
{
10521060
if (level < m_LogLevel) {
10531061
return;
@@ -1056,7 +1064,7 @@ void LOOTWorker::log(loot::LogLevel level, const std::string& message) const
10561064
const auto ll = fromLootLogLevel(level);
10571065
const auto levelName = logLevelToString(ll);
10581066

1059-
std::cout << "[" << levelName << "] " << escapeNewlines(message) << "\n";
1067+
std::cout << "[" << levelName << "] " << message << "\n";
10601068
std::cout.flush();
10611069
}
10621070

src/lootthread.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#define LOOTTHREAD_H
33

44
#include "game_settings.h"
5+
#include "loot/database_interface.h"
56
#include <lootcli/lootcli.h>
67

78
namespace loot
@@ -35,7 +36,7 @@ class LOOTWorker
3536

3637
private:
3738
void progress(Progress p);
38-
void log(loot::LogLevel level, const std::string& message) const;
39+
void log(loot::LogLevel level, const std::string_view message) const;
3940

4041
DWORD GetFile(const WCHAR* szUrl, const CHAR* szFileName);
4142
void getSettings(const std::filesystem::path& file);

src/version.rc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ VALUE "CompanyName", "Mod Organizer 2 Team\0"
2222
VALUE "FileDescription", "LOOT Command line interface\0"
2323
VALUE "OriginalFilename", "lootcli.exe\0"
2424
VALUE "InternalName", "lootcli\0"
25-
VALUE "LegalCopyright", "Copyright 2011-2016 Sebastian Herbord\r\nCopyright 2016-2023 Mod Organizer 2 contributors\0"
25+
VALUE "LegalCopyright", "Copyright 2011-2016 Sebastian Herbord\r\nCopyright 2016-2025 Mod Organizer 2 contributors\0"
2626
VALUE "ProductName", "lootcli\0"
2727
VALUE "ProductVersion", VER_FILEVERSION_STR
2828
END

0 commit comments

Comments
 (0)