1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-26 22:57:00 +02:00

Place objects away from wide connection

This commit is contained in:
Tomasz Zieliński 2023-06-18 19:20:12 +02:00
parent 47726625c2
commit 8510af487e
3 changed files with 14 additions and 0 deletions

View File

@ -147,6 +147,7 @@ void ConnectionsPlacer::selfSideDirectConnection(const rmg::ZoneConnection & con
{
zone.connectPath(ourPath);
otherZone->connectPath(theirPath);
otherZone->getModificator<ObjectManager>()->updateDistances(potentialPos);
success = true;
break;

View File

@ -86,6 +86,18 @@ void ObjectManager::updateDistances(const rmg::Object & obj)
}
}
void ObjectManager::updateDistances(const int3 & pos)
{
RecursiveLock lock(externalAccessMutex);
tilesByDistance.clear();
for (auto tile : zone.areaPossible().getTiles()) //don't need to mark distance for not possible tiles
{
ui32 d = pos.dist2dSQ(tile); //optimization, only relative distance is interesting
map.setNearestObjectDistance(tile, std::min(static_cast<float>(d), map.getNearestObjectDistance(tile)));
tilesByDistance.push(std::make_pair(tile, map.getNearestObjectDistance(tile)));
}
}
const rmg::Area & ObjectManager::getVisitableArea() const
{
RecursiveLock lock(externalAccessMutex);

View File

@ -62,6 +62,7 @@ public:
void placeObject(rmg::Object & object, bool guarded, bool updateDistance);
void updateDistances(const rmg::Object & obj);
void updateDistances(const int3& pos);
void createDistancesPriorityQueue();
const rmg::Area & getVisitableArea() const;