1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-03-03 14:52:11 +02:00

map editor: check hero and town spells during mod assessment

This commit is contained in:
godric3 2024-08-07 21:29:21 +02:00
parent a4dd510735
commit 18e96171de

View File

@ -613,16 +613,49 @@ ModCompatibilityInfo MapController::modAssessmentAll()
ModCompatibilityInfo MapController::modAssessmentMap(const CMap & map)
{
ModCompatibilityInfo result;
auto extractEntityMod = [&result](const auto & entity)
{
auto modName = QString::fromStdString(entity->getJsonKey()).split(":").at(0).toStdString();
if(modName != "core")
result[modName] = VLC->modh->getModInfo(modName).getVerificationInfo();
};
for(auto obj : map.objects)
{
if(obj->ID == Obj::HERO)
continue; //stub!
auto handler = obj->getObjectHandler();
auto modName = QString::fromStdString(handler->getJsonKey()).split(":").at(0).toStdString();
if(modName != "core")
result[modName] = VLC->modh->getModInfo(modName).getVerificationInfo();
if(obj->ID == Obj::TOWN || obj->ID == Obj::RANDOM_TOWN)
{
auto town = dynamic_cast<CGTownInstance *>(obj.get());
for(const auto & spellID : town->possibleSpells)
{
if(spellID == SpellID::PRESET)
continue;
extractEntityMod(spellID.toEntity(VLC));
}
for(const auto & spellID : town->obligatorySpells)
{
extractEntityMod(spellID.toEntity(VLC));
}
}
if(obj->ID == Obj::HERO || obj->ID == Obj::RANDOM_HERO)
{
auto hero = dynamic_cast<CGHeroInstance *>(obj.get());
for(const auto & spellID : hero->getSpellsInSpellbook())
{
if(spellID == SpellID::PRESET || spellID == SpellID::SPELLBOOK_PRESET)
continue;
extractEntityMod(spellID.toEntity(VLC));
}
}
}
//TODO: terrains?
//TODO: terrains, artifacts?
return result;
}