瀏覽代碼

Remove target and origin only

DricomDragon 5 年之前
父節點
當前提交
e93f030f35
共有 1 個文件被更改,包括 3 次插入4 次删除
  1. 3 4
      main.cc

+ 3 - 4
main.cc

@@ -215,12 +215,11 @@ class World
 			} while (!targetIsReached && !open.empty());
 
 			// Remove origin and target
-			if (!discovered.empty()) {
+			if (!discovered.empty() && discovered.front() == origin)
 				discovered.pop_front();
 
-				if (!discovered.empty())
-					discovered.pop_back();
-			}
+			if (!discovered.empty() && discovered.back() == target)
+				discovered.pop_back();
 
 			// Build path
 			if (targetIsReached) {