mirror of
https://github.com/vcmi/vcmi.git
synced 2025-02-03 13:01:33 +02:00
Do not calculate area for invalid positions
This commit is contained in:
parent
2d3b8ee866
commit
b9193ecb73
@ -84,16 +84,27 @@ int ObstacleProxy::getWeightedObjects(const int3 & tile, CRandomGenerator & rand
|
||||
rmg::Object * rmgObject = &allObjects.back();
|
||||
for(const auto & offset : obj->getBlockedOffsets())
|
||||
{
|
||||
rmgObject->setPosition(tile - offset);
|
||||
auto newPos = tile - offset;
|
||||
|
||||
if(!isInTheMap(rmgObject->getPosition()))
|
||||
if(!isInTheMap(newPos))
|
||||
continue;
|
||||
|
||||
if(!rmgObject->getArea().getSubarea([this](const int3 & t)
|
||||
rmgObject->setPosition(newPos);
|
||||
|
||||
bool isInTheMapEntirely = true;
|
||||
for (const auto & t : rmgObject->getArea().getTiles())
|
||||
{
|
||||
if (!isInTheMap(t))
|
||||
{
|
||||
isInTheMapEntirely = false;
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
if (!isInTheMapEntirely)
|
||||
{
|
||||
return !isInTheMap(t);
|
||||
}).empty())
|
||||
continue;
|
||||
}
|
||||
|
||||
if(isProhibited(rmgObject->getArea()))
|
||||
continue;
|
||||
|
Loading…
x
Reference in New Issue
Block a user