diff --git a/lib/rmg/modificators/ConnectionsPlacer.cpp b/lib/rmg/modificators/ConnectionsPlacer.cpp index fecf7c951..d51e9aadb 100644 --- a/lib/rmg/modificators/ConnectionsPlacer.cpp +++ b/lib/rmg/modificators/ConnectionsPlacer.cpp @@ -147,6 +147,7 @@ void ConnectionsPlacer::selfSideDirectConnection(const rmg::ZoneConnection & con { zone.connectPath(ourPath); otherZone->connectPath(theirPath); + otherZone->getModificator()->updateDistances(potentialPos); success = true; break; diff --git a/lib/rmg/modificators/ObjectManager.cpp b/lib/rmg/modificators/ObjectManager.cpp index c82e632e0..15a4f890a 100644 --- a/lib/rmg/modificators/ObjectManager.cpp +++ b/lib/rmg/modificators/ObjectManager.cpp @@ -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(d), map.getNearestObjectDistance(tile))); + tilesByDistance.push(std::make_pair(tile, map.getNearestObjectDistance(tile))); + } +} + const rmg::Area & ObjectManager::getVisitableArea() const { RecursiveLock lock(externalAccessMutex); diff --git a/lib/rmg/modificators/ObjectManager.h b/lib/rmg/modificators/ObjectManager.h index 243407fa4..5e17a3303 100644 --- a/lib/rmg/modificators/ObjectManager.h +++ b/lib/rmg/modificators/ObjectManager.h @@ -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;