MCPcopy Create free account
hub / github.com/Norbyte/bg3se / LoadConfigs

Method LoadConfigs

BG3Extender/Extender/Shared/ExtensionState.cpp:49–122  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

47 }
48
49 void ExtensionStateBase::LoadConfigs()
50 {
51 auto modManager = GetModManager();
52 if (modManager == nullptr) {
53 OsiErrorS("Mod manager not available");
54 return;
55 }
56
57 unsigned numConfigs{ 0 };
58 for (auto const& mod : modManager->LoadOrderedModules) {
59 auto dir = mod.Info.Directory;
60 auto configFile = "Mods/" + dir + "/ScriptExtender/Config.json";
61 auto reader = GetStaticSymbols().MakeFileReader(configFile);
62
63 if (reader.IsLoaded()) {
64 ExtensionModConfig config;
65 if (LoadConfig(mod, reader.ToString(), config)) {
66 std::stringstream featureFlags;
67 for (auto const & flag : config.FeatureFlags) {
68 featureFlags << flag << " ";
69 }
70
71 INFO(" '%s': SE v%d; flags: %s", mod.Info.Name.c_str(),
72 config.MinimumVersion, featureFlags.str().c_str());
73
74 if (config.MinimumVersion == 0) {
75 OsiError("Module '" << mod.Info.Name << ":");
76 OsiError("Specifying RequiredVersion in ScriptExtender/Config.json is mandatory.");
77 continue;
78 }
79
80 if (config.ModTable.empty()) {
81 OsiError("Module '" << mod.Info.Name << ":");
82 OsiError("Module must specify a ModTable in ScriptExtender/Config.json.");
83 continue;
84 }
85
86 if (config.MinimumVersion > CurrentVersion) {
87 OsiError("Module '" << mod.Info.Name << " is targeting version v" << config.MinimumVersion << " that's more recent than the current version!");
88 }
89
90 if (config.MinimumVersion != 0 && config.MinimumVersion > MergedConfig.MinimumVersion) {
91 MergedConfig.MinimumVersion = config.MinimumVersion;
92 HighestVersionMod = &mod;
93 }
94
95 for (auto const & flag : config.FeatureFlags) {
96 MergedConfig.FeatureFlags.insert(flag);
97 }
98
99 numConfigs++;
100
101 modConfigs_.insert(std::make_pair(mod.Info.ModuleUUIDString.GetString(), config));
102 }
103 }
104 }
105
106 if (numConfigs > 0) {

Callers 2

LoadExtensionStateMethod · 0.80
LoadExtensionStateMethod · 0.80

Calls 7

MakeFileReaderMethod · 0.80
IsLoadedMethod · 0.80
GetStringMethod · 0.80
ShowStartupErrorMethod · 0.80
ToStringMethod · 0.45
emptyMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected