X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~mdw/git/rocl/blobdiff_plain/1304202ad2001c85d3eae3a37c51e001794c24c8..486cb648a93f2833bb97cee17c6a90fb7a271fcb:/elite-pairs diff --git a/elite-pairs b/elite-pairs index 6f81995..5a435cf 100755 --- a/elite-pairs +++ b/elite-pairs @@ -1,6 +1,8 @@ #! /usr/bin/tclsh +# +# $Id: elite-pairs,v 1.4 2003/03/07 00:41:46 mdw Exp $ -package require "elite" "1.0.0" +package require "elite" "1.0.1" proc ok {s vv expr} { global argv0 @@ -29,6 +31,7 @@ proc ok {s vv expr} { set g $galaxy1 set d 70 +set v 0 for {set i 0} {$i < [llength $argv]} {incr i} { set a [lindex $argv $i] switch -glob -- $a { @@ -44,14 +47,20 @@ for {set i 0} {$i < [llength $argv]} {incr i} { } "-d" { incr i - set d [expr {[lindex $argv $i] * 10}] + set d [expr {int([lindex $argv $i] * 10)}] + } + "-v" { + incr v + } + "-q" { + incr v -1 } "--" { incr i break } "-*" { - puts stderr "usage: $argv0 \[-g GALAXY\] \[-d DIST\] AEXPR BEXPR" + puts stderr "usage: $argv0 \[-qv\] \[-g GALAXY\] \[-d DIST\] AEXPR BEXPR" exit 1 } default { @@ -64,21 +73,24 @@ if {$i != [llength $argv] - 2} { exit 1 } destructure {aexpr bexpr} [lrange $argv $i end] -puts -nonewline stderr "\[computing adjacency table..." -flush stderr -set ww [worldinfo $g] -adjacency $ww adj $d -puts stderr " done\]" +set ww [elite-galaxylist $g] +elite-adjacency adj $ww $d unset a foreach {s x y} $ww { if {![ok $s {} $aexpr]} { continue } elite-worldinfo a $s set l {} foreach {ss xx yy} $adj($s) { - set d [world-distance $x $y $xx $yy] + set d [elite-distance $x $y $xx $yy] if {[ok $ss {a d} $bexpr]} { - puts [format "%-11s %-11s (%.1f LY)" $a(name) [worldname $ss] \ - [expr {[world-distance $x $y $xx $yy]/10.0}]] + set d [expr {[elite-distance $x $y $xx $yy]/10.0}] + if {$v} { + puts [format "%s (%.1f LY)" [world-summary $s] $d] + puts [world-summary $ss] + puts "" + } else { + puts [format "%-11s %-11s (%.1f LY)" $a(name) [worldname $ss] $d] + } } } }