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;
}
}
{
my ($self, $callback) = @_;
# send global stats
- $callback->(undef, undef, $self->{allstats});
+ $callback->(undef, undef, undef, $self->{allstats});
# 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);
+ }
}
}
}
1 => ["Laser", "laser"],
2 => ["Shotgun", "shotgun"],
3 => ["Uzi", "uzi"],
- 4 => ["Mortar", "gl"],
+ 4 => ["Mortar", "grenadelauncher"],
5 => ["Mine Layer", "minelayer"],
6 => ["Electro", "electro"],
7 => ["Crylink", "crylink"],
8 => ["Nex", "nex"],
9 => ["Hagar", "hagar"],
- 10 => ["Rocket Launcher", "rl"],
+ 10 => ["Rocket Launcher", "rocketlauncher"],
11 => ["Port-O-Launch", "porto"],
12 => ["MinstaNex", "minstanex"],
- 13 => ["Grappling Hook", "hookgun"],
+ 13 => ["Grappling Hook", "hook"],
14 => ["Heavy Laser Assault Cannon", "hlac"],
15 => ["@!#%'n Tuba", "tuba"],
- 16 => ["Sniper Rifle", "sniperrifle"],
+ 16 => ["Sniper Rifle", "rifle"],
17 => ["Fireball", "fireball"],
18 => ["Seeker", "seeker"],
);