mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-22 22:13:35 +02:00
Fix problem with empty areas (#772)
* Fixes for obstacles and treasures
This commit is contained in:
parent
9ec0ca332c
commit
ae63e0c30e
@ -135,6 +135,7 @@ rmg::Path ObjectManager::placeAndConnectObject(const rmg::Area & searchArea, rmg
|
||||
{
|
||||
auto & guardedArea = obj.instances().back()->getAccessibleArea();
|
||||
accessibleArea.intersect(guardedArea);
|
||||
accessibleArea.add(obj.instances().back()->getPosition(true));
|
||||
}
|
||||
|
||||
auto path = zone.searchPath(accessibleArea, onlyStraight, [&obj, isGuarded](const int3 & t)
|
||||
@ -145,6 +146,10 @@ rmg::Path ObjectManager::placeAndConnectObject(const rmg::Area & searchArea, rmg
|
||||
auto & unguardedArea = obj.getAccessibleArea(isGuarded);
|
||||
if(unguardedArea.contains(t) && !guardedArea.contains(t))
|
||||
return false;
|
||||
|
||||
//guard position is always target
|
||||
if(obj.instances().back()->getPosition(true) == t)
|
||||
return true;
|
||||
}
|
||||
return !obj.getArea().contains(t);
|
||||
});
|
||||
|
@ -88,7 +88,10 @@ void ObstaclePlacer::process()
|
||||
if(!possibleObstacles[i].first)
|
||||
continue;
|
||||
|
||||
for(auto & temp : possibleObstacles[i].second)
|
||||
auto shuffledObstacles = possibleObstacles[i].second;
|
||||
RandomGeneratorUtil::randomShuffle(shuffledObstacles, generator.rand);
|
||||
|
||||
for(auto & temp : shuffledObstacles)
|
||||
{
|
||||
auto handler = VLC->objtypeh->getHandlerFor(temp.id, temp.subid);
|
||||
auto obj = handler->create(temp);
|
||||
|
@ -722,7 +722,7 @@ void TreasurePlacer::createTreasures(ObjectManager & manager)
|
||||
if(areaToBlock.overlap(zone.freePaths()) || areaToBlock.overlap(manager.getVisitableArea()))
|
||||
return -1.f;
|
||||
|
||||
return 1.f;
|
||||
return ti.getNearestObjectDistance();
|
||||
}, guarded, false, false);
|
||||
}
|
||||
else
|
||||
|
Loading…
Reference in New Issue
Block a user