1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-24 22:14:36 +02:00

Generate underground tunnels first to get a bit more of them.

This commit is contained in:
DjWarmonger 2015-03-28 20:09:54 +01:00
parent a0d9ae4849
commit 9515d51bd2

View File

@ -281,6 +281,44 @@ void CMapGenerator::fillZones()
void CMapGenerator::createObstaclesCommon()
{
#define MAKE_COOL_UNDERGROUND_TUNNELS true
if (map->twoLevel && MAKE_COOL_UNDERGROUND_TUNNELS) //underground
{
std::vector<int3> rockTiles;
for (int x = 0; x < map->width; x++)
{
for (int y = 0; y < map->height; y++)
{
int3 tile(x, y, 1);
if (shouldBeBlocked(tile))
{
bool placeRock = true;
foreach_neighbour(tile, [this, tile, &placeRock](int3 &pos)
{
if (!(this->shouldBeBlocked(pos) || this->isPossible(pos)))
placeRock = false;
});
if (placeRock)
{
rockTiles.push_back(tile);
}
}
}
}
editManager->getTerrainSelection().setSelection(rockTiles);
editManager->drawTerrain(ETerrainType::ROCK, &rand);
for (auto tile : rockTiles)
{
setOccupied(tile, ETileType::USED); //don't place obstacles in a rock
//gen->foreach_neighbour (tile, [gen](int3 &pos)
//{
// if (!gen->isUsed(pos))
// gen->setOccupied (pos, ETileType::BLOCKED);
//});
}
}
//tighten obstacles to improve visuals
for (int i = 0; i < 3; ++i)
@ -322,44 +360,6 @@ void CMapGenerator::createObstaclesCommon()
}
logGlobal->traceStream() << boost::format("Set %d tiles to BLOCKED and %d tiles to FREE") % blockedTiles % freeTiles;
}
#define MAKE_COOL_UNDERGROUND_TUNNELS true
if (map->twoLevel && MAKE_COOL_UNDERGROUND_TUNNELS) //underground
{
std::vector<int3> rockTiles;
for (int x = 0; x < map->width; x++)
{
for (int y = 0; y < map->height; y++)
{
int3 tile(x, y, 1);
if (shouldBeBlocked(tile))
{
bool placeRock = true;
foreach_neighbour(tile, [this, &placeRock](int3 &pos)
{
if (!(this->shouldBeBlocked(pos) || this->isPossible(pos)))
placeRock = false;
});
if (placeRock)
{
rockTiles.push_back(tile);
}
}
}
}
editManager->getTerrainSelection().setSelection(rockTiles);
editManager->drawTerrain(ETerrainType::ROCK, &rand);
for (auto tile : rockTiles)
{
setOccupied(tile, ETileType::USED); //don't place obstacles in a rock
//gen->foreach_neighbour (tile, [gen](int3 &pos)
//{
// if (!gen->isUsed(pos))
// gen->setOccupied (pos, ETileType::BLOCKED);
//});
}
}
}
void CMapGenerator::findZonesForQuestArts()