mirror of
https://github.com/vcmi/vcmi.git
synced 2025-03-31 22:05:10 +02:00
Update distances in all zones adjacent to object
This commit is contained in:
parent
ca0eacc283
commit
44fae4945d
@ -216,6 +216,7 @@ int3 ObjectManager::findPlaceForObject(const rmg::Area & searchArea, rmg::Object
|
|||||||
|
|
||||||
rmg::Path ObjectManager::placeAndConnectObject(const rmg::Area & searchArea, rmg::Object & obj, si32 min_dist, bool isGuarded, bool onlyStraight, OptimizeType optimizer) const
|
rmg::Path ObjectManager::placeAndConnectObject(const rmg::Area & searchArea, rmg::Object & obj, si32 min_dist, bool isGuarded, bool onlyStraight, OptimizeType optimizer) const
|
||||||
{
|
{
|
||||||
|
RecursiveLock lock(externalAccessMutex);
|
||||||
return placeAndConnectObject(searchArea, obj, [this, min_dist, &obj](const int3 & tile)
|
return placeAndConnectObject(searchArea, obj, [this, min_dist, &obj](const int3 & tile)
|
||||||
{
|
{
|
||||||
auto ti = map.getTileInfo(tile);
|
auto ti = map.getTileInfo(tile);
|
||||||
@ -455,8 +456,31 @@ void ObjectManager::placeObject(rmg::Object & object, bool guarded, bool updateD
|
|||||||
map.setOccupied(i, ETileType::BLOCKED);
|
map.setOccupied(i, ETileType::BLOCKED);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(updateDistance)
|
if (updateDistance)
|
||||||
updateDistances(object);
|
{
|
||||||
|
//Update distances in every adjacent zone in case of wide connection
|
||||||
|
|
||||||
|
std::set<TRmgTemplateZoneId> adjacentZones;
|
||||||
|
auto objectArea = object.getArea();
|
||||||
|
objectArea.unite(objectArea.getBorderOutside());
|
||||||
|
|
||||||
|
for (auto tile : objectArea.getTilesVector())
|
||||||
|
{
|
||||||
|
if (map.isOnMap(tile))
|
||||||
|
{
|
||||||
|
adjacentZones.insert(map.getZoneID(tile));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (auto id : adjacentZones)
|
||||||
|
{
|
||||||
|
auto manager = map.getZones().at(id)->getModificator<ObjectManager>();
|
||||||
|
if (manager)
|
||||||
|
{
|
||||||
|
manager->updateDistances(object);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for(auto * instance : object.instances())
|
for(auto * instance : object.instances())
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user