Skip to content

Commit

Permalink
[kernel] add: config option to not load user directory files
Browse files Browse the repository at this point in the history
  • Loading branch information
jd28 committed Nov 18, 2023
1 parent 9c0b1bc commit 3ab9029
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 24 deletions.
11 changes: 6 additions & 5 deletions lib/nw/kernel/Config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@ namespace nw {

/// Configuration options, maybe there will be an actual config file.. someday.
struct ConfigOptions {
GameVersion version;
std::filesystem::path install;
std::filesystem::path user;
bool include_install = true;
bool include_nwsync = true;
GameVersion version; ///< Game version
std::filesystem::path install; ///< Path to Game installation directory
std::filesystem::path user; ///< Path to User directory
bool include_install = true; ///< Load Game install files
bool include_nwsync = true; ///< Load NWSync files
bool include_user = true; ///< Load User files, note: if false, value overrides ``include_nwsync``
};

namespace kernel {
Expand Down
44 changes: 25 additions & 19 deletions lib/nw/kernel/Resources.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,28 +52,34 @@ void Resources::initialize()
LOG_F(INFO, "kernel: root directory: {}", config().options().install);
LOG_F(INFO, "kernel: user directory: {}", config().options().user);

ambient_user_ = Directory{config().alias_path(PathAlias::ambient)};
dmvault_user_ = Directory{config().alias_path(PathAlias::dmvault)};
localvault_user_ = Directory{config().alias_path(PathAlias::localvault)};
music_user_ = Directory{config().alias_path(PathAlias::music)};
override_user_ = Directory{config().alias_path(PathAlias::override)};
portraits_user_ = Directory{config().alias_path(PathAlias::portraits)};
servervault_user_ = Directory{config().alias_path(PathAlias::servervault)};

if (config().options().version == GameVersion::vEE) {
if (config().options().include_nwsync) {
nwsync_ = NWSync{config().alias_path(PathAlias::nwsync)};
if (config().options().include_user) {
ambient_user_ = Directory{config().alias_path(PathAlias::ambient)};
dmvault_user_ = Directory{config().alias_path(PathAlias::dmvault)};
localvault_user_ = Directory{config().alias_path(PathAlias::localvault)};
music_user_ = Directory{config().alias_path(PathAlias::music)};
override_user_ = Directory{config().alias_path(PathAlias::override)};
portraits_user_ = Directory{config().alias_path(PathAlias::portraits)};
servervault_user_ = Directory{config().alias_path(PathAlias::servervault)};
}

if (config().options().include_user) {
if (config().options().version == GameVersion::vEE) {
if (config().options().include_nwsync) {
nwsync_ = NWSync{config().alias_path(PathAlias::nwsync)};
}
development_ = Directory{config().alias_path(PathAlias::development)};
}
development_ = Directory{config().alias_path(PathAlias::development)};
}

if (config().userpatch_ini().valid()) {
int i = 0;
std::string file;
while (config().userpatch_ini().get_to(fmt::format("Patch/PatchFile{:03d}", i++), file)) {
auto c = resolve_container(config().alias_path(PathAlias::patch), file);
if (c) {
patches_.emplace_back(c);
if (config().options().include_user) {
if (config().userpatch_ini().valid()) {
int i = 0;
std::string file;
while (config().userpatch_ini().get_to(fmt::format("Patch/PatchFile{:03d}", i++), file)) {
auto c = resolve_container(config().alias_path(PathAlias::patch), file);
if (c) {
patches_.emplace_back(c);
}
}
}
}
Expand Down

0 comments on commit 3ab9029

Please sign in to comment.