mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-26 22:57:00 +02:00
Correct underground terrains. More improvements for connection placement.
This commit is contained in:
parent
d4d3f1a568
commit
5fb07ded38
@ -251,7 +251,8 @@ void CMapGenerator::createConnections()
|
||||
continue;
|
||||
foreach_neighbour (tile, [&guardPos, tile, &otherZoneTiles, this](int3 &pos)
|
||||
{
|
||||
if (vstd::contains(otherZoneTiles, pos) && !this->isBlocked(pos))
|
||||
//if (vstd::contains(otherZoneTiles, pos) && !this->isBlocked(pos))
|
||||
if (vstd::contains(otherZoneTiles, pos))
|
||||
guardPos = tile;
|
||||
});
|
||||
if (guardPos.valid())
|
||||
@ -285,17 +286,32 @@ void CMapGenerator::createConnections()
|
||||
float distanceFromA = posA.dist2d(tile);
|
||||
float distanceFromB = posB.dist2d(tile);
|
||||
|
||||
if (distanceFromA + distanceFromB > std::max(zoneA->getSize() + zoneB->getSize(), distance))
|
||||
if (distanceFromA + distanceFromB > std::max<int>(zoneA->getSize() + zoneB->getSize(), distance))
|
||||
break; //we are too far away to ever connect
|
||||
|
||||
//if zone is underground, gate must lay withing its (reduced) radius
|
||||
if (distanceFromA > 3 && (!posA.z || distanceFromA < zoneA->getSize() - 3) &&
|
||||
distanceFromB > 3 && (!posB.z || distanceFromB < zoneB->getSize() - 3))
|
||||
//if zone is underground, gate must fit within its (reduced) radius
|
||||
if (distanceFromA > 5 && (!posA.z || distanceFromA < zoneA->getSize() - 3) &&
|
||||
distanceFromB > 5 && (!posB.z || distanceFromB < zoneB->getSize() - 3))
|
||||
{
|
||||
otherTile = tile;
|
||||
otherTile.z = posB.z;
|
||||
|
||||
if (vstd::contains(tiles, tile) && vstd::contains(otherZoneTiles, otherTile))
|
||||
{
|
||||
bool withinZone = true;
|
||||
|
||||
foreach_neighbour (tile, [&withinZone, &tiles](int3 &pos)
|
||||
{
|
||||
if (!vstd::contains(tiles, pos))
|
||||
withinZone = false;
|
||||
});
|
||||
foreach_neighbour (otherTile, [&withinZone, &otherZoneTiles](int3 &pos)
|
||||
{
|
||||
if (!vstd::contains(otherZoneTiles, pos))
|
||||
withinZone = false;
|
||||
});
|
||||
|
||||
if (withinZone)
|
||||
{
|
||||
auto gate1 = new CGTeleport;
|
||||
gate1->ID = Obj::SUBTERRANEAN_GATE;
|
||||
@ -308,6 +324,7 @@ void CMapGenerator::createConnections()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (stop)
|
||||
continue;
|
||||
}
|
||||
|
@ -839,7 +839,17 @@ void CRmgTemplateZone::initTerrainType (CMapGenerator* gen)
|
||||
else
|
||||
terrainType = *RandomGeneratorUtil::nextItem(terrainTypes, gen->rand);
|
||||
|
||||
//paint zone with matching terrain
|
||||
//TODO: allow new types of terrain?
|
||||
if (pos.z)
|
||||
{
|
||||
if (terrainType != ETerrainType::LAVA)
|
||||
terrainType = ETerrainType::SUBTERRANEAN;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (terrainType == ETerrainType::SUBTERRANEAN)
|
||||
terrainType = ETerrainType::DIRT;
|
||||
}
|
||||
|
||||
paintZoneTerrain (gen, terrainType);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user