aboutsummaryrefslogtreecommitdiff
path: root/lib/MasterServer/Util/KFStatsWatcher.pm
diff options
context:
space:
mode:
authorDarkelarious <darkelarious@333networks.com>2017-08-22 11:00:13 +0200
committerDarkelarious <darkelarious@333networks.com>2017-08-22 11:00:13 +0200
commitc06322da38b4cb76b2036af1a5448083adb8ff20 (patch)
tree189c9f0fec3325be927f763aba23cf18aa68cfe4 /lib/MasterServer/Util/KFStatsWatcher.pm
parente0d727670cbeda0db0812c5c9efc503d75f8d0a4 (diff)
downloadMasterServer-Perl-c06322da38b4cb76b2036af1a5448083adb8ff20.tar.gz
MasterServer-Perl-c06322da38b4cb76b2036af1a5448083adb8ff20.zip
new server checking mechanism, complete recode of major functionsv2.4.0
Diffstat (limited to 'lib/MasterServer/Util/KFStatsWatcher.pm')
-rwxr-xr-xlib/MasterServer/Util/KFStatsWatcher.pm22
1 files changed, 6 insertions, 16 deletions
diff --git a/lib/MasterServer/Util/KFStatsWatcher.pm b/lib/MasterServer/Util/KFStatsWatcher.pm
index 6601aa3..d78fbf9 100755
--- a/lib/MasterServer/Util/KFStatsWatcher.pm
+++ b/lib/MasterServer/Util/KFStatsWatcher.pm
@@ -4,51 +4,41 @@ use strict;
use warnings;
use AnyEvent::IO;
use Exporter 'import';
-
our @EXPORT = qw| read_kfstats |;
################################################################################
## Read Killing Floor Statistics from the file.
################################################################################
sub read_kfstats {
- my ($self) = shift;
+ my $self = shift;
# open file and read content
return aio_load($self->{kfstats_file},
sub {
my $f = shift;
-
- # process player data as blocks
my $block = "";
# read player stats
for my $l (split /^/, $f) {
-
- # add data to block
+ # add data to "player" block
$block .= $l;
# if block contains last item GamesLost, process block
if ($l =~ m/^(GamesLost=)/i){
-
- # treat as array
my @s = split "\n", $block;
# process items
my %h;
for my $m (@s) {
- if ($m =~ m/(KFPlayerStats\])$/i) { $h{UTkey} = substr $m, 1, index($m, " ")-1; }
- if ($m =~ m/=/) {$h{substr $m, 0, index($m, "=")} = substr $m, index($m, "=")+1; }
+ if ($m =~ m/(KFPlayerStats\])$/i) {
+ $h{UTkey} = substr $m, 1, index($m, " ")-1;}
+ if ($m =~ m/=/) {
+ $h{substr $m, 0, index($m, "=")} = substr $m, index($m, "=")+1;}
}
-
- # store in db
$self->write_kfstats(\%h);
-
- # clear block for next player
$block = "";
}
}
-
- # notify
$self->log("kfstat", "Updated Killing Floor player stats.");
}
);