From 78eddfe5d23e4e2a09d637c6377a0bf0416e3849 Mon Sep 17 00:00:00 2001 From: t-moe Date: Fri, 17 Jun 2016 01:06:01 +0200 Subject: [PATCH] Fixed pathfinding bug. --- src/ch/bfh/sevennotseven/Game.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/ch/bfh/sevennotseven/Game.java b/src/ch/bfh/sevennotseven/Game.java index 5386028..7cdf98a 100644 --- a/src/ch/bfh/sevennotseven/Game.java +++ b/src/ch/bfh/sevennotseven/Game.java @@ -132,7 +132,7 @@ public class Game { } - return reconstructShortestPath(allVerticies, dst); + return reconstructShortestPath(allVerticies, src,dst); } public boolean doUndo(){ @@ -214,7 +214,7 @@ public class Game { return null; } - private List reconstructShortestPath(final List vertices, final Point dst) { + private List reconstructShortestPath(final List vertices, final Point src, final Point dst) { ArrayList path = new ArrayList(); path.add(dst); Vertex u = findVertex(dst, vertices); @@ -225,6 +225,9 @@ public class Game { u= u.getPrev(); path.add(0, u.getPos()); } + if(u!=findVertex(src, vertices)) { + return null; + } return path; } /**