From 5a74fac289a7d687527c4cad2eb5b9fcd62a5135 Mon Sep 17 00:00:00 2001 From: Mark Wooding Date: Thu, 5 May 2016 10:29:47 +0100 Subject: [PATCH] Mostly style cleanups and commentary. This is a bit of a mess I found in crybaby's working tree, but I don't think there's any really major work in here. --- DEVGUIDE | 10 +- Makefile | 34 +++--- Makefile.NT | 2 +- README | 4 +- debian/changelog | 2 +- debian/control | 1 - debian/rules | 2 +- elite-cmdr | 201 +++++++++++++++++++++++++++-------- elite-describe | 40 ++++++- elite-editor | 38 +++---- elite-find | 2 +- elite-map | 3 - elite-pairs | 2 +- elite-prices | 2 +- elite-reach | 84 +++++++++++++-- elite-tantalus | 2 +- elite.c | 28 +++-- elite.tcl | 319 +++++++++++++++++++++++++++---------------------------- graph.c | 10 +- vec.c | 8 +- vec.h | 8 +- 21 files changed, 495 insertions(+), 307 deletions(-) diff --git a/DEVGUIDE b/DEVGUIDE index 5cb167b..3e51a53 100644 --- a/DEVGUIDE +++ b/DEVGUIDE @@ -22,7 +22,7 @@ Package `elite' y in decilightyears from galaxy top government as integer: 0 .. 7 are anarchy .. corp-state economy as integer: 0 .. 7 are rich-ind .. poor-agri - techlevel the tech level, + techlevel the tech level population in 100 million productivity in M Cr radius in km @@ -62,7 +62,7 @@ Package `elite' mission mission status code world-x in dly from left world-y in dly from top - gal-seed + gal-seed credits in tenths of a credit fuel in tenths of a lightyear gal-number 1 .. 8 seem sensible @@ -79,7 +79,7 @@ Package `elite' station-PRODUCT quantity of product at station ecm just true or false - fuel-scoop + fuel-scoop energy-bomb energy-unit docking-computer @@ -87,7 +87,7 @@ Package `elite' escape-pod missiles number; 0 .. 4 are usual - legal-status 0 = clean; 1 .. 49 = offender; + legal-status 0 = clean; 1 .. 49 = offender; 50+ = fugitive score number @@ -265,7 +265,7 @@ Package `graph' -cool FACTOR Cooling factor. [1.001] -dead COUNT Give up after COUNT cycles. [200] -inner COUNT Do COUNT loops for each cooling cycle. - [10000] + [10000] -temp TEMP Start at this temperature. [unhelpful] diff --git a/Makefile b/Makefile index b6f6d71..31b10dc 100644 --- a/Makefile +++ b/Makefile @@ -1,21 +1,18 @@ -# Makefile for RIGHT ON COMMAND-LINE -# -# $Id$ +### Makefile for RIGHT ON COMMAND-LINE -#----- Configuration stuff -------------------------------------------------- - -# --- Compiling and linking --- +###-------------------------------------------------------------------------- +### Configuration stuff. +## Compiling and linking. CC = gcc -INCLUDES = +INCLUDES = CFLAGS = \ - -O2 -g -pedantic -Wall -funroll-loops -fomit-frame-pointer \ + -O2 -g -Wall -funroll-loops -fomit-frame-pointer \ $(INCLUDES) LD = gcc LDFLAGS = -shared -# --- Installation --- - +## Installation. INST = prefix = /usr/local tcllibdir = $(prefix)/lib @@ -25,9 +22,10 @@ bindir = $(prefix)/bin INSTALL = install RM = rm -#----- Main machinery ------------------------------------------------------- -# -# Shouldn't need to fiddle with thiis stuff. +###-------------------------------------------------------------------------- +### Main machinery. +### +### Shouldn't need to fiddle with this stuff. PACKAGE = rocl VERSION = 1.1.5 @@ -47,15 +45,17 @@ elite.so: elite.o $(LD) $(LDFLAGS) elite.o -o elite.so vec.so: vec.o $(LD) $(LDFLAGS) vec.o -o vec.so -graph.so: graph.o - $(LD) $(LDFLAGS) graph.o -o graph.so +graph.so: graph.o vec.so + $(LD) $(LDFLAGS) -Wl,-rpath,$(pkglibdir) graph.o vec.so -o graph.so graph.o vec.o: vec.h .SUFFIXES: .c .o .c.o:; $(CC) -c $(CFLAGS) -o $@ $< pkgIndex.tcl: $(PKGFILES) - echo "pkg_mkIndex -verbose -direct -load Vec . $(PKGFILES) " | tclsh + LD_LIBRARY_PATH=$$(pwd) \ + echo "pkg_mkIndex -verbose -direct -load Vec . $(PKGFILES) " | \ + tclsh install: all $(INSTALL) -d $(INST)$(bindir) $(INST)$(pkglibdir) @@ -107,4 +107,4 @@ distcheck: dist .PHONY: all install clean dist disttar distzip distdir distcheck -#----- That's all, folks ---------------------------------------------------- +###----- That's all, folks -------------------------------------------------- diff --git a/Makefile.NT b/Makefile.NT index 93f82ee..ddc871a 100644 --- a/Makefile.NT +++ b/Makefile.NT @@ -50,7 +50,7 @@ elite.dll: elite.o elite.def vec.dll vec.dll.a: vec.o vec.def $(LD) $(LDFLAGS) vec.o vec.def $(LIBS) \ -o vec.dll -Wl,--out-implib,vec.dll.a -graph.dll: graph.o graph.def vec.dll.a +graph.dll: graph.o graph.def vec.dll.a $(LD) $(LDFLAGS) graph.o graph.def $(LIBS) vec.dll.a -o graph.dll graph.o vec.o: vec.h diff --git a/README b/README index e03f7e8..c3d9307 100644 --- a/README +++ b/README @@ -56,7 +56,7 @@ RIGHT ON COMMAND-LINE A `galaxy-spec' is * a number, between 1 and 8, for one of the standard eight - galaxies; + galaxies; * a `galaxy seed' of 12 hex digits (a 48-bit value), for any arbitrary galaxy; or @@ -484,7 +484,7 @@ RIGHT ON COMMAND-LINE program slower) and where the shortest path is more than RATIO times the distance in each GALAXY specified -- by default the eight standard ones. - + 3. The graphical editor diff --git a/debian/changelog b/debian/changelog index f860733..59695f9 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,7 +1,7 @@ rocl (1.1.5) experimental; urgency=low * Add elite-tantalus. - + -- Mark Wooding Wed, 22 Sep 2004 23:43:29 +0100 rocl (1.1.4) experimental; urgency=low diff --git a/debian/control b/debian/control index 6b33251..e0a9117 100644 --- a/debian/control +++ b/debian/control @@ -13,4 +13,3 @@ Description: Elite tools for the discerning player some C extensions, for analysing the Elite universe and editing original BBC version commander files, as also used by Elite: The New Kind by Christian Pinder. - diff --git a/debian/rules b/debian/rules index af37146..b837317 100755 --- a/debian/rules +++ b/debian/rules @@ -41,4 +41,4 @@ source: d=`pwd`; cd ..; dpkg-source -i -b $$d/=inst=/=deb=/* rm -rf =inst= -.PHONY: binary binary-arch binary-indep clean install source +.PHONY: binary binary-arch binary-indep clean install source diff --git a/elite-cmdr b/elite-cmdr index f574f68..b0d500c 100755 --- a/elite-cmdr +++ b/elite-cmdr @@ -1,45 +1,82 @@ #! /usr/bin/tclsh +### +### Commander file inspector +### +### (c) 2003 Mark Wooding +### + +###----- Licensing notice --------------------------------------------------- +### +### This program is free software; you can redistribute it and/or modify +### it under the terms of the GNU General Public License as published by +### the Free Software Foundation; either version 2 of the License, or +### (at your option) any later version. +### +### This program is distributed in the hope that it will be useful, +### but WITHOUT ANY WARRANTY; without even the implied warranty of +### MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +### GNU General Public License for more details. +### +### You should have received a copy of the GNU General Public License +### along with this program; if not, write to the Free Software Foundation, +### Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. package require "elite" "1.0.1" -if {[llength $argv] < 1} { - puts stderr "usage: $argv0 \[-OPTION | ATTR | ATTR=VALUE\] ..." - exit 1 +###-------------------------------------------------------------------------- +### Various type handlers. +### +### We associate a named type and some optional (type-specific) parameters +### with each attribute in the commander file format. For each TYPE, there +### are Tcl procedures: +### +### get/TYPE [PARAM ...] A -- return presentation form of the attribute A +### dump/TYPE [PARAM ...] A -- return an external form of the attribute A +### set/TYPE [PARAM ...] A V -- convert V from presentation form and store +### as the attribute A + +proc dump-like-get {type} { + ## Define dump/TYPE as a synonym for get/TYPE. + + proc dump/$type {args} [list uplevel 1 get/$type \$args] } -jameson cmdr +## string -- just a plain unconverted string. proc get/string {a} { global cmdr; return $cmdr($a) } -proc dump/string {a} { global cmdr; return $cmdr($a) } +dump-like-get string proc set/string {a v} { global cmdr; set cmdr($a) $v } +## int MIN MAX -- an integer constrained to lie between the stated +## (inclusive) bounds. proc get/int {min max a} { global cmdr return [format "%d" [expr {$cmdr($a) + 0}]] } -proc dump/int {min max a} { - global cmdr - return [format "%d" [expr {$cmdr($a) + 0}]] -} +dump-like-get int proc set/int {min max a v} { global cmdr if {$v < $min || $v > $max} { error "value out of range" } set cmdr($a) $v } +## tenth MIN MAX -- a numerical value constrained to lie between the stated +## inclusive bounds; the internal format is an integer containing ten times +## the presentation value. proc get/tenth {min max a} { global cmdr return [format "%.1f" [expr {$cmdr($a)/10.0}]] } -proc dump/tenth {min max a} { - global cmdr - return [format "%.1f" [expr {$cmdr($a)/10.0}]] -} +dump-like-get tenth proc set/tenth {min max a v} { global cmdr if {$v < $min || $v > $max} { error "value out of range" } set cmdr($a) [expr {int($v * 10)}] } +## choice MIN MAX L -- the presentation form is either an integer between the +## given inclusive bounds, or a token matching one of the items in the +## list L; the internal form is the integer, or the index of the token +## in the list. proc get/choice {min max l a} { global cmdr set x "custom" @@ -65,8 +102,10 @@ proc set/choice {min max l a v} { set cmdr($a) $v } +## seed -- a galaxy seed; any valid galaxy spec is permitted as the +## presentation form. proc get/seed {a} { global cmdr; return $cmdr($a) } -proc dump/seed {a} { global cmdr; return $cmdr($a) } +dump-like-get seed proc set/seed {a v} { global cmdr set s [parse-galaxy-spec $v] @@ -74,6 +113,9 @@ proc set/seed {a v} { destructure [list . cmdr($a)] $s } +## world -- a planet identifier; on input, any planet spec is permitted +## (relative to the commander's established galaxy), and on output a +## summary description is produced. proc get/world {a} { global cmdr gov eco set ww [elite-galaxylist $cmdr(gal-seed)] @@ -107,27 +149,36 @@ proc set/world {a v} { set cmdr(world-y) [expr {$p(y)/2}] } +## bool DFL -- internal form is either zero or DFL; external form is one of a +## number of standard boolean tokens. proc get/bool {dfl a} { global cmdr if {$cmdr($a)} { return "yes" } else { return "no" } } -proc dump/bool {dfl a} { - global cmdr - if {$cmdr($a)} { return "yes" } else { return "no" } -} +dump-like-get bool proc set/bool {dfl a v} { global cmdr switch -- [string tolower $v] { - "y" - "yes" - "true" - "on" { set v 1 } - "n" - "no" - "false" - "off" { set v 0 } + "y" - "yes" - "true" - "on" - "t" { set v 1 } + "n" - "no" - "false" - "off" - "nil" { set v 0 } } if {$v} { set cmdr($a) $dfl } else { set cmdr($a) 0 } } +## comment -- a pseudo-type for discarding commnts in input files. proc set/comment {a v} { } +###-------------------------------------------------------------------------- +### Attribute table. + +### The `attr' array maps commander attribute names to TYPE [PARAM ...] +### lists; the `attrs' list contains the names in a canonical order. set attrs {} + +## Comment magic. set attr(\#) { comment } + +## Basic attributes. foreach {a type} { mission { int 0 255 } score { choice 0 65535 { @@ -150,6 +201,8 @@ foreach {a type} { set attr($a) $type lappend attrs $a } + +## Lasers. foreach l {front rear left right} { set attr($l-laser) { choice 0 255 @@ -157,12 +210,16 @@ foreach l {front rear left right} { } lappend attrs $l-laser } + +## Standard boolean properties. foreach i { ecm fuel-scoop energy-bomb escape-pod docking-computer gal-hyperdrive } { set attr($i) { bool 255 } lappend attrs $i } + +## Station and hold produce. foreach l {station hold} { foreach {t p} $products { set attr($l-$t) { int 0 255 } @@ -170,27 +227,72 @@ foreach l {station hold} { } } +###-------------------------------------------------------------------------- +### Main program. + +jameson cmdr + +## Parse the command-line. +if {[llength $argv] < 1} { + puts stderr "usage: $argv0 \[-OPTION | ATTR | ATTR=VALUE\] ..." + exit 1 +} + +proc show-attrs {pat} { + ## Show the attributes whose names match the glob pattern PAT. Return the + ## number of matches. + + global attr attrs + set n 0 + foreach a $attrs { + if {[string match $pat $a]} { + puts [format "%-20s %s" $a [eval \ + get/[lindex $attr($a) 0] [lrange $attr($a) 1 end] [list $a]]] + incr n + } + } + return $n +} + +proc load-file {file} { + ## Load FILE as a commander. + + global argv0 cmdr + if {[catch { elite-unpackcmdr cmdr [read-file $file] } err]} { + puts stderr "$argv0: couldn't read `$file': $err" + exit 1 + } +} + set acted 0 for {set i 0} {$i < [llength $argv]} {incr i} { set a [lindex $argv $i] switch -regexp -- $a { - "^-reset$" { jameson cmdr } + + "^-reset$" { + ## Reset the commander back to Jameson. + + jameson cmdr + } + "^-show$" { - foreach a $attrs { - puts [format "%-20s %s" $a [eval \ - get/[lindex $attr($a) 0] [lrange $attr($a) 1 end] [list $a]]] - } + ## Produce a human-readable description of the commander. + + show-attrs "*" set acted 1 } + "^-load$" { + ## Load a commander file. + incr i set a [lindex $argv $i] - if {[catch { elite-unpackcmdr cmdr [read-file $a] } err]} { - puts stderr "$argv0: couldn't read `$a': $err" - exit 1 - } + load-file $a } + "^-save$" { + ## Write the commander to a file. + incr i set a [lindex $argv $i] if {[catch { write-file $a [elite-packcmdr cmdr] } err]} { @@ -199,7 +301,10 @@ for {set i 0} {$i < [llength $argv]} {incr i} { } set acted 1 } + "^-dump$" { + ## Dump a machine-readable textual description of the commander. + puts "# {Elite commander dump}" puts "" foreach a $attrs { @@ -208,7 +313,10 @@ for {set i 0} {$i < [llength $argv]} {incr i} { } set acted 1 } + "^-read$" { + ## Read back a description produced by `-dump'. + incr i set a [lindex $argv $i] if {[catch { @@ -223,11 +331,17 @@ for {set i 0} {$i < [llength $argv]} {incr i} { exit 1 } } + "^-" { + ## An unknown option. + puts stderr "$argv0: unknown option `$a'" exit 1 } + "^[a-z][a-z-]*=" { + ## An assignment ATTR=VALUE. + regexp {^([a-z][a-z-]*)=(.*)$} $a . a v if {![info exists attr($a)]} { puts stderr "$argv0: no such attribute `$a'" @@ -240,30 +354,23 @@ for {set i 0} {$i < [llength $argv]} {incr i} { exit 1 } } + default { - set n 0 - foreach aa $attrs { - if {[string match $a $aa]} { - incr n - puts [format "%-20s %s" $aa [eval \ - get/[lindex $attr($aa) 0] \ - [lrange $attr($aa) 1 end] [list $aa]]] - } - } - if {$n} { + ## If the argument matches any attribute names, then print the matching + ## attributes; otherwise load the named file. + + if {[show-attrs $a]} { set acted 1 } else { - if {[catch { elite-unpackcmdr cmdr [read-file $a] } err]} { - puts stderr "$argv0: couldn't read `$a': $err" - exit 1 - } + load-file $a } } } } + +## If we didn't do anything, write out a description of the file. if {!$acted} { - foreach a $attrs { - puts [format "%-20s %s" $a [eval \ - get/[lindex $attr($a) 0] [lrange $attr($a) 1 end] [list $a]]] - } + show-attrs "*" } + +###----- That's all, folks -------------------------------------------------- diff --git a/elite-describe b/elite-describe index 38c9022..8f5cfd4 100755 --- a/elite-describe +++ b/elite-describe @@ -1,12 +1,40 @@ #! /usr/bin/tclsh -# -# $Id: elite-describe,v 1.4 2003/03/10 23:38:18 mdw Exp $ +### +### Describe a particular world +### +### (c) 2003 Mark Wooding +### + +###----- Licensing notice --------------------------------------------------- +### +### This program is free software; you can redistribute it and/or modify +### it under the terms of the GNU General Public License as published by +### the Free Software Foundation; either version 2 of the License, or +### (at your option) any later version. +### +### This program is distributed in the hope that it will be useful, +### but WITHOUT ANY WARRANTY; without even the implied warranty of +### MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +### GNU General Public License for more details. +### +### You should have received a copy of the GNU General Public License +### along with this program; if not, write to the Free Software Foundation, +### Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. package require "elite" "1.0.1" +###-------------------------------------------------------------------------- +### Support functions. + proc describe n { + ## Describe the world with seed N. + global economy government + + ## Fetch the necessary information. elite-worldinfo p $n + + ## Format most of the data. puts "Name: $p(name)" puts "Seed: $p(seed)" puts "Position: $p(x), $p(y) LY" @@ -17,6 +45,8 @@ proc describe n { [expr {$p(population)/10.0}] $p(inhabitants)] puts "Gross productivity: $p(productivity) M Cr" puts "Radius: $p(radius) km" + + ## Format the world description, word-wrapping as necessary. puts "" set ll {} set l 0 @@ -29,6 +59,10 @@ proc describe n { puts $ll } +###-------------------------------------------------------------------------- +### Main program. + +## Parse the command line and describe the planets indicated. if {[llength $argv] < 1} { puts stderr "usage: $argv0 \[-g GALAXY\] PLANET ..." exit 1 @@ -58,3 +92,5 @@ for {set i 0} {$i < [llength $argv]} {incr i} { } } } + +###----- That's all, folks -------------------------------------------------- diff --git a/elite-editor b/elite-editor index 360f05b..f367c1c 100755 --- a/elite-editor +++ b/elite-editor @@ -110,7 +110,7 @@ proc help-menu {m} { #----- Map editing machinery ------------------------------------------------ -tab col red orange yellow green blue magenta violet white +_tab col red orange yellow green blue magenta violet white set seq 0 set nwin 0 @@ -152,7 +152,7 @@ proc colour-by {seq} { set tl .map-$seq global col switch -exact -- $map(colourby) { - off { + off { foreach-world $map(galaxy) p { $tl.map itemconfigure $p(seed) -fill white -outline white } @@ -300,7 +300,7 @@ proc hide-path {seq} { } } -proc path-to-text {seq} { +proc path-to-text {seq} { upvar \#0 map-$seq map set t {} foreach n $map(path) { @@ -340,7 +340,7 @@ proc list-path {seq} { $tl.text delete 1.0 end $tl.text insert end [path-to-text $seq] $tl.text configure -state disabled -} +} proc load-path {seq} { upvar \#0 map-$seq map @@ -375,7 +375,7 @@ proc load-path {seq} { $tl.menu.path entryconfigure $i -state normal } show-path $seq -} +} proc show-shortest-path {seq weight} { upvar \#0 map-$seq map @@ -580,7 +580,7 @@ proc set-selection {seq p} { foreach i {5 6 7 8 9} { $tl.menu.path entryconfigure $i -state normal } -} +} proc do-select {seq x y} { set-selection $seq [find-click $seq $x $y] @@ -682,7 +682,7 @@ proc map-set-title {seq} { } proc map-set-galaxy {seq ng g} { - upvar \#0 map-$seq map + upvar \#0 map-$seq map if {[string equal $g $map(galaxy)]} { return } set map(galaxy-num) $ng map-set-title $seq @@ -736,7 +736,7 @@ proc map-new {ng g} { $tl.info.ldest $tl.info.dest \ $tl.info.ldist $tl.info.dist \ -side left -pady 2 - + scrollbar $tl.hscr -orient horizontal \ -command [list $tl.map xview] scrollbar $tl.vscr -orient vertical \ @@ -785,7 +785,7 @@ proc map-new {ng g} { $tl.menu.path add command -label "Load path..." \ -command [list load-path $seq] $tl.menu.path add command -label "Save path..." -state disabled \ - -command [list save-path $seq] + -command [list save-path $seq] $tl.menu.path add command -label "List path..." -state disabled \ -command [list list-path $seq] $tl.menu.path add separator @@ -857,7 +857,7 @@ proc integerp {min max n} { proc galaxyp {s} { if {![regexp {^[0-9a-fA-F]{12}$} $s]} { return 0 } return 1 -} +} proc cmdr-do-validate {seq widget check value} { upvar \#0 cmdr-$seq cmdr @@ -1109,15 +1109,15 @@ proc cmdr-open {seq} { foreach {tag label kind} [list \ mission "Mission" { entry 2 255 } \ score "Rating" { dropbox 65535 \ - "Harmless" 0 \ - "Mostly harmless" 8 \ + "Harmless" 0 \ + "Mostly harmless" 8 \ "Poor" 16 \ - "Average" 32 \ + "Average" 32 \ "Above average" 64 \ - "Competent" 128 \ - "Dangerous" 512 \ - "Deadly" 2560 \ - "Elite" 6400 } \ + "Competent" 128 \ + "Dangerous" 512 \ + "Deadly" 2560 \ + "Elite" 6400 } \ legal-status "Legal status" { dropbox 255 \ "Clean" 0 \ "Offender" 1 \ @@ -1127,7 +1127,7 @@ proc cmdr-open {seq} { fuel "Fuel" { tenth 4 25.5 } \ missiles "Missiles" { entry 4 255 } \ energy-unit "Energy unit" { dropbox 255 \ - "None" 0 \ + "None" 0 \ "Standard" 1 \ "Naval" 2 } \ front-laser "Front laser" $laser \ @@ -1207,7 +1207,7 @@ proc cmdr-open {seq} { cmdr-validate-widget $seq $tl.gal-number [list integerp 1 8] checkbutton $tl.std-gal -text "Standard galaxy" \ -variable cmdr-${seq}(std-gal) -justify left \ - -command [list cmdr-std-gal $seq] + -command [list cmdr-std-gal $seq] entry-on-change $tl.gal-number [list cmdr-set-gal-num $seq] grid configure $tl.l-gal-number -row $r -column 0 -sticky e -padx 1 -pady 1 grid configure $tl.std-gal -row $r -column 1 -sticky w -padx 1 -pady 1 diff --git a/elite-find b/elite-find index f760f5e..72805c6 100755 --- a/elite-find +++ b/elite-find @@ -54,7 +54,7 @@ for {set i 0} {$i < [llength $argv]} {incr i} { } default { break - } + } } } diff --git a/elite-map b/elite-map index 61eea9e..d1908c7 100755 --- a/elite-map +++ b/elite-map @@ -251,6 +251,3 @@ if {$v > 1} { } } } - - - \ No newline at end of file diff --git a/elite-pairs b/elite-pairs index 700006b..4492900 100755 --- a/elite-pairs +++ b/elite-pairs @@ -65,7 +65,7 @@ for {set i 0} {$i < [llength $argv]} {incr i} { } default { break - } + } } } if {$i != [llength $argv] - 2} { diff --git a/elite-prices b/elite-prices index 1af510a..2e555f2 100755 --- a/elite-prices +++ b/elite-prices @@ -61,7 +61,7 @@ proc get-prices {ss arr} { foreach {t p} $products { set a($t) [loavghi $l($t)] } -} +} set g $galaxy1 set sortcol 0 diff --git a/elite-reach b/elite-reach index 7e72204..e44b5c3 100755 --- a/elite-reach +++ b/elite-reach @@ -1,45 +1,98 @@ #! /usr/bin/tclsh -# -# $Id: elite-reach,v 1.3 2003/03/07 00:41:46 mdw Exp $ +### +### Determine the connected components of the various galaxies +### +### (c) 2003 Mark Wooding +### + +###----- Licensing notice --------------------------------------------------- +### +### This program is free software; you can redistribute it and/or modify +### it under the terms of the GNU General Public License as published by +### the Free Software Foundation; either version 2 of the License, or +### (at your option) any later version. +### +### This program is distributed in the hope that it will be useful, +### but WITHOUT ANY WARRANTY; without even the implied warranty of +### MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +### GNU General Public License for more details. +### +### You should have received a copy of the GNU General Public License +### along with this program; if not, write to the Free Software Foundation, +### Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. package require "elite" "1.0.1" +###-------------------------------------------------------------------------- +### Support functions. + proc reach {dist seed} { + ## Given a hyperspace range DIST and a galaxy SEED, determine and print the + ## connected components of the reachability graph. + + ## Determine the graph. Throughout, we use world seeds as indices: a(W) + ## maintains a list of worlds adjacent to W. p(W) is set (to an + ## uninteresting value) if it's awaiting tracing. The algorithm is simple: + ## repeatedly pick a world awaiting tracing, do a depth-first search of + ## graph starting from the chosen world adding each one encountered to the + ## current component and removing it from the waiting list. set ww [elite-galaxylist $seed] elite-adjacency a $ww $dist foreach {s x w} $ww { set p($s) 1 } + + ## Initially there are no components. set pp {} + + ## Iterate over the untraced worlds. while 1 { + + ## Find an untraced world. If there are none left then we're done. set ps [array startsearch p] if {![array anymore p $ps]} { array donesearch p $ps; break } set cc [array nextelement p $ps] array donesearch p $ps + + ## Now we do the depth-first search. For each world in $trace, + ## accumulate the untraced worlds reachable from it, and add them to the + ## component. Do this until we stop tracing new worlds. + set trace $cc unset p($cc) - set go 1 - while {$go} { - set go 0 - foreach c $cc { + while {[llength $trace]} { + set tt $trace; set trace {} + foreach c $tt { foreach w $a($c) { if {[info exists p($w)]} { unset p($w) - lappend cc $w - set go 1 + lappend trace $w } } } + set cc [concat $cc $trace] } + + ## We've finished the component. Add it to the list. lappend pp $cc } + + ## Output the components. foreach cc $pp { + + ## Firstly, accumulate the summary data for all the worlds in the + ## component. Also, do dead-end analysis: if there's no world in the + ## component with tech level 10 or higher then the component as a whole + ## is a `dead end', and can't be escaped by buying a galactic hyperdrive + ## (and you can't have one of those already, because you must have used + ## it to reach the component in the first pace). set de 1 set l {} foreach c $cc { elite-worldinfo i $c - if {$i(techlevel) >= 10} { - set de 0 - } + if {$i(techlevel) >= 10} { set de 0 } lappend l [world-summary $i(seed)] } + + ## Secondly, output the component information. Separate components using + ## blank lines. foreach n $l { if {$de} { append n " *" } puts $n @@ -48,6 +101,11 @@ proc reach {dist seed} { } } +###-------------------------------------------------------------------------- +### Main program. + +## Parse the command line. The default will be to scan all of the standard +## galaxies. if {[llength $argv] == 0} { set argv {1 2 3 4 5 6 7 8} } @@ -75,7 +133,11 @@ for {set i 0} {$i < [llength $argv]} {incr i} { } } } + +## Analyse the requested galaxies. foreach {d ng g} $gg { puts "*** GALAXY $ng ***" reach $d $g } + +###----- That's all, folks -------------------------------------------------- diff --git a/elite-tantalus b/elite-tantalus index bdb6285..ac5837e 100755 --- a/elite-tantalus +++ b/elite-tantalus @@ -31,7 +31,7 @@ for {set i 0} {$i < [llength $argv]} {incr i} { } default { break - } + } } } diff --git a/elite.c b/elite.c index 11037fb..e6e90f2 100644 --- a/elite.c +++ b/elite.c @@ -1,24 +1,22 @@ /* -*-c-*- * - * $Id$ - * * Elite planet data * * (c) 2003 Mark Wooding */ -/*----- Licensing notice --------------------------------------------------* +/*----- Licensing notice --------------------------------------------------* * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. @@ -103,7 +101,7 @@ static void world_us(Tcl_Obj *o) o->bytes = p; o->length = 12; for (i = 0; i < 6; i++, p += 2) - sprintf(p, "%02x", w->x[i]); + sprintf(p, "%02x", w->x[i]); } static void world_dir(Tcl_Obj *o, Tcl_Obj *oo) @@ -315,7 +313,7 @@ static void goatsoup(Tcl_Obj *d, const char *pn, world *w, const char *p) p++; j = mangle(w); goatsoup(d, pn, w, desc[i][(j >= 0x33) + (j >= 0x66) + - (j >= 0x99) + (j >= 0xcc)]); + (j >= 0x99) + (j >= 0xcc)]); break; case '%': p++; @@ -364,7 +362,7 @@ static int cmd_worldinfo(ClientData cd, Tcl_Interp *ti, world ww; /* --- Check arguments --- */ - + if (objc != 3) return (err(ti, "usage: elite-worldinfo ARR SEED")); if ((w = world_get(ti, objv[2])) == 0) @@ -379,15 +377,15 @@ static int cmd_worldinfo(ClientData cd, Tcl_Interp *ti, TCL_LEAVE_ERR_MSG) || !Tcl_SetVar2Ex(ti, arr, "y", Tcl_NewIntObj(wi.y * 2), TCL_LEAVE_ERR_MSG) || - !Tcl_SetVar2Ex(ti, arr, "government", Tcl_NewIntObj(wi.gov), + !Tcl_SetVar2Ex(ti, arr, "government", Tcl_NewIntObj(wi.gov), TCL_LEAVE_ERR_MSG) || !Tcl_SetVar2Ex(ti, arr, "economy", Tcl_NewIntObj(wi.eco), TCL_LEAVE_ERR_MSG) || - !Tcl_SetVar2Ex(ti, arr, "techlevel", Tcl_NewIntObj(wi.tech), + !Tcl_SetVar2Ex(ti, arr, "techlevel", Tcl_NewIntObj(wi.tech), TCL_LEAVE_ERR_MSG) || - !Tcl_SetVar2Ex(ti, arr, "population", Tcl_NewIntObj(wi.pop), + !Tcl_SetVar2Ex(ti, arr, "population", Tcl_NewIntObj(wi.pop), TCL_LEAVE_ERR_MSG) || - !Tcl_SetVar2Ex(ti, arr, "productivity", Tcl_NewIntObj(wi.prod), + !Tcl_SetVar2Ex(ti, arr, "productivity", Tcl_NewIntObj(wi.prod), TCL_LEAVE_ERR_MSG) || !Tcl_SetVar2Ex(ti, arr, "radius", Tcl_NewIntObj(wi.rad), TCL_LEAVE_ERR_MSG) || @@ -700,7 +698,7 @@ static int put_items(Tcl_Interp *ti, /*const*/ char *arr, return (-1); *p++ = ii; } - return (0); + return (0); } static struct cmddata cmdtab[] = { @@ -916,7 +914,7 @@ static int cmd_adjacency(ClientData cd, Tcl_Interp *ti, goto done; } for (i = 0; i < oc; i += 3) { - s = Tcl_GetString(ov[i]); + s = Tcl_GetString(ov[i]); Tcl_CreateHashEntry(&done, s, &dummy); if (Tcl_GetLongFromObj(ti, ov[i + 1], &x) != TCL_OK || Tcl_GetLongFromObj(ti, ov[i + 2], &y) != TCL_OK) @@ -977,7 +975,7 @@ int Elite_SafeInit(Tcl_Interp *ti) } cmds[] = { { "elite-nextworld", cmd_nextworld }, { "elite-nextgalaxy", cmd_nextgalaxy }, - { "elite-worldinfo", cmd_worldinfo }, + { "elite-worldinfo", cmd_worldinfo }, { "elite-market", cmd_market }, { "elite-unpackcmdr", cmd_unpackcmdr }, { "elite-packcmdr", cmd_packcmdr }, diff --git a/elite.tcl b/elite.tcl index d72250f..8da3279 100644 --- a/elite.tcl +++ b/elite.tcl @@ -1,16 +1,37 @@ -#! /usr/bin/tclsh -# -# $Id$ +### -*-tcl-*- +### +### Common Elite hacking functions +### +### (c) 2003 Mark Wooding +### + +###----- Licensing notice --------------------------------------------------- +### +### This program is free software; you can redistribute it and/or modify +### it under the terms of the GNU General Public License as published by +### the Free Software Foundation; either version 2 of the License, or +### (at your option) any later version. +### +### This program is distributed in the hope that it will be useful, +### but WITHOUT ANY WARRANTY; without even the implied warranty of +### MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +### GNU General Public License for more details. +### +### You should have received a copy of the GNU General Public License +### along with this program; if not, write to the Free Software Foundation, +### Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. package require "elite-bits" "1.0.1" -set galaxy1 "4a5a480253b7" ;# Seed for standard galaxy 1 +###-------------------------------------------------------------------------- +### Internal utilities. -# --- tab ARR NAME NAME ... --- -# -# Construct an array mapping integers 0, 1, ... to the given NAMEs, in order. +proc _tab {arr args} { + ## _tab ARR NAME NAME ... --- + ## + ## Construct an array mapping integers 0, 1, ... to the given NAMEs, in + ## order. -proc tab {arr args} { upvar 1 $arr a set i 0 foreach v $args { @@ -19,28 +40,37 @@ proc tab {arr args} { } } -# --- Various standard tables --- +###-------------------------------------------------------------------------- +### Magic constants and tables. + +set galaxy1 "4a5a480253b7" ;# Seed for standard galaxy 1 -tab government \ +## Government types. +_tab government \ "anarchy" "feudal" "multi-government" "dictatorship" \ "communist" "confederacy" "democracy" "corporate state" -tab economy \ +## Economy types. +_tab economy \ "rich industrial" "average industrial" "poor industrial" \ "mainly industrial" "mainly agricultural" "rich agricultural" \ "average agricultural" "poor agricultural" -tab gov \ +## Abbreviated government types. +_tab gov \ anarchy feudal multi-gov dictator \ communist confed democracy corp-state -tab eco \ +## Abbreviated economy types. +_tab eco \ rich-ind avg-ind poor-ind mainly-ind \ mainly-agri rich-agri avg-agri poor-agri -tab gv Ay Fl MG Dp Ct Cy Dy CS -tab ec RI AI PI MI MA RA AA PA +## Two-letter government and economy types. +_tab gv Ay Fl MG Dp Ct Cy Dy CS +_tab ec RI AI PI MI MA RA AA PA +## Products for trading. set products { food "Food" textiles "Textiles" @@ -66,38 +96,33 @@ foreach p {gold platinum} { set unit($p) kg } set unit(gem-stones) g unset p -# --- galaxy N [GAL] --- -# -# Compute the seed of the Nth galaxy, if GAL is the seed of galaxy 1. By -# default, GAL is the standard galaxy 1 seed. +###-------------------------------------------------------------------------- +### External functions. proc galaxy [list n [list g $galaxy1]] { + ## Compute the seed of the Nth galaxy, if G is the seed of galaxy 1. By + ## default, G is the standard galaxy 1 seed. + for {set i 1} {$i < $n} {incr i} { set g [elite-nextgalaxy $g] } return $g } -# --- foreach-world GAL ARR SCRIPT --- -# -# For each world in galaxy GAL (a seed), set ARR to the world information -# and evaluate SCRIPT. The usual loop control commands can be used in -# SCRIPT. - proc foreach-world {g p act} { + ## For each world in galaxy G (a seed), set P to the world information and + ## evaluate ACT. The usual loop control commands can be used in ACT. upvar 1 $p pp for {set i 0} {$i < 256} {incr i; set g [elite-nextworld $g]} { elite-worldinfo pp $g - uplevel 1 $act + uplevel 1 $act } } -# --- find-world GAL PAT --- -# -# Return a list of seeds for the worlds in galaxy GAL (a seed) whose names -# match the glob pattern PAT. - proc find-world {g pat} { + ## Return a list of seeds for the worlds in galaxy G (a seed) whose names + ## match the glob pattern PAT. + set l {} foreach-world $g p { if {[string match -nocase $pat $p(name)]} { @@ -107,16 +132,14 @@ proc find-world {g pat} { return $l } -# --- destructure PAT LIST --- -# -# Destrcture LIST according to PAT. If PAT is a single name, set the -# variable PAT to LIST; otherwise, if PAT is a list, each of its elements -# must correspond to an element of LIST, so recursively destructure the -# corresponding elements of each. It is not an error if the PAT list is -# shorter than LIST. The special variable name `.' indicates that no -# assignment is to be made. - proc destructure {pp xx} { + ## Destrcture an object XX according to the pattern PP. If PP is a single + ## name, set the variable PP to XX; otherwise, if PP is a list, each of its + ## elements must correspond to an element of the list XX, so recursively + ## destructure the corresponding elements of each. It is not an error if + ## the PP list is shorter than XX. The special variable name `.' indicates + ## that no assignment is to be made. + if {![string compare $pp "."]} { return } elseif {[llength $pp] == 0} { @@ -131,13 +154,11 @@ proc destructure {pp xx} { } } -# --- write-file NAME CONTENTS [TRANS] --- -# -# Write file NAME, storing CONTENTS translated according to TRANS (default -# `binary'. The write is safe against errors -- we don't destroy the old -# data until the file is written. - proc write-file {name contents {trans binary}} { + ## Write file NAME, storing CONTENTS translated according to TRANS (default + ## `binary'. The write is safe against errors -- we don't destroy the old + ## data until the file is written. + if {[file exists $name]} { if {[set rc [catch { file copy -force $name "$name.old" } err]]} { return -code $rc $err @@ -156,12 +177,10 @@ proc write-file {name contents {trans binary}} { return "" } -# --- read-file NAME [TRANS] --- -# -# Read the contents of the file NAME, translating it according to TRANS -# (default `binary'). - proc read-file {name {trans binary}} { + ## Read the contents of the file NAME, translating it according to TRANS + ## (default `binary'). + set f [open $name] fconfigure $f -translation $trans set c [read $f] @@ -169,12 +188,10 @@ proc read-file {name {trans binary}} { return $c } -# --- nearest-planet WW X Y --- -# -# Returns the seed of the `nearest' planet given in the worldinfo list WW to -# the point X Y (in decilightyears). - proc nearest-planet {ww x y} { + ## Returns the seed of the `nearest' planet given in the worldinfo list WW + ## to the point X Y (in decilightyears). + set min 10000 foreach {ss xx yy} $ww { set dx [expr {abs($x - $xx)/4}] @@ -192,26 +209,22 @@ proc nearest-planet {ww x y} { return $p } -# --- worldname W --- -# -# Returns the name of the world with seed W. - proc worldname {w} { + ## Returns the name of the world with seed W. + elite-worldinfo p $w return $p(name) } -# --- shortest-path ADJ FROM TO WEIGHT --- -# -# Computes the shortest path and shortest distance between the worlds wose -# seeds are FROM and TO respectively. ADJ must be an adjacency table for the -# galaxy containing FROM and TO. WEIGHT is a command such that WEIGHT A B -# returns the `distance' for the simple path between A and B. The return -# value is a list P D, where D is the weight of the path found, and P is a -# simple list of seeds for the worlds on the path. P starts with FROM and -# ends with TO. - proc shortest-path {adjvar from to weight} { + ## Computes the shortest path and shortest distance between the worlds wose + ## seeds are FROM and TO respectively. ADJVAR must be the name of a + ## variable holding an adjacency table for the galaxy containing FROM and + ## TO. WEIGHT is a command such that WEIGHT A B returns the `distance' for + ## the simple path between A and B. The return value is a list P D, where + ## D is the weight of the path found, and P is a simple list of seeds for + ## the worlds on the path. P starts with FROM and ends with TO. + upvar 1 $adjvar adj if {[string equal $from $to]} { return [list $to 0] } set l($from) 0 @@ -247,79 +260,68 @@ proc shortest-path {adjvar from to weight} { } } -# --- weight-hops A B --- -# -# shortest-path weight function giving each hop the same weight. - proc weight-hops {from to} { + ## shortest-path weight function giving each hop the same weight. return 1 } -# --- weight-fuel A B --- -# -# shortest-path weight function measuring the distance between FROM and TO. - proc weight-fuel {from to} { + ## shortest-path weight function measuring the distance between FROM and + ## TO. + elite-worldinfo f $from elite-worldinfo t $to return [elite-distance $f(x) $f(y) $t(x) $t(y)] } -# --- weight-safety A B --- -# -# shortest-path weight function attempting to maximize safety of the journey -# by giving high weight (square-law) to worlds with unstable governments. - proc weight-safety {from to} { + ## shortest-path weight function attempting to maximize safety of the + ## journey by giving high weight (square-law) to worlds with unstable + ## governments. + elite-worldinfo t $to set w [expr {8 - $t(government)}] return [expr {$w * $w}] } -# --- weight-encounters A B --- -# -# shortest-path weight function attempting to maximize encounters on the -# journey by giving high weight (square law) to worlds with stable -# governments. - proc weight-encounters {from to} { + ## shortest-path weight function attempting to maximize encounters on the + ## journey by giving high weight (square law) to worlds with stable + ## governments. + elite-worldinfo f $from elite-worldinfo t $to set w [expr {1 + $t(government)}] return [expr {$w * $w}] } -# --- weight-trading A B --- -# -# shortest-path weight function attempting to maximize trading opportunities -# along the journey by giving high weight (square law) to pairs of worlds -# with small differences between their economic statuses. - proc weight-trading {from to} { + ## shortest-path weight function attempting to maximize trading + ## opportunities along the journey by giving high weight (square law) to + ## pairs of worlds with small differences between their economic statuses. + elite-worldinfo f $from elite-worldinfo t $to set w [expr {8 - abs($f(economy) - $t(economy))}] return [expr {$w * $w}] } -# --- parse-galaxy-spec G --- -# -# Parses a galaxy spec and returns a list containing a description of the -# galaxy and the corresponding galaxy seed. A galaxy spec is one of: -# -# * a number between 1 and 8, corresponding to one of the standard -# galaxies; -# -# * a 12-digit hex string, which is a galaxy seed (and is returned -# unchanged); or -# -# * a string of the form S:N where S is a 12-hex-digit seed and N is a -# galaxy number, corresponding to the Nth galaxy starting with S as -# galaxy 1. -# -# If the string is unrecognized, an empty list is returned. - proc parse-galaxy-spec {g} { + ## Parses a galaxy spec and returns a list containing a description of the + ## galaxy and the corresponding galaxy seed. A galaxy spec is one of: + ## + ## * a number between 1 and 8, corresponding to one of the standard + ## galaxies; + ## + ## * a 12-digit hex string, which is a galaxy seed (and is returned + ## unchanged); or + ## + ## * a string of the form S:N where S is a 12-hex-digit seed and N is a + ## galaxy number, corresponding to the Nth galaxy starting with S as + ## galaxy 1. + ## + ## If the string is unrecognized, an empty list is returned. + switch -regexp -- $g { {^[1-8]$} { return [list $g [galaxy $g]] } {^[0-9a-fA-F]{12}$} { return [list $g $g] } @@ -332,27 +334,26 @@ proc parse-galaxy-spec {g} { return {} } -# --- parse-planet-spec G P --- -# -# Parses a planet spec and returns the planet seed. The planet spec P is -# interpreted relative to galaxy G. A planet spec is one of: -# -# * a simple integer, corresponding to a planet number; -# -# * a 12-hex-digit seed, which is returned unchanged; -# -# * a pair of integers separated by commas, corresponding to the nearest -# planet to those coordinates; -# -# * a glob pattern, corresponding to the lowest-numbered planet in the -# galaxy whose name matches the pattern case-insensitively; or -# -# * a string of the form G.P where G is a galaxy spec and P is a planet -# spec, corresponding to the planet specified by P relative to galaxy G. -# -# If the string is unrecognized, an empty string is returned. - proc parse-planet-spec {g p} { + ## Parses a planet spec and returns the planet seed. The planet spec P is + ## interpreted relative to galaxy G. A planet spec is one of: + ## + ## * a simple integer, corresponding to a planet number; + ## + ## * a 12-hex-digit seed, which is returned unchanged; + ## + ## * a pair of integers separated by commas, corresponding to the nearest + ## planet to those coordinates; + ## + ## * a glob pattern, corresponding to the lowest-numbered planet in the + ## galaxy whose name matches the pattern case-insensitively; or + ## + ## * a string of the form G.P where G is a galaxy spec and P is a planet + ## spec, corresponding to the planet specified by P relative to galaxy + ## G. + ## + ## If the string is unrecognized, an empty string is returned. + if {[regexp {^[0-9a-fA-F]{12}$} $p]} { return $p } if {[regexp {^(.+)\.(.+)$} $p . g p]} { set g [parse-galaxy-spec $g] @@ -376,22 +377,20 @@ proc parse-planet-spec {g p} { return {} } -# --- in-galaxy-p G PP --- -# -# Returns nonzero if the planets (seeds) listed in PP are in galaxy G. -# Doesn't mind if the planet seeds are invalid. - proc in-galaxy-p {g pp} { + ## Returns nonzero if the planets (seeds) listed in PP are in galaxy G. + ## Doesn't mind if the planet seeds are invalid. + foreach-world $g i { set x($i(seed)) 1 } foreach p $pp { if {![info exists x($p)]} { return 0 } } return 1 } -# --- world-summary PLANET --- -# -# Return a one-line summary string for PLANET. - proc world-summary {s {ind 0} {spc 0}} { + ## Return a one-line summary string for planet S. IND and SPC are numbers + ## of additional spaces to insert at the start of the line and after the + ## planet name, respectively. + global eco gov elite-worldinfo p $s set is [string repeat " " $ind] @@ -401,38 +400,34 @@ proc world-summary {s {ind 0} {spc 0}} { $eco($p(economy)) $gov($p(government)) $p(techlevel) $p(seed)] } -# --- world-brief PLANET --- -# -# Return a very brief summary string for PLANET. - proc world-brief {s} { + ## Return a very brief summary string for planet S. + global gv ec elite-worldinfo p $s return [format "%-8s (%s, %s, %2d)" \ $p(name) $ec($p(economy)) $gv($p(government)) $p(techlevel)] } -# --- jameson ARR --- -# -# Fill ARR with the information about commander JAMESON. - proc jameson {arr} { + ## Fill ARR with the information about commander JAMESON. + global galaxy1 products upvar 1 $arr cmdr array set cmdr { - mission 0 - credits 1000 - fuel 70 - gal-number 1 - front-laser 0x0f - rear-laser 0 - left-laser 0 - right-laser 0 - cargo 20 - missiles 3 + mission 0 + credits 1000 + fuel 70 + gal-number 1 + front-laser 0x0f + rear-laser 0 + left-laser 0 + right-laser 0 + cargo 20 + missiles 3 legal-status 0 - score 0 - market-fluc 0 + score 0 + market-fluc 0 } set cmdr(gal-seed) $galaxy1 foreach i { @@ -450,6 +445,6 @@ proc jameson {arr} { set cmdr(station-alien-items) 0 } -#----- That's all, folks ---------------------------------------------------- +###----- That's all, folks -------------------------------------------------- package provide "elite" "1.0.1" diff --git a/graph.c b/graph.c index 23c1a32..9dc3942 100644 --- a/graph.c +++ b/graph.c @@ -1,24 +1,22 @@ /* -*-c-*- * - * $Id$ - * * Graph theory stuff * * (c) 2003 Mark Wooding */ -/*----- Licensing notice --------------------------------------------------* +/*----- Licensing notice --------------------------------------------------* * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. @@ -536,7 +534,7 @@ static int cmd_tsp(ClientData cd, Tcl_Interp *ti, t = r[i]; r[i] = r[j]; r[j] = t; if (c_curr < c_best) { c_best = c_curr; -/* printf("*** new best = %lu\n", c_best); */ +/* printf("*** new best = %lu\n", c_best); */ memcpy(r_best, r, nn * sizeof(*r)); } } diff --git a/vec.c b/vec.c index 0383c88..912fb38 100644 --- a/vec.c +++ b/vec.c @@ -1,24 +1,22 @@ /* -*-c-*- * - * $Id$ - * * Vectors and arrays in Tcl * * (c) 2003 Mark Wooding */ -/*----- Licensing notice --------------------------------------------------* +/*----- Licensing notice --------------------------------------------------* * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. diff --git a/vec.h b/vec.h index 34e1560..fff3fbe 100644 --- a/vec.h +++ b/vec.h @@ -1,24 +1,22 @@ /* -*-c-*- * - * $Id$ - * * Vectors and arrays in Tcl * * (c) 2003 Mark Wooding */ -/*----- Licensing notice --------------------------------------------------* +/*----- Licensing notice --------------------------------------------------* * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -- 2.11.0