| 162 | } |
| 163 | |
| 164 | void PluginList::refresh(const QString& profileName, |
| 165 | const DirectoryEntry& baseDirectory, |
| 166 | const QString& lockedOrderFile, bool force) |
| 167 | { |
| 168 | TimeThis tt("PluginList::refresh()"); |
| 169 | |
| 170 | if (force) { |
| 171 | m_ESPs.clear(); |
| 172 | m_ESPsByName.clear(); |
| 173 | m_ESPsByPriority.clear(); |
| 174 | } |
| 175 | |
| 176 | ChangeBracket<PluginList> layoutChange(this); |
| 177 | |
| 178 | QStringList primaryPlugins = m_GamePlugin->primaryPlugins(); |
| 179 | QStringList enabledPlugins = m_GamePlugin->enabledPlugins(); |
| 180 | auto gamePlugins = m_Organizer.gameFeatures().gameFeature<GamePlugins>(); |
| 181 | const bool lightPluginsAreSupported = |
| 182 | gamePlugins ? gamePlugins->lightPluginsAreSupported() : false; |
| 183 | const bool mediumPluginsAreSupported = |
| 184 | gamePlugins ? gamePlugins->mediumPluginsAreSupported() : false; |
| 185 | const bool loadOrderMechanismNone = |
| 186 | m_GamePlugin->loadOrderMechanism() == IPluginGame::LoadOrderMechanism::None; |
| 187 | |
| 188 | m_CurrentProfile = profileName; |
| 189 | |
| 190 | std::unordered_map<QString, FileEntryPtr> availablePlugins; |
| 191 | QStringList archiveCandidates; |
| 192 | |
| 193 | for (FileEntryPtr current : baseDirectory.getFiles()) { |
| 194 | if (current.get() == nullptr) { |
| 195 | continue; |
| 196 | } |
| 197 | const QString& filename = ToQString(current->getName()); |
| 198 | |
| 199 | if (filename.endsWith(".esp", Qt::CaseInsensitive) || |
| 200 | filename.endsWith(".esm", Qt::CaseInsensitive) || |
| 201 | filename.endsWith(".esl", Qt::CaseInsensitive)) { |
| 202 | availablePlugins.insert(std::make_pair(filename, current)); |
| 203 | } else if (filename.endsWith(".bsa", Qt::CaseInsensitive) || |
| 204 | filename.endsWith("ba2", Qt::CaseInsensitive)) { |
| 205 | archiveCandidates.append(filename); |
| 206 | } |
| 207 | } |
| 208 | |
| 209 | for (const auto& [filename, current] : availablePlugins) { |
| 210 | if (m_ESPsByName.contains(filename)) { |
| 211 | continue; |
| 212 | } |
| 213 | |
| 214 | bool forceLoaded = Settings::instance().game().forceEnableCoreFiles() && |
| 215 | primaryPlugins.contains(filename, Qt::CaseInsensitive); |
| 216 | bool forceEnabled = enabledPlugins.contains(filename, Qt::CaseInsensitive); |
| 217 | bool forceDisabled = loadOrderMechanismNone && !forceLoaded && !forceEnabled; |
| 218 | if (!lightPluginsAreSupported && filename.endsWith(".esl")) { |
| 219 | forceDisabled = true; |
| 220 | } |
| 221 |
nothing calls this directly
no test coverage detected