ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/ext/schmorplog.ext
(Generate patch)

Comparing deliantra/server/ext/schmorplog.ext (file contents):
Revision 1.11 by root, Wed Nov 14 08:09:46 2007 UTC vs.
Revision 1.15 by root, Wed Apr 30 10:36:01 2008 UTC

1#! perl # depends=irc 1#! perl # depends=irc
2 2
3use Fcntl;
4use Coro::AIO;
5
3our $UPDATE_LOGINS = EV::idle Coro::unblock_sub { 6our $UPDATE_LOGINS = EV::idle sub {
4 $_[0]->stop; 7 $_[0]->stop;
5 8
9 cf::async {
6 my ($status, @pl) = ext::commands::who_listing; 10 my ($status, @pl) = ext::commands::who_listing;
7 11
8 #TODO: write files asynchronously 12 my $fh = aio_open "$LOCALDIR/usercount", O_WRONLY | O_CREAT | O_TRUNC, 0644
9 open my $fh, ">", "$LOCALDIR/usercount"; 13 or return;
10 print $fh scalar @pl; 14 aio_write $fh, 0, undef, scalar @pl, 0;
15 aio_close $fh;
11 16
12 open my $fh, ">", "$LOCALDIR/userlisting.html"; 17 my $who;
13 for ($status, @pl) { 18 for ($status, @pl) {
14 s/[<&]//g; 19 s/[<&]//g;
15 print $fh "$_<br />\n"; 20 $who .= "$_<br />\n";
21 }
22
23 my $fh = aio_open "$LOCALDIR/userlisting.html", O_WRONLY | O_CREAT | O_TRUNC, 0644
24 or return;
25 aio_write $fh, 0, undef, $who, 0;
26 aio_close $fh;
16 } 27 };
17}; 28};
29
30cf::object->attach (
31 on_kill => sub {
32 my ($ob, $hitter) = @_;
33
34 return unless $hitter;
35 $hitter = $hitter->outer_owner;
36 my $pl = $hitter->contr
37 or return;
38
39 ++$hitter->{stats_kill}{$ob->name_pl};
40 },
41);
18 42
19cf::player->attach ( 43cf::player->attach (
20 on_login => sub { 44 on_login => sub {
21 my ($pl) = @_; 45 my ($pl) = @_;
22 $pl->ob->set_ob_key_value (schmorplog_last_login => time); 46 $pl->ob->set_ob_key_value (schmorplog_last_login => time);
56 80
57 warn "QUIT: ", $pl->ob->name, " from ", $pl->ns->host; 81 warn "QUIT: ", $pl->ob->name, " from ", $pl->ns->host;
58 }, 82 },
59 on_death => sub { 83 on_death => sub {
60 my ($pl) = @_; 84 my ($pl) = @_;
61 ext::irc::do_notice (sprintf "%s was killed by %s", $pl->ob->name, $pl->killer); 85 ext::irc::do_notice (sprintf "%s was killed by %s", $pl->ob->name, $pl->killer_name);
86
87 ++$pl->ob->{stats_death}{$pl->killer_name};
62 88
63 $pl->ob->set_ob_key_value (schmorplog_death_count => 89 $pl->ob->set_ob_key_value (schmorplog_death_count =>
64 1 + $pl->ob->get_ob_key_value ("schmorplog_death_count")); 90 1 + $pl->ob->get_ob_key_value ("schmorplog_death_count"));
65 }, 91 },
66 on_load => sub { 92 on_load => sub {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines