… | |
… | |
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); |
… | |
… | |
117 | unless $observe->flag (cf::FLAG_USE_WEAPON); |
117 | unless $observe->flag (cf::FLAG_USE_WEAPON); |
118 | |
118 | |
119 | $ob->send_msg ("c/body" => $reply, cf::NDI_REPLY | cf::NDI_CLEAR); |
119 | $ob->send_msg ("c/body" => $reply, cf::NDI_REPLY | cf::NDI_CLEAR); |
120 | }; |
120 | }; |
121 | |
121 | |
122 | cf::register_command mark => sub { |
122 | #cf::register_command mark => sub { |
123 | my ($pl, $arg) = @_; |
123 | # my ($pl, $arg) = @_; |
124 | |
124 | # |
125 | if (length $arg) { |
125 | # if (length $arg) { |
126 | my $ob = $pl->find_best_object_match ($arg); |
126 | # my $ob = $pl->find_best_object_match ($arg); |
127 | |
127 | # |
128 | 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") |
129 | unless $ob; |
129 | # unless $ob; |
130 | |
130 | # |
131 | $pl->contr->mark ($ob); |
131 | # $pl->contr->mark ($ob); |
132 | $pl->reply (undef, (sprintf "Marked item %s", $ob->name, $ob->title)); |
132 | # $pl->reply (undef, (sprintf "Marked item %s", $ob->name, $ob->title)); |
133 | } else { |
133 | # } else { |
134 | my $ob = $pl->find_marked_object; |
134 | # my $ob = $pl->mark; |
135 | |
135 | # |
136 | $pl->reply (undef, $ob |
136 | # $pl->reply (undef, $ob |
137 | ? (sprintf "%s %s * is marked.", $ob->name, $ob->title) |
137 | # ? (sprintf "%s %s * is marked.", $ob->name, $ob->title) |
138 | : "You have no marked object."); |
138 | # : "You have no marked object."); |
139 | } |
139 | # } |
140 | }; |
140 | #}; |
141 | |
|
|
142 | for my $cmd ("run", "fire") { |
|
|
143 | my $oncmd = "${cmd}_on"; |
|
|
144 | cf::register_command $cmd => sub { |
|
|
145 | my ($ob, $arg) = @_; |
|
|
146 | |
|
|
147 | $ob->reply (undef, "Can't $cmd into a non adjacent square.") |
|
|
148 | if $arg < 0 or $arg >= 9; |
|
|
149 | |
|
|
150 | $ob->contr->$oncmd (1); |
|
|
151 | $ob->move_player ($arg); |
|
|
152 | }; |
|
|
153 | |
|
|
154 | cf::register_command "${cmd}_stop" => sub { |
|
|
155 | my ($ob) = @_; |
|
|
156 | |
|
|
157 | $ob->contr->$oncmd (0); |
|
|
158 | }; |
|
|
159 | } |
|
|
160 | |
141 | |
161 | cf::register_command mapinfo => sub { |
142 | cf::register_command mapinfo => sub { |
162 | my ($ob) = @_; |
143 | my ($ob) = @_; |
163 | |
144 | |
164 | my $observe = $ob->contr->observe; |
145 | my $observe = $ob->contr->observe; |
165 | |
146 | |
166 | my $map = $observe->map |
147 | my $map = $observe->map |
167 | or return; |
148 | or return; |
168 | |
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 | |
169 | my $msg = sprintf "%s (%s)\r%s", $map->name, $map->path, $observe->region->longname; |
162 | $msg .= sprintf "\r%s", $observe->region->longname; |
170 | $msg .= sprintf "\rplayers: %d difficulty: %d size: %d start: %dx%d timeout: %d", |
163 | |
171 | (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 |
172 | if $ob->flag (cf::FLAG_WIZ); |
172 | if $ob->flag (cf::FLAG_WIZ); |
173 | |
173 | |
174 | $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); |
175 | }; |
175 | }; |
176 | |
176 | |
… | |
… | |
243 | }; |
243 | }; |
244 | |
244 | |
245 | cf::register_command afk => sub { |
245 | cf::register_command afk => sub { |
246 | my ($ob, $arg) = @_; |
246 | my ($ob, $arg) = @_; |
247 | |
247 | |
248 | $ob->contr->ns->afk ($ob->contr->ns->afk ? 0 : 1); |
248 | $ob->contr->ns->afk (!(length $arg ? !$arg : $ob->contr->ns->afk)); |
249 | $ob->reply (undef, $ob->contr->ns->afk ? "You are now AFK" : "You are no longer AFK"); |
249 | $ob->reply (undef, $ob->contr->ns->afk ? "You are now AFK." : "You are no longer AFK."); |
|
|
250 | }; |
|
|
251 | |
|
|
252 | cf::register_command bumpmsg => sub { |
|
|
253 | my ($ob, $arg) = @_; |
|
|
254 | |
|
|
255 | $ob->contr->ns->bumpmsg (!(length $arg ? !$arg : $ob->contr->ns->bumpmsg)); |
|
|
256 | $ob->reply (undef, $ob->contr->ns->bumpmsg ? "Bumping into walls sounds more painful now." : "Bumping into walls will now be silent."); |
|
|
257 | }; |
|
|
258 | |
|
|
259 | cf::register_command brace => sub { |
|
|
260 | my ($ob, $arg) = @_; |
|
|
261 | |
|
|
262 | $ob->contr->braced (!(length $arg ? !$arg : $ob->contr->ns->braced)); |
|
|
263 | $ob->reply (undef, $ob->contr->braced ? "You are braced." : "Not braced."); |
250 | }; |
264 | }; |
251 | |
265 | |
252 | cf::register_command sound => sub { |
266 | cf::register_command sound => sub { |
253 | my ($ob, $arg) = @_; |
267 | my ($ob, $arg) = @_; |
254 | |
268 | |
255 | $ob->contr->ns->sound ($ob->contr->ns->sound ? 0 : 1); |
269 | $ob->contr->ns->sound (!(length $arg ? !$arg : $ob->contr->ns->sound)); |
256 | $ob->reply (undef, $ob->contr->ns->sound ? "The sounds are enabled." : "Silence is golden..."); |
270 | $ob->reply (undef, $ob->contr->ns->sound ? "The sounds are enabled." : "Silence is golden..."); |
257 | }; |
|
|
258 | |
|
|
259 | cf::register_command brace => sub { |
|
|
260 | my ($ob, $arg) = @_; |
|
|
261 | |
|
|
262 | $ob->contr->braced ($ob->contr->braced ? 0 : 1); |
|
|
263 | $ob->reply (undef, $ob->contr->braced ? "You are braced." : "Not braced."); |
|
|
264 | }; |
271 | }; |
265 | |
272 | |
266 | cf::register_command 'output-rate' => sub { |
273 | cf::register_command 'output-rate' => sub { |
267 | my ($ob, $arg) = @_; |
274 | my ($ob, $arg) = @_; |
268 | |
275 | |
269 | return $ob->reply (undef, sprintf "Output rate is presently %dbps.", $ob->contr->ns->max_rate / $cf::TICK) |
276 | return $ob->reply (undef, sprintf "Output rate is presently %dbps.", $ob->contr->ns->max_rate / $cf::TICK) |
270 | unless $arg > 0; |
277 | unless $arg > 0; |
271 | |
278 | |
272 | # minimum is 5k/s |
279 | $ob->contr->ns->max_rate ((cf::clamp $arg, $OUTPUT_RATE_MIN, $OUTPUT_RATE_MAX) * $TICK); |
273 | # maximum is 100k/s, this should be configurable |
|
|
274 | $ob->contr->ns->max_rate ((List::Util::max 5000, List::Util::min 100000, $arg) * $cf::TICK); |
|
|
275 | $ob->reply (undef, sprintf "Output rate now set to %dbps.", $ob->contr->ns->max_rate / $cf::TICK); |
280 | $ob->reply (undef, sprintf "Output rate now set to %dbps.", $ob->contr->ns->max_rate / $TICK); |
276 | }; |
281 | }; |
277 | |
282 | |
278 | cf::register_command 'output-count' => sub { |
283 | cf::register_command 'output-count' => sub { |
279 | my ($ob, $arg) = @_; |
284 | my ($ob, $arg) = @_; |
280 | |
285 | |
… | |
… | |
340 | |
345 | |
341 | if (length $from) { |
346 | if (length $from) { |
342 | $item = $ob->find_best_object_match ($from) |
347 | $item = $ob->find_best_object_match ($from) |
343 | or return $ob->message ("rename: could not find a matching item to rename."); |
348 | or return $ob->message ("rename: could not find a matching item to rename."); |
344 | } else { |
349 | } else { |
345 | $item = $ob->find_marked_object |
350 | $item = $ob->mark |
346 | or return $ob->message ("rename: no from name and no marked item found to rename."); |
351 | or return $ob->message ("rename: no from name and no marked item found to rename."); |
347 | } |
352 | } |
348 | |
353 | |
349 | $item->custom_name (length $to ? $to : undef); |
354 | $item->custom_name (length $to ? $to : undef); |
350 | |
355 | |
… | |
… | |
392 | my $runtime = sprintf "%.1f", (time - $cf::UPTIME) / 86400; |
397 | my $runtime = sprintf "%.1f", (time - $cf::UPTIME) / 86400; |
393 | $ob->send_msg ("c/uptime" => "server started $startup, uptime ${runtime}\d", cf::NDI_REPLY | cf::NDI_CLEAR); |
398 | $ob->send_msg ("c/uptime" => "server started $startup, uptime ${runtime}\d", cf::NDI_REPLY | cf::NDI_CLEAR); |
394 | }; |
399 | }; |
395 | |
400 | |
396 | my %IN_MEMORY = ( |
401 | my %IN_MEMORY = ( |
|
|
402 | cf::MAP_ACTIVE => "A", |
397 | cf::MAP_ACTIVE => "I", |
403 | cf::MAP_INACTIVE => "I", |
398 | cf::MAP_SWAPPED => "S", |
404 | cf::MAP_SWAPPED => "S", |
399 | cf::MAP_LOADING => "L", |
|
|
400 | ); |
405 | ); |
401 | |
406 | |
402 | cf::register_command maps => sub { |
407 | cf::register_command maps => sub { |
403 | my ($ob, $arg) = @_; |
408 | my ($ob, $arg) = @_; |
404 | |
409 | |
405 | no re 'eval'; $arg = qr<$arg>; |
410 | no re 'eval'; $arg = qr<$arg>; |
406 | |
411 | |
407 | my $format = " %2s %1s %3s %5s %.60s\n"; |
412 | my $format = " %2s %1s %3s %5s %.60s\n"; |
408 | |
413 | |
409 | my $msg = "\n" . sprintf $format, "Pl", "I", "Svd", "Reset", "Name"; |
414 | my $msg = "\n" . sprintf $format, "Pl", "S", "Svd", "Reset", "Name"; |
410 | |
415 | |
411 | for (sort keys %cf::MAP) { |
416 | for (sort keys %cf::MAP) { |
412 | my $map = $cf::MAP{$_} |
417 | my $map = $cf::MAP{$_} |
413 | or next; |
418 | or next; |
414 | |
419 | |