1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-27 22:49:25 +02:00

iterate objects only for grail special case

This commit is contained in:
MichalZr6
2025-03-21 15:47:45 +01:00
parent 9f8c4d3747
commit e3a661f91a

View File

@@ -537,6 +537,8 @@ void MapController::commitObjectCreate(int level)
}
bool MapController::canPlaceObject(int level, CGObjectInstance * newObj, QString & error) const
{
if(newObj->ID == Obj::GRAIL) //special case for grail
{
//find all objects of such type
int objCounter = 0;
@@ -548,11 +550,12 @@ bool MapController::canPlaceObject(int level, CGObjectInstance * newObj, QString
}
}
if(newObj->ID == Obj::GRAIL && objCounter >= 1) //special case for grail
if(objCounter >= 1)
{
error = QObject::tr("There can only be one grail object on the map.");
return false; //maplimit reached
}
}
if(defaultPlayer == PlayerColor::NEUTRAL && (newObj->ID == Obj::HERO || newObj->ID == Obj::RANDOM_HERO))
{