ActiveModsInSaveList.cpp 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /*
  2. * ActiveModsInSaveList.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 "ActiveModsInSaveList.h"
  12. #include "../VCMI_Lib.h"
  13. #include "ModDescription.h"
  14. #include "CModHandler.h"
  15. #include "ModIncompatibility.h"
  16. VCMI_LIB_NAMESPACE_BEGIN
  17. std::vector<TModID> ActiveModsInSaveList::getActiveGameplayAffectingMods()
  18. {
  19. std::vector<TModID> result;
  20. for (auto const & entry : VLC->modh->getActiveMods())
  21. if (VLC->modh->getModInfo(entry).affectsGameplay())
  22. result.push_back(entry);
  23. return result;
  24. }
  25. ModVerificationInfo ActiveModsInSaveList::getVerificationInfo(TModID mod)
  26. {
  27. return VLC->modh->getModInfo(mod).getVerificationInfo();
  28. }
  29. void ActiveModsInSaveList::verifyActiveMods(const std::map<TModID, ModVerificationInfo> & modList)
  30. {
  31. auto comparison = ModVerificationInfo::verifyListAgainstLocalMods(modList);
  32. std::vector<TModID> missingMods;
  33. std::vector<TModID> excessiveMods;
  34. for (auto const & compared : comparison)
  35. {
  36. if (compared.second == ModVerificationStatus::NOT_INSTALLED)
  37. missingMods.push_back(modList.at(compared.first).name);
  38. if (compared.second == ModVerificationStatus::DISABLED)
  39. missingMods.push_back(VLC->modh->getModInfo(compared.first).getName());
  40. if (compared.second == ModVerificationStatus::EXCESSIVE)
  41. excessiveMods.push_back(VLC->modh->getModInfo(compared.first).getName());
  42. }
  43. if(!missingMods.empty() || !excessiveMods.empty())
  44. throw ModIncompatibility(missingMods, excessiveMods);
  45. }
  46. VCMI_LIB_NAMESPACE_END