mirror of
https://github.com/vcmi/vcmi.git
synced 2025-11-06 09:09:40 +02:00
Code cleanup
This commit is contained in:
@@ -352,7 +352,6 @@ void Zone::fractalize()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Lock lock(areaMutex);
|
|
||||||
//Connect with free areas
|
//Connect with free areas
|
||||||
auto areas = connectedAreas(clearedTiles, true);
|
auto areas = connectedAreas(clearedTiles, true);
|
||||||
for(auto & area : areas)
|
for(auto & area : areas)
|
||||||
|
|||||||
@@ -35,7 +35,6 @@ std::pair<Zone::Lock, Zone::Lock> ConnectionsPlacer::lockZones(std::shared_ptr<Z
|
|||||||
|
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
// FIXME: What if every zone owns its own lock?
|
|
||||||
auto lock1 = Zone::Lock(zone.areaMutex, boost::try_to_lock);
|
auto lock1 = Zone::Lock(zone.areaMutex, boost::try_to_lock);
|
||||||
auto lock2 = Zone::Lock(otherZone->areaMutex, boost::try_to_lock);
|
auto lock2 = Zone::Lock(otherZone->areaMutex, boost::try_to_lock);
|
||||||
|
|
||||||
@@ -59,7 +58,6 @@ void ConnectionsPlacer::process()
|
|||||||
|
|
||||||
while (cp)
|
while (cp)
|
||||||
{
|
{
|
||||||
// FIXME: It does lock ConnectionPlacer, but not areaMutex
|
|
||||||
RecursiveLock lock1(externalAccessMutex, boost::try_to_lock);
|
RecursiveLock lock1(externalAccessMutex, boost::try_to_lock);
|
||||||
RecursiveLock lock2(cp->externalAccessMutex, boost::try_to_lock);
|
RecursiveLock lock2(cp->externalAccessMutex, boost::try_to_lock);
|
||||||
if (lock1.owns_lock() && lock2.owns_lock())
|
if (lock1.owns_lock() && lock2.owns_lock())
|
||||||
@@ -292,7 +290,6 @@ void ConnectionsPlacer::selfSideDirectConnection(const rmg::ZoneConnection & con
|
|||||||
zone.freePaths()->add(guardPos);
|
zone.freePaths()->add(guardPos);
|
||||||
map.setOccupied(guardPos, ETileType::FREE);
|
map.setOccupied(guardPos, ETileType::FREE);
|
||||||
manager.updateDistances(guardPos);
|
manager.updateDistances(guardPos);
|
||||||
// FIXME: Accessing other manager might lead to deadlock
|
|
||||||
otherZone->getModificator<ObjectManager>()->updateDistances(guardPos);
|
otherZone->getModificator<ObjectManager>()->updateDistances(guardPos);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -273,7 +273,6 @@ 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)
|
||||||
{
|
{
|
||||||
float bestDistance = 10e9;
|
float bestDistance = 10e9;
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ void RockFiller::init()
|
|||||||
}
|
}
|
||||||
|
|
||||||
char RockFiller::dump(const int3 & t)
|
char RockFiller::dump(const int3 & t)
|
||||||
{
|
{
|
||||||
if(!map.getTile(t).terType->isPassable())
|
if(!map.getTile(t).terType->isPassable())
|
||||||
{
|
{
|
||||||
return zone.area()->contains(t) ? 'R' : 'E';
|
return zone.area()->contains(t) ? 'R' : 'E';
|
||||||
|
|||||||
@@ -918,7 +918,7 @@ void TreasurePlacer::createTreasures(ObjectManager& manager)
|
|||||||
|
|
||||||
{
|
{
|
||||||
Zone::Lock lock(zone.areaMutex); //We are going to subtract this area
|
Zone::Lock lock(zone.areaMutex); //We are going to subtract this area
|
||||||
|
|
||||||
auto searchArea = zone.areaPossible().get();
|
auto searchArea = zone.areaPossible().get();
|
||||||
searchArea.erase_if([this, &minDistance](const int3& tile) -> bool
|
searchArea.erase_if([this, &minDistance](const int3& tile) -> bool
|
||||||
{
|
{
|
||||||
@@ -954,7 +954,6 @@ void TreasurePlacer::createTreasures(ObjectManager& manager)
|
|||||||
path = manager.placeAndConnectObject(searchArea, rmgObject, minDistance, guarded, false, ObjectManager::OptimizeType::DISTANCE);
|
path = manager.placeAndConnectObject(searchArea, rmgObject, minDistance, guarded, false, ObjectManager::OptimizeType::DISTANCE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//lock.unlock();
|
|
||||||
|
|
||||||
if (path.valid())
|
if (path.valid())
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -43,8 +43,6 @@ void WaterRoutes::process()
|
|||||||
result.push_back(wproxy->waterRoute(*z.second));
|
result.push_back(wproxy->waterRoute(*z.second));
|
||||||
}
|
}
|
||||||
|
|
||||||
//Zone::Lock lock(zone.areaMutex);
|
|
||||||
|
|
||||||
auto area = zone.area();
|
auto area = zone.area();
|
||||||
auto freePaths = zone.freePaths();
|
auto freePaths = zone.freePaths();
|
||||||
auto areaPossible = zone.areaPossible();
|
auto areaPossible = zone.areaPossible();
|
||||||
|
|||||||
Reference in New Issue
Block a user