fix(routes): connect new burg to land route only

This commit is contained in:
Azgaar 2025-04-17 13:11:23 +02:00
parent fd9e010153
commit 8dad1a3bac
3 changed files with 11 additions and 9 deletions

View file

@ -547,14 +547,7 @@ window.Burgs = (() => {
cells.burg[cellId] = burgId; cells.burg[cellId] = burgId;
const newRoute = Routes.connect(cellId); const newRoute = Routes.connect(cellId);
if (newRoute && layerIsOn("toggleRoutes")) { if (newRoute && layerIsOn("toggleRoutes")) drawRoute(newRoute);
const path = Routes.getPath(newRoute);
routes
.select("#" + newRoute.group)
.append("path")
.attr("d", path)
.attr("id", "route" + newRoute.i);
}
drawBurgIcon(burg); drawBurgIcon(burg);
drawBurgLabel(burg); drawBurgLabel(burg);

View file

@ -360,7 +360,8 @@ window.Routes = (function () {
// connect cell with routes system by land // connect cell with routes system by land
function connect(cellId) { function connect(cellId) {
const getCost = createCostEvaluator({isWater: false, connections: new Map()}); const getCost = createCostEvaluator({isWater: false, connections: new Map()});
const pathCells = findPath(cellId, isConnected, getCost); const isExit = cellId => isLand(cellId) && isConnected(cellId);
const pathCells = findPath(cellId, isExit, getCost);
if (!pathCells) return; if (!pathCells) return;
const pointsArray = preparePointsArray(); const pointsArray = preparePointsArray();

View file

@ -845,6 +845,14 @@ function drawRoutes() {
TIME && console.timeEnd("drawRoutes"); TIME && console.timeEnd("drawRoutes");
} }
function drawRoute(route) {
routes
.select("#" + route.group)
.append("path")
.attr("d", Routes.getPath(route))
.attr("id", "route" + route.i);
}
function toggleMilitary(event) { function toggleMilitary(event) {
if (!layerIsOn("toggleMilitary")) { if (!layerIsOn("toggleMilitary")) {
turnButtonOn("toggleMilitary"); turnButtonOn("toggleMilitary");