mirror of
https://github.com/vcmi/vcmi.git
synced 2025-08-15 20:03:15 +02:00
Even tighter obstacles.
This commit is contained in:
@@ -1116,24 +1116,38 @@ void CRmgTemplateZone::createTreasures(CMapGenerator* gen)
|
|||||||
void CRmgTemplateZone::createObstacles(CMapGenerator* gen)
|
void CRmgTemplateZone::createObstacles(CMapGenerator* gen)
|
||||||
{
|
{
|
||||||
//tighten obstacles to improve visuals
|
//tighten obstacles to improve visuals
|
||||||
for (auto tile : tileinfo)
|
|
||||||
{
|
|
||||||
if (!gen->isPossible(tile)) //only possible tiles can change
|
|
||||||
continue;
|
|
||||||
|
|
||||||
int blockedNeighbours = 0;
|
for (int i = 0; i < 3; ++i)
|
||||||
int freeNeighbours = 0;
|
{
|
||||||
gen->foreach_neighbour(tile, [gen, &blockedNeighbours, &freeNeighbours](int3 &pos)
|
int blockedTiles = 0;
|
||||||
|
int freeTiles = 0;
|
||||||
|
|
||||||
|
for (auto tile : tileinfo)
|
||||||
{
|
{
|
||||||
if (gen->isBlocked(pos))
|
if (!gen->isPossible(tile)) //only possible tiles can change
|
||||||
blockedNeighbours++;
|
continue;
|
||||||
if (gen->isFree(pos))
|
|
||||||
freeNeighbours++;
|
int blockedNeighbours = 0;
|
||||||
});
|
int freeNeighbours = 0;
|
||||||
if (blockedNeighbours > 4)
|
gen->foreach_neighbour(tile, [gen, &blockedNeighbours, &freeNeighbours](int3 &pos)
|
||||||
gen->setOccupied(tile, ETileType::BLOCKED);
|
{
|
||||||
else if (freeNeighbours > 4)
|
if (gen->isBlocked(pos))
|
||||||
gen->setOccupied(tile, ETileType::FREE);
|
blockedNeighbours++;
|
||||||
|
if (gen->isFree(pos))
|
||||||
|
freeNeighbours++;
|
||||||
|
});
|
||||||
|
if (blockedNeighbours > 4)
|
||||||
|
{
|
||||||
|
gen->setOccupied(tile, ETileType::BLOCKED);
|
||||||
|
blockedTiles++;
|
||||||
|
}
|
||||||
|
else if (freeNeighbours > 4)
|
||||||
|
{
|
||||||
|
gen->setOccupied(tile, ETileType::FREE);
|
||||||
|
freeTiles++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
logGlobal->infoStream() << boost::format("Set %d tiles to BLOCKED and %d tiles to FREE") % blockedTiles % freeTiles;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pos.z) //underground
|
if (pos.z) //underground
|
||||||
|
Reference in New Issue
Block a user