1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-03-21 21:17:49 +02:00

Add validation for hero duplicate

This commit is contained in:
nordsoft 2023-04-22 20:08:52 +04:00 committed by Nordsoft91
parent bab84309a5
commit 1de9a57a76

View File

@ -74,6 +74,8 @@ std::list<Validator::Issue> Validator::validate(const CMap * map)
if(!hplayers)
issues.emplace_back("No human players allowed to play this map", true);
std::set<CHero*> allHeroesOnMap; //used to find hero duplicated
//checking all objects in the map
for(auto o : map->objects)
{
@ -121,6 +123,9 @@ std::list<Validator::Issue> Validator::validate(const CMap * map)
{
if(!map->allowedHeroes[ins->type->getId().getNum()])
issues.emplace_back(QString("Hero %1 is prohibited by map settings").arg(ins->type->getNameTranslated().c_str()), false);
if(!allHeroesOnMap.insert(ins->type).second)
issues.emplace_back(QString("Hero %1 has duplicate on map").arg(ins->type->getNameTranslated().c_str()), false);
}
else
issues.emplace_back(QString("Hero %1 has an empty type and must be removed").arg(ins->instanceName.c_str()), true);