3 # $Id: elite-path,v 1.2 2003/02/25 00:25:38 mdw Exp $
5 package require "elite" "1.0.0"
10 for {set i 0} {$i < [llength $argv]} {incr i} {
11 set a [lindex $argv $i]
15 set a [lindex $argv $i]
16 set g [parse-galaxy-spec $a]
17 if {[string equal $g ""]} {
18 puts stderr "$argv0: bad galaxy string `$a'"
25 set a [lindex $argv $i]
26 set weight "weight-$a"
27 if {[lsearch -exact [info commands "weight-*"] $weight] == -1} {
28 puts stderr "$argv0: unknown weight function `$a'"
29 puts stderr "$argv0: I know [info commands weight-*]"
38 puts stderr "unknown switch `$a'"
52 foreach a [lrange $argv $i end] {
53 set s [parse-planet-spec $g $a]
54 if {[string equal $s ""]} {
55 puts stderr "$argv0: unknown planet `$a'"
58 if {![info exists px($s)]} {
59 puts stderr "$argv0: planet `$a' doesn't exist in galaxy $ng"
64 if {[llength $r] < 2} {
65 puts stderr "usage: $argv0 \[-g GALAXY\] \[-w WEIGHT\] PLANET PLANET ..."
68 puts -nonewline stderr "\[computing adjacency table..."
71 set home [lindex $r 0]
73 foreach w [lrange $r 1 end] {
74 destructure {p .} [shortest-path adj $home $w $weight]
76 puts -stderr "$argv0: no route from [worldinfo $home] to [worldinfo $w]"
84 if {![string equal $s $last]} {
85 puts [world-summary $s]