#!/usr/bin/perl -w

while (<>) {
    if (/FinalFrontierHallOfFameEntry/) {
	$foo=$_;
	do {
	    $foo .= <>;
	} until ($foo=~/\n\s*\}\s*$/); 
	$foo=~/time\s*\=\s*([\d\.]+)/;
	$time=$1;
	$untimed=$foo; $untimed=~s/$time//;
	$foo=~/code\s*\=\s*(\S*)/;
	$code=$1;
	# We want to get _a_ time from the savefiles, but we don't
	# much care which one it is, and we do want to dedupe.
	# We think entries of the form X+ should not be deduped
	# unless they are entirely identical - name, code, time, data
	# We try and give the oldest, though, assuming the savefiles were
	# also sorted by time on the command line
	if (!defined($entries{$untimed})) {
	    $entries{$untimed}=$foo; $time{$untimed}=$time;
	} elsif ($code=~/\+$/ and ($entries{$untimed} ne $foo)) {
	    $entries{$foo}=$foo; $time{$foo}=$time;
	}
    }
}
foreach (sort {$time{$a}<=>$time{$b}} keys %entries) {
    print $entries{$_};
}
