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.10 by root, Mon Jun 11 22:18:03 2007 UTC vs.
Revision 1.16 by root, Wed Apr 30 13:44:41 2008 UTC

1#! perl # depends=irc 1#! perl # depends=irc
2 2
3our $UPDATE_LOGINS = Event->idle (repeat => 0, min => 1, data => cf::WF_AUTOCANCEL, cb => Coro::unblock_sub { 3use Fcntl;
4 my ($status, @pl) = ext::commands::who_listing; 4use Coro::AIO;
5 5
6 #TODO: write files asynchronously 6our $UPDATE_LOGINS = EV::idle sub {
7 open my $fh, ">", "$LOCALDIR/usercount"; 7 $_[0]->stop;
8 print $fh scalar @pl;
9 8
10 open my $fh, ">", "$LOCALDIR/userlisting.html"; 9 cf::async {
10 my ($status, @pl) = ext::commands::who_listing;
11
12 my $fh = aio_open "$LOCALDIR/usercount", O_WRONLY | O_CREAT | O_TRUNC, 0644
13 or return;
14 aio_write $fh, 0, undef, scalar @pl, 0;
15 aio_close $fh;
16
17 my $who;
11 for ($status, @pl) { 18 for ($status, @pl) {
12 s/[<&]//g; 19 s/[<&]//g;
13 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;
14 } 27 };
15}); 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};
40 },
41);
16 42
17cf::player->attach ( 43cf::player->attach (
18 on_login => sub { 44 on_login => sub {
19 my ($pl) = @_; 45 my ($pl) = @_;
20 $pl->ob->set_ob_key_value (schmorplog_last_login => time); 46 $pl->ob->set_ob_key_value (schmorplog_last_login => time);
54 80
55 warn "QUIT: ", $pl->ob->name, " from ", $pl->ns->host; 81 warn "QUIT: ", $pl->ob->name, " from ", $pl->ns->host;
56 }, 82 },
57 on_death => sub { 83 on_death => sub {
58 my ($pl) = @_; 84 my ($pl) = @_;
59 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};
60 88
61 $pl->ob->set_ob_key_value (schmorplog_death_count => 89 $pl->ob->set_ob_key_value (schmorplog_death_count =>
62 1 + $pl->ob->get_ob_key_value ("schmorplog_death_count")); 90 1 + $pl->ob->get_ob_key_value ("schmorplog_death_count"));
63 }, 91 },
64 on_load => sub { 92 on_load => sub {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines