3 package require "elite" "1.0.0"
5 set syms "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
8 if {$i < [string length $syms]} {
9 return [string index $syms $i]
11 set hi [expr {$i / [string length $syms]}]
12 set lo [expr {$i % [string length $syms]}]
13 return [string index $syms $hi][string index $syms $lo]
16 proc show-map {asp wx wy ww {n ""}} {
23 if {$x < $minx} { set minx $x}
24 if {$y < $miny} { set miny $y}
25 if {$x > $maxx} { set maxx $x}
26 if {$y > $maxy} { set maxy $y}
28 set dx [expr {$maxx - $minx}]
29 set dy [expr {$maxy - $miny}]
30 if {$dx == 0} { set dx 1 }
31 if {$dy == 0} { set dy 1 }
33 set sc [expr {$wx/double($dx)}]
34 if {$dy * $sc/$asp > $wy} {
35 set sc [expr {$wy * $asp/double($dy)}]
39 set gx [expr {int(($x - $minx) * $sc + 0.5)}]
40 set gy [expr {int(($y - $miny) * $sc/$asp + 0.5)}]
41 lappend gw [list $s $gx $gy]
44 set pw [lsort -index 1 -integer -increasing $gw]
45 set pw [lsort -index 2 -integer -increasing $pw]
51 destructure {s px py} $w
53 puts -nonewline [string repeat "\n" [expr {$py - $y}]]
58 puts -nonewline [string repeat " " [expr {$px - $x}]]
61 if {[string equal $s $n]} {
68 incr x [string length $sy]
77 if {![string equal $n ""]} {
82 set out [format "%2s %s" $sy [world-summary $s]]
83 if {![string equal $n ""]} {
84 append out [format " (%.1f LY)" \
85 [expr {[world-distance $p(x) $p(y) $pp(x) $pp(y)]/10.0}]]
91 proc local-area {g d n} {
97 if {abs($p(x) - $x) > $d + 10 || abs($p(y) - $y) > $d + 10 ||
98 [world-distance $p(x) $p(y) $x $y] > $d} { continue }
110 set usage "usage: $argv0 \[-qv\] \[-g GAL\] \[-d DIST\] \[-w WD,HT\] \[-a ASP\] \[PLANET\]"
111 for {set i 0} {$i < [llength $argv]} {incr i} {
112 set a [lindex $argv $i]
116 set a [lindex $argv $i]
117 set g [parse-galaxy-spec $a]
118 if {[string equal $g ""]} {
119 puts stderr "$argv0: bad galaxy string `$a'"
126 set d [expr {[lindex $argv $i] * 10}]
130 if {![regexp {^(\d+),(\d+)$} [lindex $argv $i] . wx wy]} {
131 puts stderr "$argv0: bad window size string"
137 set asp [lindex $argv $i]
159 set p [lrange $argv $i end]
160 switch -exact [llength $p] {
167 set n [parse-planet-spec $g $a]
168 if {[string equal $n ""]} {
169 puts stderr "$argv0: unknown planet `$a'"
172 set w [local-area $g $d $n]
179 set l [show-map $asp $wx $wy $w $n]