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.6 by root, Fri Sep 29 20:16:58 2006 UTC vs.
Revision 1.15 by root, Tue Dec 12 16:59:34 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) = @_;
31 $ob->message ("You stop calling your " . $item->base_name . " with weird names."); 33 $ob->message ("You stop calling your " . $item->base_name . " with weird names.");
32 } 34 }
33 35
34 $ob->esrv_update_item (cf::UPD_NAME, $item); 36 $ob->esrv_update_item (cf::UPD_NAME, $item);
35 37
36 return 1; 38 1
37} 39}
40
41sub ext::schmorp_irc::users; # HACK: TODO: replace by signal
38 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);
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->client . "]"
67 . " [" . ($pl->peaceful ? $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") . "]"
68 . ($privileged ? " " . $pl->host : "") 73 . ($privileged ? " " . $pl->host : "")
69 } sort { $a->ob->name cmp $b->ob->name } @pl 74 } sort { (lc $a->ob->name) cmp (lc $b->ob->name) } @pl
75 ),
76 eval { "* IRC: " . join ", ", ext::schmorp_irc::users },
70 ) 77 )
71} 78}
72 79
73cf::register_command who => $cf::TICK, sub { 80cf::register_command who => sub {
74 my ($ob, $arg) = @_; 81 my ($ob, $arg) = @_;
75 82
83 $ob->speed_left ($ob->speed_left - 0.25);
84
76 $ob->reply (undef, (join "\n", who_listing $ob->flag (cf::FLAG_WIZ)), cf::NDI_UNIQUE | cf::NDI_GOLD); 85 $ob->reply (undef, (join "\n", who_listing $ob->may ("extended_who")), cf::NDI_UNIQUE | cf::NDI_DK_ORANGE);
86
87 1
77}; 88};
78 89
79cf::register_command rename => $cf::TICK, sub { 90cf::register_command rename => sub {
80 my ($ob, $arg) = @_; 91 my ($ob, $arg) = @_;
81 92
93 $ob->speed_left ($ob->speed_left - 0.25);
94
82 if ($arg =~ /^\s* (?: <([^>]+)> \s+)? to \s+ <([^>]+)> \s*$/x) { 95 if ($arg =~ /^\s* (?: <([^>]+)> \s+)? to \s+ <([^>]*)> \s*$/x) {
83 # compatibility syntax 96 # compatibility syntax
84 rename_to $ob, $1, $2; 97 rename_to $ob, $1, $2;
85 } elsif ($arg =~ / 98 } elsif ($arg =~ /
86 ^\s* 99 ^\s*
87 (?: 100 (?:
94 # does not unquote $1 or $3 107 # does not unquote $1 or $3
95 rename_to $ob, $2||$1, $4||$3; 108 rename_to $ob, $2||$1, $4||$3;
96 } else { 109 } else {
97 $ob->reply (undef, 'Syntax error. Rename usage: rename ["oldname"] to "newname"'); 110 $ob->reply (undef, 'Syntax error. Rename usage: rename ["oldname"] to "newname"');
98 } 111 }
112
113 1
99}; 114};
115
116cf::register_command uptime => sub {
117 my ($ob, $arg) = @_;
118
119 my $startup = POSIX::strftime "%Y-%m-%d %H:%M:%S %Z", localtime $cf::UPTIME;
120 my $runtime = sprintf "%.1f", (time - $cf::UPTIME) / 86400;
121 $ob->reply (undef, "server started $startup, uptime ${runtime}\d");
122
123 1
124};
125

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines