my ($self) = @_;
$self->{stats} = {};
$self->{mapstats} = {};
+ $self->{typestats} = {};
$self->{addrstats} = {};
$self->{allstats} = {};
open my $fh, "<", $self->{fn}
if $targweapon ne int $targweapon;
$attackerweapon = int $self->weaponid_from_name($attackerweapon)
if $attackerweapon ne int $attackerweapon;
- $self->{stats}->{$addr}{$map}{$attackerweapon}{$targweapon} += $value;
+ $map =~ /(.*?)_(.*)/
+ or do { warn "invalid map name: $map"; next; };
+ (my $type, $map) = ($1, $2);
+ $self->{stats}->{$addr}{$type}{$map}{$attackerweapon}{$targweapon} += $value;
+ $self->{typestats}->{$type}{$attackerweapon}{$targweapon} += $value;
+ $self->{typemapstats}->{$type}{$map}{$attackerweapon}{$targweapon} += $value;
$self->{mapstats}->{$map}{$attackerweapon}{$targweapon} += $value;
$self->{addrstats}->{$addr}{$attackerweapon}{$targweapon} += $value;
$self->{allstats}->{$attackerweapon}{$targweapon} += $value;
sub event($$$$$$)
{
- my ($self, $addr, $map, $attackerweapon, $targweapon, $type) = @_;
+ my ($self, $addr, $map, $attackerweapon, $targweapon, $value) = @_;
return if $map eq '';
- if($type > 0)
+ if($value > 0)
{
- $self->{stats}->{$addr}{$map}{$attackerweapon}{$targweapon} += $type;
- $self->{mapstats}->{$map}{$attackerweapon}{$targweapon} += $type;
- $self->{addrstats}->{$addr}{$attackerweapon}{$targweapon} += $type;
- $self->{allstats}->{$attackerweapon}{$targweapon} += $type;
+ $map =~ /(.*?)_(.*)/
+ or do { warn "invalid map name: $map"; return; };
+ (my $type, $map) = ($1, $2);
+ $self->{stats}->{$addr}{$type}{$map}{$attackerweapon}{$targweapon} += $value;
+ $self->{typemapstats}->{$type}{$map}{$attackerweapon}{$targweapon} += $value;
+ $self->{typestats}->{$type}{$attackerweapon}{$targweapon} += $value;
+ $self->{mapstats}->{$map}{$attackerweapon}{$targweapon} += $value;
+ $self->{addrstats}->{$addr}{$attackerweapon}{$targweapon} += $value;
+ $self->{allstats}->{$attackerweapon}{$targweapon} += $value;
}
}
# send per-host stats
while(my ($k, $v) = each %{$self->{addrstats}})
{
- $callback->($k, undef, $v);
+ $callback->($k, undef, undef, $v);
+ }
+ # send per-type stats
+ while(my ($k, $v) = each %{$self->{typestats}})
+ {
+ $callback->(undef, $k, undef, $v);
+ }
+ # send per-type-map stats
+ while(my ($k1, $v1) = each %{$self->{typemapstats}})
+ {
+ while(my ($k2, $v2) = each %$v1)
+ {
+ $callback->(undef, $k1, $k2, $v2);
+ }
}
# send per-map stats
while(my ($k, $v) = each %{$self->{mapstats}})
{
- $callback->(undef, $k, $v);
+ $callback->(undef, undef, $k, $v);
}
# send single stats
while(my ($k1, $v1) = each %{$self->{stats}})
{
while(my ($k2, $v2) = each %$v1)
{
- $callback->($k1, $k2, $v2);
+ while(my ($k3, $v3) = each %$v2)
+ {
+ $callback->($k1, $k2, $k3, $v3);
+ }
}
}
}
}
elsif($event eq 'startmatrix')
{
- my ($addr, $map, @columns) = @data;
+ my ($addr, $type, $map, @columns) = @data;
$addr ||= 'any';
$map ||= 'any';
- print "For server @{[$addr || 'any']} map @{[$map || 'any']}:\n";
+ $type ||= 'any';
+ print "For server $addr type $type map $map:\n";
}
elsif($event eq 'startrow')
{
}
elsif($event eq 'startmatrix')
{
- my ($addr, $map, @columns) = @data;
+ my ($addr, $type, $map, @columns) = @data;
$addr ||= 'any';
+ $type ||= 'any';
$map ||= 'any';
- print "<h2>For server @{[$addr || 'any']} map @{[$map || 'any']}:</h2>\n";
+ print "<h2>For server $addr type $type map $map</h2>\n";
print "<table><tr><th>Weapon</th><th>Rating</th>\n";
printf '<th><img width=70 height=80 src="http://svn.icculus.org/*checkout*/nexuiz/trunk/Docs/htmlfiles/weaponimg/thirdperson-%s.png" alt="%s"></th>', $stats->weaponid_to_model($_), $stats->weaponid_to_name($_) for @columns;
print "</tr>\n";
$out->(start => ());
$stats->allstats(sub
{
- my ($addr, $map, $data) = @_;
+ my ($addr, $type, $map, $data) = @_;
my $values = Evaluate $data;
my $valid = defined [values %$values]->[0];
my @weapons_sorted = sort { $valid ? $values->{$b} <=> $values->{$a} : $a <=> $b } keys %$values;
my $min = undef;
- $out->(startmatrix => ($addr, $map, @weapons_sorted));
+ $out->(startmatrix => ($addr, $type, $map, @weapons_sorted));
for my $row(@weapons_sorted)
{
$out->(startrow => $row, ($valid ? $values->{$row} : undef));