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.72 by root, Sun Jan 11 06:08:40 2009 UTC vs.
Revision 1.79 by root, Fri May 7 19:46:18 2010 UTC

32 "* " . $ob->name . "/" . $ob->level . " " . (length $pl->own_title ? $pl->own_title : "the " . $pl->title) 32 "* " . $ob->name . "/" . $ob->level . " " . (length $pl->own_title ? $pl->own_title : "the " . $pl->title)
33 . ($pl->gender ? " [f]" : " [m]") 33 . ($pl->gender ? " [f]" : " [m]")
34 . ($pl->peaceful ? " [peaceful]" : " [HOSTILE]") 34 . ($pl->peaceful ? " [peaceful]" : " [HOSTILE]")
35 . ($ns->afk ? " [AFK]" : "") 35 . ($ns->afk ? " [AFK]" : "")
36 . ($ob->flag (cf::FLAG_WIZ) ? " [WIZ]" : "") 36 . ($ob->flag (cf::FLAG_WIZ) ? " [WIZ]" : "")
37 . " [" . $pl->ns->version . "]" 37 . " [" . $pl->ns->{who_version} . "]"
38 . " [" . ($pl->peaceful || $privileged ? $ob->map->visible_name : $ob->region->name) . "]" 38 . " [" . ($pl->peaceful || $privileged ? $ob->map->visible_name : $ob->region->name) . "]"
39 . (sprintf " [rtt %.3fs]", $pl->ns->tcpi_rtt * 1e-6) 39 . (sprintf " [rtt %.3fs]", $pl->ns->tcpi_rtt * 1e-6)
40 . ($privileged ? " " . $pl->ns->host : "") 40 . ($privileged ? " " . $pl->ns->host : "")
41 } sort { (lc $a->ob->name) cmp (lc $b->ob->name) } @pl 41 } sort { (lc $a->ob->name) cmp (lc $b->ob->name) } @pl
42 ), 42 ),
60 if ($login eq $pl->name) { 60 if ($login eq $pl->name) {
61 $pl->message ("Very funny, $login. Ha. Ha.", cf::NDI_REPLY); 61 $pl->message ("Very funny, $login. Ha. Ha.", cf::NDI_REPLY);
62 } elsif (cf::player::find_active $login) { 62 } elsif (cf::player::find_active $login) {
63 $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);
64 } elsif (cf::player::exists $login 64 } elsif (cf::player::exists $login
65 and stat cf::player::path $login) { 65 and !Coro::AIO::aio_stat cf::player::path $login) {
66 my $time = (stat _)[9]; 66 my $time = (stat _)[9];
67 67
68 $pl->message ("$login was last seen here " 68 $pl->message ("$login was last seen here "
69 . (POSIX::strftime "%Y-%m-%d %H:%M:%S +0000", gmtime $time) 69 . (POSIX::strftime "%Y-%m-%d %H:%M:%S +0000", gmtime $time)
70 . " which was " . (int +(time - $time) / 3600) . " hours ago.", cf::NDI_REPLY); 70 . " which was " . (int +(time - $time) / 3600) . " hours ago.", cf::NDI_REPLY);
78}; 78};
79 79
80cf::register_command body => sub { 80cf::register_command body => sub {
81 my ($ob) = @_; 81 my ($ob) = @_;
82 82
83 my $observe = $ob->contr->observe;
84
83 # 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
84 # give a description. (comment from C++) 86 # give a description. (comment from C++)
85 my $reply = 87 my $reply =
86 "The first column is the name of the body location.\r" 88 "The first column is the name of the body location.\r"
87 . "The second column is how many of those locations your body has.\r" 89 . "The second column is how many of those locations your body has.\r"
89 . "The last column shows the items currently using the slot\n\n"; 91 . "The last column shows the items currently using the slot\n\n";
90 92
91 # first process all applied items and hash them into their slots 93 # first process all applied items and hash them into their slots
92 my @slot; 94 my @slot;
93 95
94 for my $item (grep $_->flag (cf::FLAG_APPLIED), $ob->inv) { 96 for my $item (grep $_->flag (cf::FLAG_APPLIED), $observe->inv) {
95 $item->slot_info ($_) 97 $item->slot_info ($_)
96 and push @{ $slot[$_] }, $item 98 and push @{ $slot[$_] }, $item
97 for 0 .. cf::NUM_BODY_LOCATIONS-1; 99 for 0 .. cf::NUM_BODY_LOCATIONS-1;
98 } 100 }
99 101
101 for (0 .. cf::NUM_BODY_LOCATIONS - 1) { 103 for (0 .. cf::NUM_BODY_LOCATIONS - 1) {
102 my $msg = cf::object::slot_nonuse_name $_; 104 my $msg = cf::object::slot_nonuse_name $_;
103 $msg =~ s/^.*? a //; 105 $msg =~ s/^.*? a //;
104 $reply .= sprintf " %-20s %3d %5d %s\n", 106 $reply .= sprintf " %-20s %3d %5d %s\n",
105 $msg, 107 $msg,
106 $ob->slot_info ($_), 108 $observe->slot_info ($_),
107 $ob->slot_used ($_), 109 $observe->slot_used ($_),
108 join ", ", map $_->query_short_name, @{ $slot[$_] } 110 join ", ", map $_->query_short_name, @{ $slot[$_] }
109 if $ob->slot_info ($_) || $ob->slot_used ($_); 111 if $observe->slot_info ($_) || $observe->slot_used ($_);
110 } 112 }
111 113
112 $reply .= "You are not allowed to wear armor\r" 114 $reply .= "You are not allowed to wear armor\r"
113 unless $ob->flag (cf::FLAG_USE_ARMOUR); 115 unless $observe->flag (cf::FLAG_USE_ARMOUR);
114 $reply .= "You are not allowed to use weapons\r" 116 $reply .= "You are not allowed to use weapons\r"
115 unless $ob->flag (cf::FLAG_USE_WEAPON); 117 unless $observe->flag (cf::FLAG_USE_WEAPON);
116 118
117 $ob->send_msg ("c/body" => $reply, cf::NDI_REPLY); 119 $ob->send_msg ("c/body" => $reply, cf::NDI_REPLY | cf::NDI_CLEAR);
118}; 120};
119 121
120cf::register_command mark => sub { 122#cf::register_command mark => sub {
121 my ($pl, $arg) = @_; 123# my ($pl, $arg) = @_;
122 124#
123 if (length $arg) { 125# if (length $arg) {
124 my $ob = $pl->find_best_object_match ($arg); 126# my $ob = $pl->find_best_object_match ($arg);
125 127#
126 return $pl->reply (undef, "Could not find an object that matches $arg") 128# return $pl->reply (undef, "Could not find an object that matches $arg")
127 unless $ob; 129# unless $ob;
128 130#
129 $pl->contr->mark ($ob); 131# $pl->contr->mark ($ob);
130 $pl->reply (undef, (sprintf "Marked item %s", $ob->name, $ob->title)); 132# $pl->reply (undef, (sprintf "Marked item %s", $ob->name, $ob->title));
131 } else { 133# } else {
132 my $ob = $pl->find_marked_object; 134# my $ob = $pl->mark;
133 135#
134 $pl->reply (undef, $ob 136# $pl->reply (undef, $ob
135 ? (sprintf "%s %s * is marked.", $ob->name, $ob->title) 137# ? (sprintf "%s %s * is marked.", $ob->name, $ob->title)
136 : "You have no marked object."); 138# : "You have no marked object.");
137 } 139# }
138}; 140#};
139
140for my $cmd ("run", "fire") {
141 my $oncmd = "${cmd}_on";
142 cf::register_command $cmd => sub {
143 my ($ob, $arg) = @_;
144
145 $ob->reply (undef, "Can't $cmd into a non adjacent square.")
146 if $arg < 0 or $arg >= 9;
147
148 $ob->contr->$oncmd (1);
149 $ob->move_player ($arg);
150 };
151
152 cf::register_command "${cmd}_stop" => sub {
153 my ($ob) = @_;
154
155 $ob->contr->$oncmd (0);
156 };
157}
158 141
159cf::register_command mapinfo => sub { 142cf::register_command mapinfo => sub {
160 my ($ob) = @_; 143 my ($ob) = @_;
161 144
162 my $observe = $ob->contr->observe; 145 my $observe = $ob->contr->observe;
163 146
164 my $map = $observe->map 147 my $map = $observe->map
165 or return; 148 or return;
166 149
150 my $msg = '';
151
152 if ($map->name ne '') {
153 $msg .= sprintf "%s [%s] ", $map->name, $map->visible_name
154 } else {
155 $msg .= sprintf "%s ", $map->visible_name
156 }
157
158 if ($map->visible_name ne $map->path) {
159 $msg .= sprintf "(%s) ", $map->path;
160 }
161
167 my $msg = sprintf "%s (%s)\r%s", $map->name, $map->path, $observe->region->longname; 162 $msg .= sprintf "\r%s", $observe->region->longname;
168 $msg .= sprintf "\rplayers: %d difficulty: %d size: %d start: %dx%d timeout: %d", 163
169 (scalar $map->players), $map->difficulty, $map->width, $map->height, $map->enter_x, $map->enter_y, $map->timeout 164 $msg .= sprintf "\rplayers: %d difficulty: %d"
165 . "\rsize: %dx%d start: %dx%d position: (%d|%d) timeout: %d",
166 (scalar $map->players),
167 $map->difficulty,
168 $map->width, $map->height,
169 $map->enter_x, $map->enter_y,
170 $ob->x, $ob->y,
171 $map->timeout
170 if $ob->flag (cf::FLAG_WIZ); 172 if $ob->flag (cf::FLAG_WIZ);
171 173
172 $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);
173}; 175};
174 176
265 my ($ob, $arg) = @_; 267 my ($ob, $arg) = @_;
266 268
267 return $ob->reply (undef, sprintf "Output rate is presently %dbps.", $ob->contr->ns->max_rate / $cf::TICK) 269 return $ob->reply (undef, sprintf "Output rate is presently %dbps.", $ob->contr->ns->max_rate / $cf::TICK)
268 unless $arg > 0; 270 unless $arg > 0;
269 271
270 # minimum is 5k/s 272 $ob->contr->ns->max_rate ((cf::clamp $arg, $OUTPUT_RATE_MIN, $OUTPUT_RATE_MAX) * $TICK);
271 # maximum is 100k/s, this should be configurable
272 $ob->contr->ns->max_rate ((List::Util::max 5000, List::Util::min 100000, $arg) * $cf::TICK);
273 $ob->reply (undef, sprintf "Output rate now set to %dbps.", $ob->contr->ns->max_rate / $cf::TICK); 273 $ob->reply (undef, sprintf "Output rate now set to %dbps.", $ob->contr->ns->max_rate / $TICK);
274}; 274};
275 275
276cf::register_command 'output-count' => sub { 276cf::register_command 'output-count' => sub {
277 my ($ob, $arg) = @_; 277 my ($ob, $arg) = @_;
278 278
338 338
339 if (length $from) { 339 if (length $from) {
340 $item = $ob->find_best_object_match ($from) 340 $item = $ob->find_best_object_match ($from)
341 or return $ob->message ("rename: could not find a matching item to rename."); 341 or return $ob->message ("rename: could not find a matching item to rename.");
342 } else { 342 } else {
343 $item = $ob->find_marked_object 343 $item = $ob->mark
344 or return $ob->message ("rename: no from name and no marked item found to rename."); 344 or return $ob->message ("rename: no from name and no marked item found to rename.");
345 } 345 }
346 346
347 $item->custom_name (length $to ? $to : undef); 347 $item->custom_name (length $to ? $to : undef);
348 348

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines