1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-22 22:13:35 +02:00
vcmi/lib/modding/ActiveModsInSaveList.cpp

59 lines
1.7 KiB
C++
Raw Normal View History

/*
* ActiveModsInSaveList.cpp, part of VCMI engine
*
* Authors: listed in file AUTHORS in main folder
*
* License: GNU General Public License v2.0 or later
* Full text of license available in license.txt file, in main folder
*
*/
#include "StdInc.h"
#include "ActiveModsInSaveList.h"
#include "../VCMI_Lib.h"
#include "CModInfo.h"
#include "CModHandler.h"
#include "ModIncompatibility.h"
VCMI_LIB_NAMESPACE_BEGIN
std::vector<TModID> ActiveModsInSaveList::getActiveGameplayAffectingMods()
{
std::vector<TModID> result;
for (auto const & entry : VLC->modh->getActiveMods())
if (VLC->modh->getModInfo(entry).checkModGameplayAffecting())
result.push_back(entry);
return result;
}
const ModVerificationInfo & ActiveModsInSaveList::getVerificationInfo(TModID mod)
{
return VLC->modh->getModInfo(mod).getVerificationInfo();
}
2024-04-16 15:30:22 +02:00
void ActiveModsInSaveList::verifyActiveMods(const std::map<TModID, ModVerificationInfo> & modList)
{
2024-04-16 15:30:22 +02:00
auto comparison = ModVerificationInfo::verifyListAgainstLocalMods(modList);
std::vector<TModID> missingMods;
std::vector<TModID> excessiveMods;
2024-04-16 15:30:22 +02:00
for (auto const & compared : comparison)
{
2024-04-16 15:30:22 +02:00
if (compared.second == ModVerificationStatus::NOT_INSTALLED)
missingMods.push_back(modList.at(compared.first).name);
2024-04-16 15:30:22 +02:00
if (compared.second == ModVerificationStatus::DISABLED)
missingMods.push_back(VLC->modh->getModInfo(compared.first).getVerificationInfo().name);
2024-04-16 15:30:22 +02:00
if (compared.second == ModVerificationStatus::EXCESSIVE)
2024-04-27 12:57:50 +02:00
excessiveMods.push_back(VLC->modh->getModInfo(compared.first).getVerificationInfo().name);
}
2024-04-16 15:30:22 +02:00
if(!missingMods.empty() || !excessiveMods.empty())
throw ModIncompatibility(missingMods, excessiveMods);
}
VCMI_LIB_NAMESPACE_END