From 9515d51bd2dd9d652020a98907163a52ecf2fdc2 Mon Sep 17 00:00:00 2001 From: DjWarmonger Date: Sat, 28 Mar 2015 20:09:54 +0100 Subject: [PATCH] Generate underground tunnels first to get a bit more of them. --- lib/rmg/CMapGenerator.cpp | 76 +++++++++++++++++++-------------------- 1 file changed, 38 insertions(+), 38 deletions(-) diff --git a/lib/rmg/CMapGenerator.cpp b/lib/rmg/CMapGenerator.cpp index 56e00b2f6..ca8b7e031 100644 --- a/lib/rmg/CMapGenerator.cpp +++ b/lib/rmg/CMapGenerator.cpp @@ -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 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 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()