1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-09-16 09:26:28 +02:00

Moar optimization!

This commit is contained in:
DjWarmonger
2016-08-09 13:40:46 +02:00
parent 7f0b852449
commit 2bffd4e5c1
4 changed files with 14 additions and 9 deletions

View File

@@ -479,6 +479,8 @@ void CMapGenerator::createConnections()
int3 posA = zoneA->getPos();
int3 posB = zoneB->getPos();
auto zoneAid = zoneA->getId();
auto zoneBid = zoneB->getId();
if (posA.z == posB.z)
{
@@ -487,9 +489,9 @@ void CMapGenerator::createConnections()
{
if (isBlocked(tile)) //tiles may be occupied by subterranean gates already placed
continue;
foreachDirectNeighbour (tile, [&guardPos, tile, &otherZoneTiles, &middleTiles, this](int3 &pos) //must be direct since paths also also generated between direct neighbours
foreachDirectNeighbour (tile, [&guardPos, tile, &otherZoneTiles, &middleTiles, this, zoneBid](int3 &pos) //must be direct since paths also also generated between direct neighbours
{
if (vstd::contains(otherZoneTiles, pos))
if (getZoneID(pos) == zoneBid)
middleTiles.push_back(tile);
});
}
@@ -572,18 +574,18 @@ void CMapGenerator::createConnections()
distanceFromB > 5 && (!posB.z || distanceFromB < zoneB->getSize() - 3))
{
//all neightbouring tiles also belong to zone
if (vstd::contains(tiles, tile) && vstd::contains(otherZoneTiles, otherTile))
if (getZoneID(tile) == zoneAid && getZoneID(otherTile) == zoneBid)
{
bool withinZone = true;
foreach_neighbour (tile, [&withinZone, &tiles](int3 &pos)
foreach_neighbour (tile, [&withinZone, &tiles, zoneAid, this](int3 &pos)
{
if (!vstd::contains(tiles, pos))
if (getZoneID(pos) != zoneAid)
withinZone = false;
});
foreach_neighbour (otherTile, [&withinZone, &otherZoneTiles](int3 &pos)
foreach_neighbour (otherTile, [&withinZone, &otherZoneTiles, zoneBid, this](int3 &pos)
{
if (!vstd::contains(otherZoneTiles, pos))
if (getZoneID(pos) != zoneBid)
withinZone = false;
});