1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-11-24 08:32:34 +02:00

Fix race condition when placing object at teh shore

This commit is contained in:
Tomasz Zieliński 2024-02-04 08:56:21 +01:00
parent 6528124c1e
commit 7ce3553a6d

View File

@ -579,11 +579,15 @@ void ObjectManager::placeObject(rmg::Object & object, bool guarded, bool updateD
for (auto id : adjacentZones)
{
auto manager = map.getZones().at(id)->getModificator<ObjectManager>();
if (manager)
auto otherZone = map.getZones().at(id);
if ((otherZone->getType() == ETemplateZoneType::WATER) == (zone.getType() == ETemplateZoneType::WATER))
{
// TODO: Update distances for perimeter of guarded object, not just treasures
manager->updateDistances(object);
// Do not update other zone if only one is water
auto manager = otherZone->getModificator<ObjectManager>();
if (manager)
{
manager->updateDistances(object);
}
}
}
}