chiark / gitweb /
And then screwed the code over...
[rocl] / elite-pairs
index 6f81995aabf26998f453aa0290898fbdcdb60942..5a435cf1d6c7bcef3e7d4e930904ce907446b52d 100755 (executable)
@@ -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]
+      }
     }
   }
 }