From 74b480f95b24f714c5a06f9f04b2683ef7ebd7fe Mon Sep 17 00:00:00 2001 From: deuce <> Date: Thu, 28 Feb 2008 16:45:39 +0000 Subject: [PATCH] Fix path finding to work correctly with one-way warps. Add crlf after the path is displayed in the computer. --- xtrn/tw2/computer.js | 2 ++ xtrn/tw2/sectors.js | 15 ++++----------- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/xtrn/tw2/computer.js b/xtrn/tw2/computer.js index 752d5a7763..5d9abb5cc9 100644 --- a/xtrn/tw2/computer.js +++ b/xtrn/tw2/computer.js @@ -65,6 +65,8 @@ function ComputerMenu() console.write(" - "); console.write(path[i]); } + console.crlf(); + console.crlf(); } } break; diff --git a/xtrn/tw2/sectors.js b/xtrn/tw2/sectors.js index d581dccc8d..153b9f537d 100644 --- a/xtrn/tw2/sectors.js +++ b/xtrn/tw2/sectors.js @@ -281,6 +281,7 @@ function ShortestPath(start, end) if(univ[univ[pos].Warps[i]]==undefined) { univ[univ[pos].Warps[i]]=sectors.Get(univ[pos].Warps[i]); univ[univ[pos].Warps[i]].hops=hops; + univ[univ[pos].Warps[i]].from=pos; if(univ[pos].Warps[i]==end) return(true); } @@ -304,17 +305,9 @@ function ShortestPath(start, end) } ret.push(end); for(i=end;i!=start;) { - var lasthop=i; - for(j=0; j<univ[i].Warps.length; j++) { - if(univ[univ[i].Warps[j]]!=undefined && univ[univ[i].Warps[j]].hops<univ[i].hops) { - i=univ[i].Warps[j]; - if(i!=start) - ret.unshift(i); - break; - } - } - if(i==lasthop) - return(null); + i=univ[i].from; + if(i!=start) + ret.unshift(i); } return(ret); } -- GitLab