diff options
author | H. Peter Anvin <hpa@zytor.com> | 2003-03-25 05:28:10 +0000 |
---|---|---|
committer | H. Peter Anvin <hpa@zytor.com> | 2003-03-25 05:28:10 +0000 |
commit | 37ae1353fb4ef6013b688b28cd82f06182ad3063 (patch) | |
tree | 7d7c3029d3b5f14d4da2997718b523e47362aea9 /high2dat.pl | |
parent | 1128ad360b5cccb1b82de092505e5ca1c4dbed8d (diff) | |
download | grv-37ae1353fb4ef6013b688b28cd82f06182ad3063.tar.gz grv-37ae1353fb4ef6013b688b28cd82f06182ad3063.tar.xz grv-37ae1353fb4ef6013b688b28cd82f06182ad3063.zip |
Add support for high score tables, including the ability to generate
a (hopefully) unique ID for each game that we can use to match identical
records.
Diffstat (limited to 'high2dat.pl')
-rwxr-xr-x | high2dat.pl | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/high2dat.pl b/high2dat.pl new file mode 100755 index 0000000..32b3357 --- /dev/null +++ b/high2dat.pl @@ -0,0 +1,63 @@ +#!/usr/bin/perl +# +# Convert the binary grv_high file to the text-based grvscore.dat +# + +eval { use bytes; }; + +$gameid = 0; + +print "VC 1.0\n"; + +sub quote($) { + my($i) = @_; + my($o) = ''; + my($x); + + for ( $x = 0 ; $x < length($i) ; $x++ ) { + $o .= sprintf("%02x", ord(substr($i,$x,1))); + } + $o .= '00'; + return $o; +} + +for ( $i = 0 ; $i < 100 ; $i++ ) { + read(STDIN, $hd, 23); + ($score, $player, $level, $time) = unpack("dA9vf", $hd); + printf STDERR "<..> %14f %-9s %2d %f\n", $score, $player, $level, $time; + $level++; + $player = quote($player); + $score = int($score+0.5); + $time = int($time*1000+0.5); + $time = ($time > 1800000) ? 0x7fffffff : $time; + $gameid++; + print "TS $gameid $score $level $player\n"; +} +for ( $l = 0 ; $l < 75 ; $l++ ) { + for ( $i = 0 ; $i < 3 ; $i++ ) { + read(STDIN, $hd, 23); + ($score, $player, $level, $time) = unpack("dA9vf", $hd); + printf STDERR "<%2d> %14f %-9s %2d %f\n", $l,$score, $player, $level, $time; + if ( $level == $l ) { + $level++; + $score = int($score+0.5); + $time = int($time*1000+0.5); + $time = ($time > 1800000) ? 0x7fffffff : $time; + $gameid++; + print "LT $gameid $level $time\n" if ( $time != 0x7fffffff ); + } + } + for ( $i = 0 ; $i < 3 ; $i++ ) { + read(STDIN, $hd, 23); + ($score, $player, $level, $time) = unpack("dA9vf", $hd); + printf STDERR "<%2d> %14f %-9s %2d %f\n", $l, $score, $player, $level, $time; + if ( 1 || $level == $l ) { + $level++; + $score = int($score+0.5); + $time = int($time*1000+0.5); + $time = ($time > 1800000) ? 0x7fffffff : $time; + $gameid++; + print "LS $gameid $level $score\n" if ( $score ); + } + } +} |