Shows players by name and race.
+my @race = (qw(Z T P), (undef) x 3, '-');
+
sub showtime {
my $time = shift() * .042;
my $minutes = int($time / 60);
sub showtime {
my $time = shift() * .042;
my $minutes = int($time / 60);
) for $head->{mag2};
delete $head->{$_} for qw(mag1 mag2 unknown1 unknown2);
) for $head->{mag2};
delete $head->{$_} for qw(mag1 mag2 unknown1 unknown2);
-my @playdata = unpack "a36"x12 . "V8C8", $headdata[0]
+my @playdata = unpack "Va32"x12 . "V8C8", $headdata[0]
or die "Couldn't parse player data in replay header\n";
or die "Couldn't parse player data in replay header\n";
-my @player;
-push @player, unpackhash("x11Z25", shift @playdata, qw/name/) for 0 .. 11;
+my (@player, @slot);
+for (0 .. 11) {
+ my $number = shift @playdata;
+ defined $player[$number] and warn "Player #$number redefined";
+ my ($data) = unpackhash("VcccZ25", shift @playdata, qw(
+ slot type race unknown name
+ ));
+ defined $race[$_] ? ($data->{race} = $race[$_]) :
+ warn "Unknown race #$_ for player $number"
+ for $data->{race};
+ $slot[$data->{slot}] = $number if $data->{slot} < 16;
+ $player[$number] = $data;
+}
$player[$_]->{color} = shift @playdata for 0 .. 7;
$player[$_]->{index} = shift @playdata for 0 .. 7;
$player[$_]->{color} = shift @playdata for 0 .. 7;
$player[$_]->{index} = shift @playdata for 0 .. 7;
+sub showplayer {
+ my $id = shift;
+ my $playdata = $player[$slot[$id]];
+ return defined $playdata ?
+ sprintf '%s (%s)', $playdata->{name}, $playdata->{race} : "#$id";
+}
+
printf "%s: %s\n", $_, $head->{$_} for qw(name creator);
use Date::Format;
printf "created: %s\n", time2str('%Y-%m-%d %X', $_) for $head->{time};
printf "%s: %s\n", $_, $head->{$_} for qw(name creator);
use Date::Format;
printf "created: %s\n", time2str('%Y-%m-%d %X', $_) for $head->{time};
for my $player (sort keys %stats) {
my $row = $stats{$player};
$row->{last} ||= $map->[-1][0];
for my $player (sort keys %stats) {
my $row = $stats{$player};
$row->{last} ||= $map->[-1][0];
-# printf("%d:%6d actions (%3d micro,%4d macro);%4d APM\n",
- printf("%d:%6d actions in%7d frames (%s) = %d APM\n",
- $player, $row->{actions}, $row->{last},
+# printf("%-16s%6d actions (%3d micro,%4d macro);%4d APM\n",
+ my $name = showplayer($player);
+ printf("%-16s%6d actions in%7d frames (%s) = %d APM\n",
+ $name, $row->{actions}, $row->{last},
showtime($row->{last}),
# $row->{micro} / $row->{last} * 60 / .042 * 1.05,
# $row->{macro} / $row->{last} * 60 / .042 * 1.05,
showtime($row->{last}),
# $row->{micro} / $row->{last} * 60 / .042 * 1.05,
# $row->{macro} / $row->{last} * 60 / .042 * 1.05,