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

Comparing deliantra/server/ext/commands.ext (file contents):
Revision 1.65 by root, Sat Nov 10 22:43:25 2007 UTC vs.
Revision 1.73 by root, Sat Oct 3 22:36:08 2009 UTC

47cf::register_command who => sub { 47cf::register_command who => sub {
48 my ($ob, $arg) = @_; 48 my ($ob, $arg) = @_;
49 49
50 $ob->speed_left ($ob->speed_left - 4); 50 $ob->speed_left ($ob->speed_left - 4);
51 51
52 $ob->send_msg ("c/who" => (join "\n\n", who_listing $ob->may ("extended_who"), $arg), cf::NDI_DK_ORANGE | cf::NDI_REPLY | cf::NDI_CLEAR | cf::NDI_DEF); 52 $ob->send_msg ("c/who" => (join "\r", who_listing $ob->may ("extended_who"), $arg), cf::NDI_DK_ORANGE | cf::NDI_REPLY | cf::NDI_CLEAR | cf::NDI_DEF);
53}; 53};
54 54
55cf::register_command seen => sub { 55cf::register_command seen => sub {
56 my ($pl, $args) = @_; 56 my ($pl, $args) = @_;
57 57
58 cf::async {
58 if (my ($login) = $args =~ /(\S+)/) { 59 if (my ($login) = $args =~ /(\S+)/) {
59 if ($login eq $pl->name) { 60 if ($login eq $pl->name) {
60 $pl->message ("Very funny, $login. Ha. Ha.", cf::NDI_REPLY); 61 $pl->message ("Very funny, $login. Ha. Ha.", cf::NDI_REPLY);
61 } elsif (cf::player::find_active $login) { 62 } elsif (cf::player::find_active $login) {
62 $pl->message ("$login is right here on this server!", cf::NDI_REPLY); 63 $pl->message ("$login is right here on this server!", cf::NDI_REPLY);
63 } elsif (cf::player::exists $login 64 } elsif (cf::player::exists $login
64 and stat cf::player::path $login) { 65 and stat cf::player::path $login) {
65 my $time = (stat _)[9]; 66 my $time = (stat _)[9];
66 67
67 $pl->message ("$login was last seen here " 68 $pl->message ("$login was last seen here "
68 . (POSIX::strftime "%Y-%m-%d %H:%M:%S +0000", gmtime $time) 69 . (POSIX::strftime "%Y-%m-%d %H:%M:%S +0000", gmtime $time)
69 . " which was " . (int +(time - $time) / 3600) . " hours ago.", cf::NDI_REPLY); 70 . " which was " . (int +(time - $time) / 3600) . " hours ago.", cf::NDI_REPLY);
71 } else {
72 $pl->message ("No player named $login is known to me.", cf::NDI_REPLY);
73 }
70 } else { 74 } else {
71 $pl->message ("No player named $login is known to me.", cf::NDI_REPLY); 75 $pl->message ("Usage: seen <player>", cf::NDI_REPLY);
72 } 76 }
73 } else {
74 $pl->message ("Usage: seen <player>", cf::NDI_REPLY);
75 } 77 };
76}; 78};
77 79
78cf::register_command body => sub { 80cf::register_command body => sub {
79 my ($ob) = @_; 81 my ($ob) = @_;
82
83 my $observe = $ob->contr->observe;
80 84
81 # Too hard to try and make a header that lines everything up, so just 85 # Too hard to try and make a header that lines everything up, so just
82 # give a description. (comment from C++) 86 # give a description. (comment from C++)
83 my $reply = 87 my $reply =
84 "The first column is the name of the body location.\n\n" 88 "The first column is the name of the body location.\r"
85 . "The second column is how many of those locations your body has.\n\n" 89 . "The second column is how many of those locations your body has.\r"
86 . "The third column is how many slots in that location are available.\n\n"; 90 . "The third column is how many slots in that location are available.\r"
91 . "The last column shows the items currently using the slot\n\n";
87 92
93 # first process all applied items and hash them into their slots
94 my @slot;
95
96 for my $item (grep $_->flag (cf::FLAG_APPLIED), $observe->inv) {
97 $item->slot_info ($_)
98 and push @{ $slot[$_] }, $item
99 for 0 .. cf::NUM_BODY_LOCATIONS-1;
100 }
101
88 $reply .= sprintf " %-20s %3s %5s\n", "Location", "You", "Avail"; 102 $reply .= sprintf " %-20s %3s %5s %s\n", "Location", "You", "Avail", "What";
89 for (0 .. cf::NUM_BODY_LOCATIONS - 1) { 103 for (0 .. cf::NUM_BODY_LOCATIONS - 1) {
90 my $msg = cf::object::slot_nonuse_name $_; 104 my $msg = cf::object::slot_nonuse_name $_;
91 $msg =~ s/^.*? a //; 105 $msg =~ s/^.*? a //;
92 $reply .= sprintf " %-20s %3d %5d\n", $msg, $ob->slot_info ($_), $ob->slot_used ($_) 106 $reply .= sprintf " %-20s %3d %5d %s\n",
107 $msg,
108 $observe->slot_info ($_),
109 $observe->slot_used ($_),
110 join ", ", map $_->query_short_name, @{ $slot[$_] }
93 if $ob->slot_info ($_) or $ob->slot_used ($_); 111 if $observe->slot_info ($_) || $observe->slot_used ($_);
94 } 112 }
95 113
96 $reply .= "You are not allowed to wear armor\n\n" 114 $reply .= "You are not allowed to wear armor\r"
97 unless $ob->flag (cf::FLAG_USE_ARMOUR); 115 unless $observe->flag (cf::FLAG_USE_ARMOUR);
98 $reply .= "You are not allowed to use weapons\n\n" 116 $reply .= "You are not allowed to use weapons\r"
99 unless $ob->flag (cf::FLAG_USE_WEAPON); 117 unless $observe->flag (cf::FLAG_USE_WEAPON);
100 118
101 $ob->send_msg ("c/body" => $reply, cf::NDI_REPLY); 119 $ob->send_msg ("c/body" => $reply, cf::NDI_REPLY | cf::NDI_CLEAR);
102}; 120};
103 121
104cf::register_command mark => sub { 122cf::register_command mark => sub {
105 my ($pl, $arg) = @_; 123 my ($pl, $arg) = @_;
106 124
146 my $observe = $ob->contr->observe; 164 my $observe = $ob->contr->observe;
147 165
148 my $map = $observe->map 166 my $map = $observe->map
149 or return; 167 or return;
150 168
151 my $msg = sprintf "%s (%s) %s", $map->name, $map->path, $observe->region->longname; 169 my $msg = sprintf "%s (%s)\r%s", $map->name, $map->path, $observe->region->longname;
152 $msg .= sprintf "\n\nplayers: %d difficulty: %d size: %d start: %dx%d timeout: %d", 170 $msg .= sprintf "\rplayers: %d difficulty: %d size: %d start: %dx%d timeout: %d",
153 (scalar $map->players), $map->difficulty, $map->width, $map->height, $map->enter_x, $map->enter_y, $map->timeout 171 (scalar $map->players), $map->difficulty, $map->width, $map->height, $map->enter_x, $map->enter_y, $map->timeout
154 if $ob->flag (cf::FLAG_WIZ); 172 if $ob->flag (cf::FLAG_WIZ);
155 173
156 $ob->send_msg ("c/mapinfo" => $msg, cf::NDI_REPLY | cf::NDI_CLEAR); 174 $ob->send_msg ("c/mapinfo" => $msg, cf::NDI_REPLY | cf::NDI_CLEAR);
157}; 175};
158 176
159cf::register_command whereami => sub { 177cf::register_command whereami => sub {
160 my ($ob) = @_; 178 my ($ob) = @_;
161 179
162 my $reg = $ob->contr->observe->region; 180 my $reg = $ob->contr->observe->region;
163 $ob->send_msg ("c/mapinfo" => (sprintf "You are %s.\n%s", $reg->longname, $reg->msg), cf::NDI_REPLY | cf::NDI_CLEAR); 181 $ob->send_msg ("c/who" => (sprintf "You are %s.\n\n%s", $reg->longname, $reg->msg), cf::NDI_REPLY | cf::NDI_CLEAR);
164}; 182};
165 183
166cf::register_command whereabouts => sub { 184cf::register_command whereabouts => sub {
167 my ($ob, $arg) = @_; 185 my ($ob, $arg) = @_;
168 186
170 188
171 for my $pl (cf::player::list) { 189 for my $pl (cf::player::list) {
172 ++$count{$pl->ob->region->longname}; 190 ++$count{$pl->ob->region->longname};
173 } 191 }
174 192
175 my $msg = "In the world currently there are:\n\n" 193 my $msg = "T<In the world currently there are:>\n\n"
176 . join "", map "$count{$_} player(s) $_\n\n", sort keys %count; 194 . join "", map { sprintf " C<%3d >player(s) %s\r", $count{$_}, $_ } sort keys %count;
177 195
178 $ob->send_msg ("c/mapinfo" => $msg, cf::NDI_REPLY | cf::NDI_CLEAR); 196 $ob->send_msg ("c/who" => $msg, cf::NDI_REPLY | cf::NDI_CLEAR);
179}; 197};
180 198
181cf::register_command hiscore => sub { 199cf::register_command hiscore => sub {
182 my ($ob, $arg) = @_; 200 my ($ob, $arg) = @_;
183 201
374 my $runtime = sprintf "%.1f", (time - $cf::UPTIME) / 86400; 392 my $runtime = sprintf "%.1f", (time - $cf::UPTIME) / 86400;
375 $ob->send_msg ("c/uptime" => "server started $startup, uptime ${runtime}\d", cf::NDI_REPLY | cf::NDI_CLEAR); 393 $ob->send_msg ("c/uptime" => "server started $startup, uptime ${runtime}\d", cf::NDI_REPLY | cf::NDI_CLEAR);
376}; 394};
377 395
378my %IN_MEMORY = ( 396my %IN_MEMORY = (
379 cf::MAP_IN_MEMORY => "I", 397 cf::MAP_ACTIVE => "I",
380 cf::MAP_SWAPPED => "S", 398 cf::MAP_SWAPPED => "S",
381 cf::MAP_LOADING => "L", 399 cf::MAP_LOADING => "L",
382); 400);
383 401
384cf::register_command maps => sub { 402cf::register_command maps => sub {
385 my ($ob, $arg) = @_; 403 my ($ob, $arg) = @_;
386 404
387 no re 'eval'; $arg = qr<$arg>; 405 no re 'eval'; $arg = qr<$arg>;
388 406
389 my $format = "%2s %1s %3s %5s %.60s\n"; 407 my $format = " %2s %1s %3s %5s %.60s\n";
390 408
391 $ob->send_msg ("c/mapinfo" => (sprintf $format, "Pl", "I", "Svd", "Reset", "Name"), cf::NDI_REPLY | cf::NDI_CLEAR); 409 my $msg = "\n" . sprintf $format, "Pl", "I", "Svd", "Reset", "Name";
392 410
393 for (sort keys %cf::MAP) { 411 for (sort keys %cf::MAP) {
394 my $map = $cf::MAP{$_} 412 my $map = $cf::MAP{$_}
395 or next; 413 or next;
396 414
398 next if $map->{deny_list}; 416 next if $map->{deny_list};
399 417
400 my $svd = int $cf::RUNTIME - $map->{last_save}; 418 my $svd = int $cf::RUNTIME - $map->{last_save};
401 $svd = "++" if $svd > 99; 419 $svd = "++" if $svd > 99;
402 420
403 $ob->send_msg ("c/mapinfo" => 421 $msg .= sprintf $format,
404 (sprintf $format,
405 (scalar $map->players), 422 (scalar $map->players),
406 $IN_MEMORY{$map->in_memory} || "?", 423 $IN_MEMORY{$map->in_memory} || "?",
407 $svd, 424 $svd,
408 (int $map->reset_at - $cf::RUNTIME), 425 (int $map->reset_at - $cf::RUNTIME),
409 $map->visible_name) 426 $map->visible_name;
410 );
411 } 427 }
412};
413 428
429 $ob->send_msg ("c/mapinfo" => $msg, cf::NDI_REPLY | cf::NDI_CLEAR);
430};
431

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines