ModManager.cpp 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664
  1. /*
  2. * ModManager.cpp, part of VCMI engine
  3. *
  4. * Authors: listed in file AUTHORS in main folder
  5. *
  6. * License: GNU General Public License v2.0 or later
  7. * Full text of license available in license.txt file, in main folder
  8. *
  9. */
  10. #include "StdInc.h"
  11. #include "ModManager.h"
  12. #include "ModDescription.h"
  13. #include "ModScope.h"
  14. #include "../constants/StringConstants.h"
  15. #include "../filesystem/Filesystem.h"
  16. #include "../json/JsonNode.h"
  17. #include "../texts/CGeneralTextHandler.h"
  18. VCMI_LIB_NAMESPACE_BEGIN
  19. static std::string getModDirectory(const TModID & modName)
  20. {
  21. std::string result = modName;
  22. boost::to_upper(result);
  23. boost::algorithm::replace_all(result, ".", "/MODS/");
  24. return "MODS/" + result;
  25. }
  26. static std::string getModSettingsDirectory(const TModID & modName)
  27. {
  28. return getModDirectory(modName) + "/MODS/";
  29. }
  30. static JsonPath getModDescriptionFile(const TModID & modName)
  31. {
  32. return JsonPath::builtin(getModDirectory(modName) + "/mod");
  33. }
  34. ModsState::ModsState()
  35. {
  36. modList.push_back(ModScope::scopeBuiltin());
  37. std::vector<TModID> testLocations = scanModsDirectory("MODS/");
  38. while(!testLocations.empty())
  39. {
  40. std::string target = testLocations.back();
  41. testLocations.pop_back();
  42. modList.push_back(boost::algorithm::to_lower_copy(target));
  43. for(const auto & submod : scanModsDirectory(getModSettingsDirectory(target)))
  44. testLocations.push_back(target + '.' + submod);
  45. }
  46. }
  47. TModList ModsState::getInstalledMods() const
  48. {
  49. return modList;
  50. }
  51. uint32_t ModsState::computeChecksum(const TModID & modName) const
  52. {
  53. boost::crc_32_type modChecksum;
  54. // first - add current VCMI version into checksum to force re-validation on VCMI updates
  55. modChecksum.process_bytes(static_cast<const void*>(GameConstants::VCMI_VERSION.data()), GameConstants::VCMI_VERSION.size());
  56. // second - add mod.json into checksum because filesystem does not contains this file
  57. if (modName != ModScope::scopeBuiltin())
  58. {
  59. auto modConfFile = getModDescriptionFile(modName);
  60. ui32 configChecksum = CResourceHandler::get("initial")->load(modConfFile)->calculateCRC32();
  61. modChecksum.process_bytes(static_cast<const void *>(&configChecksum), sizeof(configChecksum));
  62. }
  63. // third - add all detected text files from this mod into checksum
  64. const auto & filesystem = CResourceHandler::get(modName);
  65. auto files = filesystem->getFilteredFiles([](const ResourcePath & resID)
  66. {
  67. return resID.getType() == EResType::JSON && boost::starts_with(resID.getName(), "CONFIG");
  68. });
  69. for (const ResourcePath & file : files)
  70. {
  71. ui32 fileChecksum = filesystem->load(file)->calculateCRC32();
  72. modChecksum.process_bytes(static_cast<const void *>(&fileChecksum), sizeof(fileChecksum));
  73. }
  74. return modChecksum.checksum();
  75. }
  76. double ModsState::getInstalledModSizeMegabytes(const TModID & modName) const
  77. {
  78. ResourcePath resDir(getModDirectory(modName), EResType::DIRECTORY);
  79. std::string path = CResourceHandler::get()->getResourceName(resDir)->string();
  80. size_t sizeBytes = 0;
  81. for(boost::filesystem::recursive_directory_iterator it(path); it != boost::filesystem::recursive_directory_iterator(); ++it)
  82. {
  83. if(!boost::filesystem::is_directory(*it))
  84. sizeBytes += boost::filesystem::file_size(*it);
  85. }
  86. double sizeMegabytes = sizeBytes / static_cast<double>(1024*1024);
  87. return sizeMegabytes;
  88. }
  89. std::vector<TModID> ModsState::scanModsDirectory(const std::string & modDir) const
  90. {
  91. size_t depth = boost::range::count(modDir, '/');
  92. const auto & modScanFilter = [&](const ResourcePath & id) -> bool
  93. {
  94. if(id.getType() != EResType::DIRECTORY)
  95. return false;
  96. if(!boost::algorithm::starts_with(id.getName(), modDir))
  97. return false;
  98. if(boost::range::count(id.getName(), '/') != depth)
  99. return false;
  100. return true;
  101. };
  102. auto list = CResourceHandler::get("initial")->getFilteredFiles(modScanFilter);
  103. //storage for found mods
  104. std::vector<TModID> foundMods;
  105. for(const auto & entry : list)
  106. {
  107. std::string name = entry.getName();
  108. name.erase(0, modDir.size()); //Remove path prefix
  109. if(name.empty())
  110. continue;
  111. if(name.find('.') != std::string::npos)
  112. continue;
  113. if (ModScope::isScopeReserved(boost::to_lower_copy(name)))
  114. continue;
  115. if(!CResourceHandler::get("initial")->existsResource(JsonPath::builtin(entry.getName() + "/MOD")))
  116. continue;
  117. foundMods.push_back(name);
  118. }
  119. return foundMods;
  120. }
  121. ///////////////////////////////////////////////////////////////////////////////
  122. ModsPresetState::ModsPresetState()
  123. {
  124. static const JsonPath settingsPath = JsonPath::builtin("config/modSettings.json");
  125. if(CResourceHandler::get("local")->existsResource(ResourcePath(settingsPath)))
  126. {
  127. modConfig = JsonNode(settingsPath);
  128. }
  129. else
  130. {
  131. // Probably new install. Create initial configuration
  132. CResourceHandler::get("local")->createResource(settingsPath.getOriginalName() + ".json");
  133. }
  134. if(modConfig["presets"].isNull())
  135. {
  136. modConfig["activePreset"] = JsonNode("default");
  137. if(modConfig["activeMods"].isNull())
  138. createInitialPreset(); // new install
  139. else
  140. importInitialPreset(); // 1.5 format import
  141. }
  142. }
  143. void ModsPresetState::createInitialPreset()
  144. {
  145. // TODO: scan mods directory for all its content? Probably unnecessary since this looks like new install, but who knows?
  146. modConfig["presets"]["default"]["mods"].Vector().emplace_back("vcmi");
  147. }
  148. void ModsPresetState::importInitialPreset()
  149. {
  150. JsonNode preset;
  151. for(const auto & mod : modConfig["activeMods"].Struct())
  152. {
  153. if(mod.second["active"].Bool())
  154. preset["mods"].Vector().emplace_back(mod.first);
  155. for(const auto & submod : mod.second["mods"].Struct())
  156. preset["settings"][mod.first][submod.first] = submod.second["active"];
  157. }
  158. modConfig["presets"]["default"] = preset;
  159. }
  160. const JsonNode & ModsPresetState::getActivePresetConfig() const
  161. {
  162. const std::string & currentPresetName = modConfig["activePreset"].String();
  163. const JsonNode & currentPreset = modConfig["presets"][currentPresetName];
  164. return currentPreset;
  165. }
  166. TModList ModsPresetState::getActiveRootMods() const
  167. {
  168. const JsonNode & modsToActivateJson = getActivePresetConfig()["mods"];
  169. auto modsToActivate = modsToActivateJson.convertTo<std::vector<TModID>>();
  170. if (!vstd::contains(modsToActivate, ModScope::scopeBuiltin()))
  171. modsToActivate.push_back(ModScope::scopeBuiltin());
  172. return modsToActivate;
  173. }
  174. std::map<TModID, bool> ModsPresetState::getModSettings(const TModID & modID) const
  175. {
  176. const JsonNode & modSettingsJson = getActivePresetConfig()["settings"][modID];
  177. auto modSettings = modSettingsJson.convertTo<std::map<TModID, bool>>();
  178. return modSettings;
  179. }
  180. std::optional<uint32_t> ModsPresetState::getValidatedChecksum(const TModID & modName) const
  181. {
  182. const JsonNode & node = modConfig["validatedMods"][modName];
  183. if (node.isNull())
  184. return std::nullopt;
  185. else
  186. return node.Integer();
  187. }
  188. void ModsPresetState::setModActive(const TModID & modID, bool isActive)
  189. {
  190. size_t dotPos = modID.find('.');
  191. if(dotPos != std::string::npos)
  192. {
  193. std::string rootMod = modID.substr(0, dotPos);
  194. std::string settingID = modID.substr(dotPos + 1);
  195. setSettingActive(rootMod, settingID, isActive);
  196. }
  197. else
  198. {
  199. if (isActive)
  200. addRootMod(modID);
  201. else
  202. eraseRootMod(modID);
  203. }
  204. }
  205. void ModsPresetState::addRootMod(const TModID & modName)
  206. {
  207. const std::string & currentPresetName = modConfig["activePreset"].String();
  208. JsonNode & currentPreset = modConfig["presets"][currentPresetName];
  209. if (!vstd::contains(currentPreset["mods"].Vector(), JsonNode(modName)))
  210. currentPreset["mods"].Vector().emplace_back(modName);
  211. }
  212. void ModsPresetState::setSettingActive(const TModID & modName, const TModID & settingName, bool isActive)
  213. {
  214. const std::string & currentPresetName = modConfig["activePreset"].String();
  215. JsonNode & currentPreset = modConfig["presets"][currentPresetName];
  216. currentPreset["settings"][modName][settingName].Bool() = isActive;
  217. }
  218. void ModsPresetState::eraseRootMod(const TModID & modName)
  219. {
  220. const std::string & currentPresetName = modConfig["activePreset"].String();
  221. JsonNode & currentPreset = modConfig["presets"][currentPresetName];
  222. vstd::erase(currentPreset["mods"].Vector(), JsonNode(modName));
  223. }
  224. void ModsPresetState::eraseModSetting(const TModID & modName, const TModID & settingName)
  225. {
  226. const std::string & currentPresetName = modConfig["activePreset"].String();
  227. JsonNode & currentPreset = modConfig["presets"][currentPresetName];
  228. currentPreset["settings"][modName].Struct().erase(modName);
  229. }
  230. std::vector<TModID> ModsPresetState::getActiveMods() const
  231. {
  232. TModList activeRootMods = getActiveRootMods();
  233. TModList allActiveMods;
  234. for(const auto & activeMod : activeRootMods)
  235. {
  236. assert(!vstd::contains(allActiveMods, activeMod));
  237. allActiveMods.push_back(activeMod);
  238. for(const auto & submod : getModSettings(activeMod))
  239. {
  240. if(submod.second)
  241. {
  242. assert(!vstd::contains(allActiveMods, activeMod + '.' + submod.first));
  243. allActiveMods.push_back(activeMod + '.' + submod.first);
  244. }
  245. }
  246. }
  247. return allActiveMods;
  248. }
  249. void ModsPresetState::setValidatedChecksum(const TModID & modName, std::optional<uint32_t> value)
  250. {
  251. if (value.has_value())
  252. modConfig["validatedMods"][modName].Integer() = *value;
  253. else
  254. modConfig["validatedMods"].Struct().erase(modName);
  255. }
  256. void ModsPresetState::saveConfigurationState() const
  257. {
  258. std::fstream file(CResourceHandler::get()->getResourceName(ResourcePath("config/modSettings.json"))->c_str(), std::ofstream::out | std::ofstream::trunc);
  259. file << modConfig.toCompactString();
  260. }
  261. ModsStorage::ModsStorage(const std::vector<TModID> & modsToLoad, const JsonNode & repositoryList)
  262. {
  263. JsonNode coreModConfig(JsonPath::builtin("config/gameConfig.json"));
  264. coreModConfig.setModScope(ModScope::scopeBuiltin());
  265. mods.try_emplace(ModScope::scopeBuiltin(), ModScope::scopeBuiltin(), coreModConfig, JsonNode());
  266. for(auto modID : modsToLoad)
  267. {
  268. if(ModScope::isScopeReserved(modID))
  269. continue;
  270. JsonNode modConfig(getModDescriptionFile(modID));
  271. modConfig.setModScope(modID);
  272. if(modConfig["modType"].isNull())
  273. {
  274. logMod->error("Can not load mod %s - invalid mod config file!", modID);
  275. continue;
  276. }
  277. mods.try_emplace(modID, modID, modConfig, repositoryList[modID]);
  278. }
  279. for(const auto & mod : repositoryList.Struct())
  280. {
  281. if (vstd::contains(modsToLoad, mod.first))
  282. continue;
  283. if (mod.second["modType"].isNull() || mod.second["name"].isNull())
  284. continue;
  285. mods.try_emplace(mod.first, mod.first, JsonNode(), mod.second);
  286. }
  287. }
  288. const ModDescription & ModsStorage::getMod(const TModID & fullID) const
  289. {
  290. return mods.at(fullID);
  291. }
  292. TModList ModsStorage::getAllMods() const
  293. {
  294. TModList result;
  295. for (const auto & mod : mods)
  296. result.push_back(mod.first);
  297. return result;
  298. }
  299. ModManager::ModManager()
  300. :ModManager(JsonNode())
  301. {
  302. }
  303. ModManager::ModManager(const JsonNode & repositoryList)
  304. : modsState(std::make_unique<ModsState>())
  305. , modsPreset(std::make_unique<ModsPresetState>())
  306. {
  307. modsStorage = std::make_unique<ModsStorage>(modsState->getInstalledMods(), repositoryList);
  308. eraseMissingModsFromPreset();
  309. addNewModsToPreset();
  310. std::vector<TModID> desiredModList = modsPreset->getActiveMods();
  311. depedencyResolver = std::make_unique<ModDependenciesResolver>(desiredModList, *modsStorage);
  312. }
  313. ModManager::~ModManager() = default;
  314. const ModDescription & ModManager::getModDescription(const TModID & modID) const
  315. {
  316. assert(boost::to_lower_copy(modID) == modID);
  317. return modsStorage->getMod(modID);
  318. }
  319. bool ModManager::isModSettingActive(const TModID & rootModID, const TModID & modSettingID) const
  320. {
  321. return modsPreset->getModSettings(rootModID).at(modSettingID);
  322. }
  323. bool ModManager::isModActive(const TModID & modID) const
  324. {
  325. return vstd::contains(getActiveMods(), modID);
  326. }
  327. const TModList & ModManager::getActiveMods() const
  328. {
  329. return depedencyResolver->getActiveMods();
  330. }
  331. uint32_t ModManager::computeChecksum(const TModID & modName) const
  332. {
  333. return modsState->computeChecksum(modName);
  334. }
  335. std::optional<uint32_t> ModManager::getValidatedChecksum(const TModID & modName) const
  336. {
  337. return modsPreset->getValidatedChecksum(modName);
  338. }
  339. void ModManager::setValidatedChecksum(const TModID & modName, std::optional<uint32_t> value)
  340. {
  341. modsPreset->setValidatedChecksum(modName, value);
  342. }
  343. void ModManager::saveConfigurationState() const
  344. {
  345. modsPreset->saveConfigurationState();
  346. }
  347. TModList ModManager::getAllMods() const
  348. {
  349. return modsStorage->getAllMods();
  350. }
  351. double ModManager::getInstalledModSizeMegabytes(const TModID & modName) const
  352. {
  353. return modsState->getInstalledModSizeMegabytes(modName);
  354. }
  355. void ModManager::eraseMissingModsFromPreset()
  356. {
  357. const TModList & installedMods = modsState->getInstalledMods();
  358. const TModList & rootMods = modsPreset->getActiveRootMods();
  359. for(const auto & rootMod : rootMods)
  360. {
  361. if(!vstd::contains(installedMods, rootMod))
  362. {
  363. modsPreset->eraseRootMod(rootMod);
  364. continue;
  365. }
  366. const auto & modSettings = modsPreset->getModSettings(rootMod);
  367. for(const auto & modSetting : modSettings)
  368. {
  369. TModID fullModID = rootMod + '.' + modSetting.first;
  370. if(!vstd::contains(installedMods, fullModID))
  371. {
  372. modsPreset->eraseModSetting(rootMod, modSetting.first);
  373. continue;
  374. }
  375. }
  376. }
  377. }
  378. void ModManager::addNewModsToPreset()
  379. {
  380. const TModList & installedMods = modsState->getInstalledMods();
  381. for(const auto & modID : installedMods)
  382. {
  383. size_t dotPos = modID.find('.');
  384. if(dotPos == std::string::npos)
  385. continue; // only look up submods aka mod settings
  386. std::string rootMod = modID.substr(0, dotPos);
  387. std::string settingID = modID.substr(dotPos + 1);
  388. const auto & modSettings = modsPreset->getModSettings(rootMod);
  389. if (!modSettings.count(settingID))
  390. modsPreset->setSettingActive(rootMod, settingID, !modsStorage->getMod(modID).keepDisabled());
  391. }
  392. }
  393. TModList ModManager::collectDependenciesRecursive(const TModID & modID) const
  394. {
  395. TModList result;
  396. TModList toTest;
  397. toTest.push_back(modID);
  398. while (!toTest.empty())
  399. {
  400. TModID currentModID = toTest.back();
  401. const auto & currentMod = getModDescription(currentModID);
  402. toTest.pop_back();
  403. result.push_back(currentModID);
  404. if (!currentMod.isInstalled())
  405. throw std::runtime_error("Unable to enable mod " + modID + "! Dependency " + currentModID + " is not installed!");
  406. for (const auto & dependency : currentMod.getDependencies())
  407. {
  408. if (!vstd::contains(result, dependency))
  409. toTest.push_back(dependency);
  410. }
  411. }
  412. return result;
  413. }
  414. void ModManager::tryEnableMods(const TModList & modList)
  415. {
  416. TModList requiredActiveMods;
  417. TModList additionalActiveMods = getActiveMods();
  418. for (const auto & modName : modList)
  419. {
  420. for (const auto & dependency : collectDependenciesRecursive(modName))
  421. {
  422. if (!vstd::contains(requiredActiveMods, dependency))
  423. {
  424. requiredActiveMods.push_back(dependency);
  425. vstd::erase(additionalActiveMods, dependency);
  426. }
  427. }
  428. assert(!vstd::contains(additionalActiveMods, modName));
  429. assert(vstd::contains(requiredActiveMods, modName));// FIXME: fails on attempt to enable broken mod / translation to other language
  430. }
  431. ModDependenciesResolver testResolver(requiredActiveMods, *modsStorage);
  432. testResolver.tryAddMods(additionalActiveMods, *modsStorage);
  433. for (const auto & modName : modList)
  434. if (!vstd::contains(testResolver.getActiveMods(), modName))
  435. throw std::runtime_error("Failed to enable mod! Mod " + modName + " remains disabled!");
  436. updatePreset(testResolver);
  437. }
  438. void ModManager::tryDisableMod(const TModID & modName)
  439. {
  440. auto desiredActiveMods = getActiveMods();
  441. assert(vstd::contains(desiredActiveMods, modName));
  442. vstd::erase(desiredActiveMods, modName);
  443. ModDependenciesResolver testResolver(desiredActiveMods, *modsStorage);
  444. if (vstd::contains(testResolver.getActiveMods(), modName))
  445. throw std::runtime_error("Failed to disable mod! Mod " + modName + " remains enabled!");
  446. modsPreset->setModActive(modName, false);
  447. updatePreset(testResolver);
  448. }
  449. void ModManager::updatePreset(const ModDependenciesResolver & testResolver)
  450. {
  451. const auto & newActiveMods = testResolver.getActiveMods();
  452. const auto & newBrokenMods = testResolver.getBrokenMods();
  453. for (const auto & modID : newActiveMods)
  454. {
  455. assert(vstd::contains(modsState->getInstalledMods(), modID));
  456. modsPreset->setModActive(modID, true);
  457. }
  458. for (const auto & modID : newBrokenMods)
  459. {
  460. const auto & mod = getModDescription(modID);
  461. if (vstd::contains(newActiveMods, mod.getTopParentID()))
  462. modsPreset->setModActive(modID, false);
  463. }
  464. std::vector<TModID> desiredModList = modsPreset->getActiveMods();
  465. depedencyResolver = std::make_unique<ModDependenciesResolver>(desiredModList, *modsStorage);
  466. // TODO: check activation status of submods of new mods
  467. modsPreset->saveConfigurationState();
  468. }
  469. ModDependenciesResolver::ModDependenciesResolver(const TModList & modsToResolve, const ModsStorage & storage)
  470. {
  471. tryAddMods(modsToResolve, storage);
  472. }
  473. const TModList & ModDependenciesResolver::getActiveMods() const
  474. {
  475. return activeMods;
  476. }
  477. const TModList & ModDependenciesResolver::getBrokenMods() const
  478. {
  479. return brokenMods;
  480. }
  481. void ModDependenciesResolver::tryAddMods(TModList modsToResolve, const ModsStorage & storage)
  482. {
  483. // Topological sort algorithm.
  484. boost::range::sort(modsToResolve); // Sort mods per name
  485. std::vector<TModID> sortedValidMods(activeMods.begin(), activeMods.end()); // Vector keeps order of elements (LIFO)
  486. std::set<TModID> resolvedModIDs(activeMods.begin(), activeMods.end()); // Use a set for validation for performance reason, but set does not keep order of elements
  487. std::set<TModID> notResolvedModIDs(modsToResolve.begin(), modsToResolve.end()); // Use a set for validation for performance reason
  488. // Mod is resolved if it has no dependencies or all its dependencies are already resolved
  489. auto isResolved = [&](const ModDescription & mod) -> bool
  490. {
  491. if (mod.isTranslation() && CGeneralTextHandler::getPreferredLanguage() != mod.getBaseLanguage())
  492. return false;
  493. if(mod.getDependencies().size() > resolvedModIDs.size())
  494. return false;
  495. for(const TModID & dependency : mod.getDependencies())
  496. if(!vstd::contains(resolvedModIDs, dependency))
  497. return false;
  498. for(const TModID & softDependency : mod.getSoftDependencies())
  499. if(vstd::contains(notResolvedModIDs, softDependency))
  500. return false;
  501. for(const TModID & conflict : mod.getConflicts())
  502. if(vstd::contains(resolvedModIDs, conflict))
  503. return false;
  504. for(const TModID & reverseConflict : resolvedModIDs)
  505. if(vstd::contains(storage.getMod(reverseConflict).getConflicts(), mod.getID()))
  506. return false;
  507. return true;
  508. };
  509. while(true)
  510. {
  511. std::set<TModID> resolvedOnCurrentTreeLevel;
  512. for(auto it = modsToResolve.begin(); it != modsToResolve.end();) // One iteration - one level of mods tree
  513. {
  514. if(isResolved(storage.getMod(*it)))
  515. {
  516. resolvedOnCurrentTreeLevel.insert(*it); // Not to the resolvedModIDs, so current node children will be resolved on the next iteration
  517. assert(!vstd::contains(sortedValidMods, *it));
  518. sortedValidMods.push_back(*it);
  519. it = modsToResolve.erase(it);
  520. continue;
  521. }
  522. it++;
  523. }
  524. if(!resolvedOnCurrentTreeLevel.empty())
  525. {
  526. resolvedModIDs.insert(resolvedOnCurrentTreeLevel.begin(), resolvedOnCurrentTreeLevel.end());
  527. for(const auto & it : resolvedOnCurrentTreeLevel)
  528. notResolvedModIDs.erase(it);
  529. continue;
  530. }
  531. // If there are no valid mods on the current mods tree level, no more mod can be resolved, should be ended.
  532. break;
  533. }
  534. assert(!sortedValidMods.empty());
  535. activeMods = sortedValidMods;
  536. brokenMods.insert(brokenMods.end(), modsToResolve.begin(), modsToResolve.end());
  537. }
  538. VCMI_LIB_NAMESPACE_END