mirror of
https://github.com/vcmi/vcmi.git
synced 2025-11-06 09:09:40 +02:00
Clean the comments
This commit is contained in:
@@ -117,7 +117,7 @@ ThreadSafeProxy<const rmg::Area> Zone::areaUsed() const
|
|||||||
|
|
||||||
void Zone::clearTiles()
|
void Zone::clearTiles()
|
||||||
{
|
{
|
||||||
//Lock lock(mx);
|
Lock lock(areaMutex);
|
||||||
dArea.clear();
|
dArea.clear();
|
||||||
dAreaPossible.clear();
|
dAreaPossible.clear();
|
||||||
dAreaFree.clear();
|
dAreaFree.clear();
|
||||||
@@ -126,7 +126,6 @@ void Zone::clearTiles()
|
|||||||
void Zone::initFreeTiles()
|
void Zone::initFreeTiles()
|
||||||
{
|
{
|
||||||
rmg::Tileset possibleTiles;
|
rmg::Tileset possibleTiles;
|
||||||
//Lock lock(mx);
|
|
||||||
vstd::copy_if(dArea.getTiles(), vstd::set_inserter(possibleTiles), [this](const int3 &tile) -> bool
|
vstd::copy_if(dArea.getTiles(), vstd::set_inserter(possibleTiles), [this](const int3 &tile) -> bool
|
||||||
{
|
{
|
||||||
return map.isPossible(tile);
|
return map.isPossible(tile);
|
||||||
@@ -239,8 +238,6 @@ TModificators Zone::getModificators()
|
|||||||
void Zone::connectPath(const rmg::Path & path)
|
void Zone::connectPath(const rmg::Path & path)
|
||||||
///connect current tile to any other free tile within zone
|
///connect current tile to any other free tile within zone
|
||||||
{
|
{
|
||||||
//Lock lock(areaMutex);
|
|
||||||
|
|
||||||
areaPossible()->subtract(path.getPathArea());
|
areaPossible()->subtract(path.getPathArea());
|
||||||
freePaths()->unite(path.getPathArea());
|
freePaths()->unite(path.getPathArea());
|
||||||
for(const auto & t : path.getPathArea().getTilesVector())
|
for(const auto & t : path.getPathArea().getTilesVector())
|
||||||
|
|||||||
@@ -477,7 +477,6 @@ void ConnectionsPlacer::createBorder()
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
//Zone::Lock lock(zone.areaMutex); //Protect from erasing same tiles again
|
|
||||||
auto areaPossible = zone.areaPossible();
|
auto areaPossible = zone.areaPossible();
|
||||||
for(const auto & tile : blockBorder.getTilesVector())
|
for(const auto & tile : blockBorder.getTilesVector())
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -118,19 +118,14 @@ void ObjectManager::updateDistances(const int3 & pos)
|
|||||||
|
|
||||||
void ObjectManager::updateDistances(std::function<ui32(const int3 & tile)> distanceFunction)
|
void ObjectManager::updateDistances(std::function<ui32(const int3 & tile)> distanceFunction)
|
||||||
{
|
{
|
||||||
// Workaround to avoid dealock when accessed from other zone
|
// Workaround to avoid deadlock when accessed from other zone
|
||||||
RecursiveLock lock(zone.areaMutex, boost::try_to_lock);
|
RecursiveLock lock(zone.areaMutex, boost::try_to_lock);
|
||||||
if (!lock.owns_lock())
|
if (!lock.owns_lock())
|
||||||
{
|
{
|
||||||
// Sorry, unsolvable problem of mutual impact¯\_(ツ)_/¯
|
// Unsolvable problem of mutual access
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
1. Update map distances - Requires lock on zone area only
|
|
||||||
2. Update tilesByDistance priority queue - Requires lock area AND externalAccessMutex
|
|
||||||
*/
|
|
||||||
|
|
||||||
const auto tiles = zone.areaPossible()->getTilesVector();
|
const auto tiles = zone.areaPossible()->getTilesVector();
|
||||||
//RecursiveLock lock(externalAccessMutex);
|
//RecursiveLock lock(externalAccessMutex);
|
||||||
tilesByDistance.clear();
|
tilesByDistance.clear();
|
||||||
@@ -619,15 +614,8 @@ void ObjectManager::placeObject(rmg::Object & object, bool guarded, bool updateD
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME: Possible deadlock by two managers updating each other
|
for (auto id : sorted)
|
||||||
// At this point areaMutex is locked
|
|
||||||
// TODO: Generic function for multiple spinlocks
|
|
||||||
//std::vector sorted(adjacentZones.begin(), adjacentZones.end());
|
|
||||||
//std::sort(sorted.begin(), sorted.end());
|
|
||||||
//for (auto id : adjacentZones)
|
|
||||||
..for (auto id : sorted)
|
|
||||||
{
|
{
|
||||||
//TODO: Test again with sorted order?
|
|
||||||
auto otherZone = map.getZones().at(id);
|
auto otherZone = map.getZones().at(id);
|
||||||
if ((otherZone->getType() == ETemplateZoneType::WATER) == (zone.getType() == ETemplateZoneType::WATER))
|
if ((otherZone->getType() == ETemplateZoneType::WATER) == (zone.getType() == ETemplateZoneType::WATER))
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -37,7 +37,6 @@ void ObstaclePlacer::process()
|
|||||||
collectPossibleObstacles(zone.getTerrainType());
|
collectPossibleObstacles(zone.getTerrainType());
|
||||||
|
|
||||||
{
|
{
|
||||||
//Zone::Lock lock(zone.areaMutex);
|
|
||||||
auto area = zone.area();
|
auto area = zone.area();
|
||||||
auto areaPossible = zone.areaPossible();
|
auto areaPossible = zone.areaPossible();
|
||||||
auto areaUsed = zone.areaUsed();
|
auto areaUsed = zone.areaUsed();
|
||||||
|
|||||||
@@ -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
|
||||||
// FIXME: Possible area will be regenerated for every object
|
|
||||||
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
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user