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.61 by root, Tue Aug 14 12:17:34 2007 UTC vs.
Revision 1.71 by root, Tue Sep 23 00:24:52 2008 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 (log => (join "\n\n", who_listing $ob->may ("extended_who"), $arg), cf::NDI_DK_ORANGE | cf::NDI_REPLY); 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_UNIQUE); 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_UNIQUE); 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_UNIQUE); 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_UNIQUE); 75 $pl->message ("Usage: seen <player>", cf::NDI_REPLY);
72 } 76 }
73 } else {
74 $pl->message ("Usage: seen <player>", cf::NDI_UNIQUE);
75 } 77 };
76}; 78};
77 79
78cf::register_command body => sub { 80cf::register_command body => sub {
79 my ($ob) = @_; 81 my ($ob) = @_;
80 82
81 # Too hard to try and make a header that lines everything up, so just 83 # Too hard to try and make a header that lines everything up, so just
82 # give a description. (comment from C++) 84 # give a description. (comment from C++)
83 my $reply = 85 my $reply =
84 "The first column is the name of the body location.\n\n" 86 "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" 87 . "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"; 88 . "The third column is how many slots in that location are available.\n\n";
87 89
88 $reply .= sprintf " %-20s %3s %5s\n", "Location", "You", "Avail"; 90 $reply .= sprintf " %-20s %3s %5s\n", "Location", "You", "Avail";
89 for (0 .. cf::NUM_BODY_LOCATIONS - 1) { 91 for (0 .. cf::NUM_BODY_LOCATIONS - 1) {
90 my $msg = cf::object::slot_nonuse_name $_; 92 my $msg = cf::object::slot_nonuse_name $_;
91 $msg =~ s/^.*? a //; 93 $msg =~ s/^.*? a //;
92 $reply .= sprintf " %-20s %3d %5d\n", $msg, $ob->slot_info ($_), $ob->slot_used ($_) 94 $reply .= sprintf " %-20s %3d %5d\n", $msg, $ob->slot_info ($_), $ob->slot_used ($_)
93 if $ob->slot_info ($_) or $ob->slot_used ($_); 95 if $ob->slot_info ($_) or $ob->slot_used ($_);
94 } 96 }
95 97
96 $reply .= "You are not allowed to wear armor\n\n" 98 $reply .= "You are not allowed to wear armor\r"
97 unless $ob->flag (cf::FLAG_USE_ARMOUR); 99 unless $ob->flag (cf::FLAG_USE_ARMOUR);
98 $reply .= "You are not allowed to use weapons\n\n" 100 $reply .= "You are not allowed to use weapons\r"
99 unless $ob->flag (cf::FLAG_USE_WEAPON); 101 unless $ob->flag (cf::FLAG_USE_WEAPON);
100 102
101 $ob->reply (undef, $reply); 103 $ob->send_msg ("c/body" => $reply, cf::NDI_REPLY);
102}; 104};
103 105
104cf::register_command mark => sub { 106cf::register_command mark => sub {
105 my ($pl, $arg) = @_; 107 my ($pl, $arg) = @_;
106 108
146 my $observe = $ob->contr->observe; 148 my $observe = $ob->contr->observe;
147 149
148 my $map = $observe->map 150 my $map = $observe->map
149 or return; 151 or return;
150 152
151 my $msg = sprintf "%s (%s) %s", $map->name, $map->path, $observe->region->longname; 153 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", 154 $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 155 (scalar $map->players), $map->difficulty, $map->width, $map->height, $map->enter_x, $map->enter_y, $map->timeout
154 if $ob->flag (cf::FLAG_WIZ); 156 if $ob->flag (cf::FLAG_WIZ);
157
155 $ob->send_msg (log => $msg, cf::NDI_REPLY); 158 $ob->send_msg ("c/mapinfo" => $msg, cf::NDI_REPLY | cf::NDI_CLEAR);
156}; 159};
157 160
158cf::register_command whereami => sub { 161cf::register_command whereami => sub {
159 my ($ob) = @_; 162 my ($ob) = @_;
160 163
161 my $reg = $ob->contr->observe->region; 164 my $reg = $ob->contr->observe->region;
162 $ob->reply (undef, (sprintf "You are %s.\n%s", $reg->longname, $reg->msg)); 165 $ob->send_msg ("c/who" => (sprintf "You are %s.\n\n%s", $reg->longname, $reg->msg), cf::NDI_REPLY | cf::NDI_CLEAR);
163}; 166};
164 167
165cf::register_command whereabouts => sub { 168cf::register_command whereabouts => sub {
166 my ($ob, $arg) = @_; 169 my ($ob, $arg) = @_;
167 170
169 172
170 for my $pl (cf::player::list) { 173 for my $pl (cf::player::list) {
171 ++$count{$pl->ob->region->longname}; 174 ++$count{$pl->ob->region->longname};
172 } 175 }
173 176
174 my $msg = "In the world currently there are:\n\n" 177 my $msg = "T<In the world currently there are:>\n\n"
175 . join "", map "$count{$_} player(s) $_\n\n", sort keys %count; 178 . join "", map { sprintf " C<%3d >player(s) %s\r", $count{$_}, $_ } sort keys %count;
176 179
177 $ob->send_msg (log => $msg, cf::NDI_REPLY); 180 $ob->send_msg ("c/who" => $msg, cf::NDI_REPLY | cf::NDI_CLEAR);
178}; 181};
179 182
180cf::register_command hiscore => sub { 183cf::register_command hiscore => sub {
181 my ($ob, $arg) = @_; 184 my ($ob, $arg) = @_;
182 185
183 my $url = $cf::CFG->{hiscore_url}; 186 my $url = $cf::CFG{hiscore_url};
184 $ob->send_msg (log => "See $url", cf::NDI_REPLY); 187 $ob->send_msg (log => "See $url", cf::NDI_REPLY);
185}; 188};
186 189
187sub _set_mode($$$@) { 190sub _set_mode($$$@) {
188 my ($name, $ob, $arg, $slot, @choices) = @_; 191 my ($name, $ob, $arg, $slot, @choices) = @_;
369cf::register_command uptime => sub { 372cf::register_command uptime => sub {
370 my ($ob, $arg) = @_; 373 my ($ob, $arg) = @_;
371 374
372 my $startup = POSIX::strftime "%Y-%m-%d %H:%M:%S %Z", localtime $cf::UPTIME; 375 my $startup = POSIX::strftime "%Y-%m-%d %H:%M:%S %Z", localtime $cf::UPTIME;
373 my $runtime = sprintf "%.1f", (time - $cf::UPTIME) / 86400; 376 my $runtime = sprintf "%.1f", (time - $cf::UPTIME) / 86400;
374 $ob->reply (undef, "server started $startup, uptime ${runtime}\d"); 377 $ob->send_msg ("c/uptime" => "server started $startup, uptime ${runtime}\d", cf::NDI_REPLY | cf::NDI_CLEAR);
375}; 378};
376 379
377my %IN_MEMORY = ( 380my %IN_MEMORY = (
378 cf::MAP_IN_MEMORY => "I", 381 cf::MAP_ACTIVE => "I",
379 cf::MAP_SWAPPED => "S", 382 cf::MAP_SWAPPED => "S",
380 cf::MAP_LOADING => "L", 383 cf::MAP_LOADING => "L",
381); 384);
382 385
383cf::register_command maps => sub { 386cf::register_command maps => sub {
384 my ($ob, $arg) = @_; 387 my ($ob, $arg) = @_;
385 388
386 no re 'eval'; $arg = qr<$arg>; 389 no re 'eval'; $arg = qr<$arg>;
387 390
388 my $format = "%2s %1s %3s %5s %.60s\n"; 391 my $format = " %2s %1s %3s %5s %.60s\n";
389 392
390 $ob->reply (undef, (sprintf $format, "Pl", "I", "Svd", "Reset", "Name"), cf::NDI_BLACK | cf::NDI_UNIQUE); 393 my $msg = "\n" . sprintf $format, "Pl", "I", "Svd", "Reset", "Name";
391 394
392 for (sort keys %cf::MAP) { 395 for (sort keys %cf::MAP) {
393 my $map = $cf::MAP{$_} 396 my $map = $cf::MAP{$_}
394 or next; 397 or next;
395 398
397 next if $map->{deny_list}; 400 next if $map->{deny_list};
398 401
399 my $svd = int $cf::RUNTIME - $map->{last_save}; 402 my $svd = int $cf::RUNTIME - $map->{last_save};
400 $svd = "++" if $svd > 99; 403 $svd = "++" if $svd > 99;
401 404
402 $ob->reply (undef, 405 $msg .= sprintf $format,
403 (sprintf $format,
404 (scalar $map->players), 406 (scalar $map->players),
405 $IN_MEMORY{$map->in_memory} || "?", 407 $IN_MEMORY{$map->in_memory} || "?",
406 $svd, 408 $svd,
407 (int $map->reset_at - $cf::RUNTIME), 409 (int $map->reset_at - $cf::RUNTIME),
408 $map->visible_name), 410 $map->visible_name;
409 cf::NDI_BLACK | cf::NDI_UNIQUE);
410 } 411 }
411};
412 412
413 $ob->send_msg ("c/mapinfo" => $msg, cf::NDI_REPLY | cf::NDI_CLEAR);
414};
415

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines