1
0
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:
DjWarmonger
2014-09-23 16:53:26 +02:00
parent 84e2f07c18
commit 87ecd0075e

View File

@@ -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