ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/maps/perl/commands.ext
(Generate patch)

Comparing deliantra/maps/perl/commands.ext (file contents):
Revision 1.11 by root, Wed Nov 8 00:54:11 2006 UTC vs.
Revision 1.16 by root, Fri Dec 15 19:06:29 2006 UTC

1#! perl 1#! perl
2
3use POSIX ();
2 4
3# miscellaneous commands 5# miscellaneous commands
4 6
5sub rename_to($$$) { 7sub rename_to($$$) {
6 my ($ob, $from, $to) = @_; 8 my ($ob, $from, $to) = @_;
34 $ob->esrv_update_item (cf::UPD_NAME, $item); 36 $ob->esrv_update_item (cf::UPD_NAME, $item);
35 37
36 1 38 1
37} 39}
38 40
41sub ext::schmorp_irc::users; # HACK: TODO: replace by signal
42
39sub who_listing(;$) { 43sub who_listing(;$) {
40 my ($privileged) = @_; 44 my ($privileged) = @_;
41 45
42 my ($numwiz, $numafk) = (0, 0); 46 my ($numwiz, $numafk) = (0, 0);
43 my @pl; 47 my @pl;
54 push @pl, $pl; 58 push @pl, $pl;
55 } 59 }
56 60
57 ( 61 (
58 "Total Players in The World. (" . (scalar @pl) . ") -- WIZ($numwiz) AFK($numafk) BOT(0)", 62 "Total Players in The World. (" . (scalar @pl) . ") -- WIZ($numwiz) AFK($numafk) BOT(0)",
63 (
59 map { 64 map {
60 my ($pl, $ob) = ($_, $_->ob); 65 my ($pl, $ob) = ($_, $_->ob);
61 66
62 "* " . $ob->name . "/" . $ob->level . " " . (length $pl->own_title ? $pl->own_title : "the " . $pl->title) 67 "* " . $ob->name . "/" . $ob->level . " " . (length $pl->own_title ? $pl->own_title : "the " . $pl->title)
63 . ($pl->peaceful ? " [peaceful]" : " [HOSTILE]") 68 . ($pl->peaceful ? " [peaceful]" : " [HOSTILE]")
64 . ($ob->flag (cf::FLAG_AFK) ? " [AFK]" : "") 69 . ($ob->flag (cf::FLAG_AFK) ? " [AFK]" : "")
65 . ($ob->flag (cf::FLAG_WIZ) ? " [WIZ]" : "") 70 . ($ob->flag (cf::FLAG_WIZ) ? " [WIZ]" : "")
66 . " [" . $pl->client . "]" 71 . " [" . $pl->socket->client . "]"
67 . " [" . ($pl->peaceful || $privileged ? $ob->map->path : $ob->map->region ? $ob->map->region->name : "the unknown") . "]" 72 . " [" . ($pl->peaceful || $privileged ? $ob->map->path : $ob->map->region ? $ob->map->region->name : "the unknown") . "]"
73 . (sprintf " [rtt %.3fs/%.3f]", $pl->socket->rtt * 1e-6, $pl->socket->rttvar * 1e-6)
68 . ($privileged ? " " . $pl->host : "") 74 . ($privileged ? " " . $pl->socket->host : "")
69 } sort { (lc $a->ob->name) cmp (lc $b->ob->name) } @pl 75 } sort { (lc $a->ob->name) cmp (lc $b->ob->name) } @pl
76 ),
77 eval { "* IRC: " . join ", ", ext::schmorp_irc::users },
70 ) 78 )
71} 79}
72 80
73cf::register_command who => $cf::TICK, sub { 81cf::register_command who => sub {
74 my ($ob, $arg) = @_; 82 my ($ob, $arg) = @_;
75 83
84 $ob->speed_left ($ob->speed_left - 0.25);
85
76 $ob->reply (undef, (join "\n", who_listing $ob->flag (cf::FLAG_WIZ)), cf::NDI_UNIQUE | cf::NDI_DK_ORANGE); 86 $ob->reply (undef, (join "\n", who_listing $ob->may ("extended_who")), cf::NDI_UNIQUE | cf::NDI_DK_ORANGE);
77 87
78 1 88 1
79}; 89};
80 90
81cf::register_command rename => $cf::TICK, sub { 91cf::register_command rename => sub {
82 my ($ob, $arg) = @_; 92 my ($ob, $arg) = @_;
93
94 $ob->speed_left ($ob->speed_left - 0.25);
83 95
84 if ($arg =~ /^\s* (?: <([^>]+)> \s+)? to \s+ <([^>]*)> \s*$/x) { 96 if ($arg =~ /^\s* (?: <([^>]+)> \s+)? to \s+ <([^>]*)> \s*$/x) {
85 # compatibility syntax 97 # compatibility syntax
86 rename_to $ob, $1, $2; 98 rename_to $ob, $1, $2;
87 } elsif ($arg =~ / 99 } elsif ($arg =~ /
100 } 112 }
101 113
102 1 114 1
103}; 115};
104 116
117cf::register_command uptime => sub {
118 my ($ob, $arg) = @_;
119
120 my $startup = POSIX::strftime "%Y-%m-%d %H:%M:%S %Z", localtime $cf::UPTIME;
121 my $runtime = sprintf "%.1f", (time - $cf::UPTIME) / 86400;
122 $ob->reply (undef, "server started $startup, uptime ${runtime}\d");
123
124 1
125};
126

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines