| 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) { |
no test coverage detected