From d10711928fd87a6cb3f163c22ed926d8935b3c42 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Zieli=C5=84ski?= Date: Mon, 29 Jul 2024 21:56:07 +0200 Subject: [PATCH] Allow connecting zone to itself (always through the portal) --- lib/rmg/modificators/ConnectionsPlacer.cpp | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/lib/rmg/modificators/ConnectionsPlacer.cpp b/lib/rmg/modificators/ConnectionsPlacer.cpp index ab53acce0..f585cb60d 100644 --- a/lib/rmg/modificators/ConnectionsPlacer.cpp +++ b/lib/rmg/modificators/ConnectionsPlacer.cpp @@ -55,6 +55,18 @@ void ConnectionsPlacer::process() { for (auto& c : dConnections) { + if (c.getZoneA() == c.getZoneB()) + { + // Zone can always be connected to itself, but only by monolith pair + RecursiveLock lock(externalAccessMutex); + if (!vstd::contains(dCompleted, c)) + { + placeMonolithConnection(c); + // FIXME: Two pair of monoliths are added instead of 1 + continue; + } + } + auto otherZone = map.getZones().at(c.getZoneB()); auto* cp = otherZone->getModificator(); @@ -126,7 +138,6 @@ void ConnectionsPlacer::forcePortalConnection(const rmg::ZoneConnection & connec if (connection.getConnectionType() == rmg::EConnectionType::FORCE_PORTAL) { placeMonolithConnection(connection); - dCompleted.push_back(connection); } } @@ -427,10 +438,6 @@ void ConnectionsPlacer::selfSideIndirectConnection(const rmg::ZoneConnection & c { placeMonolithConnection(connection); } - else - { - dCompleted.push_back(connection); - } } void ConnectionsPlacer::placeMonolithConnection(const rmg::ZoneConnection & connection) @@ -448,6 +455,8 @@ void ConnectionsPlacer::placeMonolithConnection(const rmg::ZoneConnection & conn RequiredObjectInfo obj2(teleport2, connection.getGuardStrength(), allowRoad); zone.getModificator()->addRequiredObject(obj1); otherZone->getModificator()->addRequiredObject(obj2); + + dCompleted.push_back(connection); assert(otherZone->getModificator()); otherZone->getModificator()->otherSideConnection(connection);