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
c47be32b25
commit
967201a68e
@ -135,6 +135,7 @@ rmg::Path ObjectManager::placeAndConnectObject(const rmg::Area & searchArea, rmg
|
|||||||
{
|
{
|
||||||
auto & guardedArea = obj.instances().back()->getAccessibleArea();
|
auto & guardedArea = obj.instances().back()->getAccessibleArea();
|
||||||
accessibleArea.intersect(guardedArea);
|
accessibleArea.intersect(guardedArea);
|
||||||
|
accessibleArea.add(obj.instances().back()->getPosition(true));
|
||||||
}
|
}
|
||||||
|
|
||||||
auto path = zone.searchPath(accessibleArea, onlyStraight, [&obj, isGuarded](const int3 & t)
|
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);
|
auto & unguardedArea = obj.getAccessibleArea(isGuarded);
|
||||||
if(unguardedArea.contains(t) && !guardedArea.contains(t))
|
if(unguardedArea.contains(t) && !guardedArea.contains(t))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
//guard position is always target
|
||||||
|
if(obj.instances().back()->getPosition(true) == t)
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
return !obj.getArea().contains(t);
|
return !obj.getArea().contains(t);
|
||||||
});
|
});
|
||||||
|
@ -88,7 +88,10 @@ void ObstaclePlacer::process()
|
|||||||
if(!possibleObstacles[i].first)
|
if(!possibleObstacles[i].first)
|
||||||
continue;
|
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 handler = VLC->objtypeh->getHandlerFor(temp.id, temp.subid);
|
||||||
auto obj = handler->create(temp);
|
auto obj = handler->create(temp);
|
||||||
|
@ -722,7 +722,7 @@ void TreasurePlacer::createTreasures(ObjectManager & manager)
|
|||||||
if(areaToBlock.overlap(zone.freePaths()) || areaToBlock.overlap(manager.getVisitableArea()))
|
if(areaToBlock.overlap(zone.freePaths()) || areaToBlock.overlap(manager.getVisitableArea()))
|
||||||
return -1.f;
|
return -1.f;
|
||||||
|
|
||||||
return 1.f;
|
return ti.getNearestObjectDistance();
|
||||||
}, guarded, false, false);
|
}, guarded, false, false);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
Loading…
Reference in New Issue
Block a user