1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-01-14 02:33:51 +02:00

Possible tweak for underground.

This commit is contained in:
DjWarmonger 2014-09-22 15:27:42 +02:00
parent b96ab55c4d
commit 3e36d0d88b

View File

@ -1115,6 +1115,27 @@ void CRmgTemplateZone::createTreasures(CMapGenerator* gen)
void CRmgTemplateZone::createObstacles(CMapGenerator* gen) void CRmgTemplateZone::createObstacles(CMapGenerator* gen)
{ {
//tighten obstacles to improve visuals
for (auto tile : tileinfo)
{
if (!gen->isPossible(tile)) //only possible tiles can change
continue;
int blockedNeighbours = 0;
int freeNeighbours = 0;
gen->foreach_neighbour(tile, [gen, &blockedNeighbours, &freeNeighbours](int3 &pos)
{
if (gen->isBlocked(pos))
blockedNeighbours++;
if (gen->isFree(pos))
freeNeighbours++;
});
if (blockedNeighbours > 4)
gen->setOccupied(tile, ETileType::BLOCKED);
else if (freeNeighbours > 4)
gen->setOccupied(tile, ETileType::FREE);
}
if (pos.z) //underground if (pos.z) //underground
{ {
std::vector<int3> rockTiles; std::vector<int3> rockTiles;
@ -1137,15 +1158,15 @@ void CRmgTemplateZone::createObstacles(CMapGenerator* gen)
} }
gen->editManager->getTerrainSelection().setSelection(rockTiles); gen->editManager->getTerrainSelection().setSelection(rockTiles);
gen->editManager->drawTerrain(ETerrainType::ROCK, &gen->rand); gen->editManager->drawTerrain(ETerrainType::ROCK, &gen->rand);
//for (auto tile : rockTiles) for (auto tile : rockTiles)
//{ {
// gen->setOccupied (tile, ETileType::USED); gen->setOccupied (tile, ETileType::USED); //don't place obstacles in a rock
// gen->foreach_neighbour (tile, [gen](int3 &pos) //gen->foreach_neighbour (tile, [gen](int3 &pos)
// { //{
// if (!gen->isUsed(pos)) // if (!gen->isUsed(pos))
// gen->setOccupied (pos, ETileType::BLOCKED); // gen->setOccupied (pos, ETileType::BLOCKED);
// }); //});
//} }
} }
typedef std::vector<ObjectTemplate> obstacleVector; typedef std::vector<ObjectTemplate> obstacleVector;
//obstacleVector possibleObstacles; //obstacleVector possibleObstacles;
@ -1195,27 +1216,6 @@ void CRmgTemplateZone::createObstacles(CMapGenerator* gen)
return false; return false;
}; };
//tighten obstacles to improve visuals
for (auto tile : tileinfo)
{
if (!gen->isPossible(tile)) //only possible tiles can change
continue;
int blockedNeighbours = 0;
int freeNeighbours = 0;
gen->foreach_neighbour(tile, [gen, &blockedNeighbours, &freeNeighbours](int3 &pos)
{
if (gen->isBlocked(pos))
blockedNeighbours++;
if (gen->isFree(pos))
freeNeighbours++;
});
if (blockedNeighbours > 4)
gen->setOccupied(tile, ETileType::BLOCKED);
else if (freeNeighbours > 4)
gen->setOccupied(tile, ETileType::FREE);
}
//reverse order, since obstacles begin in bottom-right corner, while the map coordinates begin in top-left //reverse order, since obstacles begin in bottom-right corner, while the map coordinates begin in top-left
for (auto tile : boost::adaptors::reverse(tileinfo)) for (auto tile : boost::adaptors::reverse(tileinfo))
{ {