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:
@@ -537,21 +537,24 @@ void MapController::commitObjectCreate(int level)
|
||||
}
|
||||
|
||||
bool MapController::canPlaceObject(int level, CGObjectInstance * newObj, QString & error) const
|
||||
{
|
||||
//find all objects of such type
|
||||
int objCounter = 0;
|
||||
for(auto o : _map->objects)
|
||||
{
|
||||
if(newObj->ID == Obj::GRAIL) //special case for grail
|
||||
{
|
||||
if(o->ID == newObj->ID && o->subID == newObj->subID)
|
||||
//find all objects of such type
|
||||
int objCounter = 0;
|
||||
for(auto o : _map->objects)
|
||||
{
|
||||
++objCounter;
|
||||
if(o->ID == newObj->ID && o->subID == newObj->subID)
|
||||
{
|
||||
++objCounter;
|
||||
}
|
||||
}
|
||||
|
||||
if(objCounter >= 1)
|
||||
{
|
||||
error = QObject::tr("There can only be one grail object on the map.");
|
||||
return false; //maplimit reached
|
||||
}
|
||||
}
|
||||
|
||||
if(newObj->ID == Obj::GRAIL && objCounter >= 1) //special case for grail
|
||||
{
|
||||
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))
|
||||
|
||||
Reference in New Issue
Block a user