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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines