--- deliantra/server/ext/commands.ext 2007/03/14 15:44:47 1.35 +++ deliantra/server/ext/commands.ext 2007/05/03 04:50:27 1.42 @@ -40,8 +40,8 @@ sub ext::schmorp_irc::users; # HACK: TODO: replace by signal -sub who_listing(;$) { - my ($privileged) = @_; +sub who_listing(;$$) { + my ($privileged, $select) = @_; my ($numwiz, $numafk) = (0, 0); my @pl; @@ -61,19 +61,19 @@ ( "Total Players in The World. (" . (scalar @pl) . ") -- WIZ($numwiz) AFK($numafk) BOT(0)", - ( - map { - my ($pl, $ob, $ns) = ($_, $_->ob, $_->ns); - - "* " . $ob->name . "/" . $ob->level . " " . (length $pl->own_title ? $pl->own_title : "the " . $pl->title) - . ($pl->peaceful ? " [peaceful]" : " [HOSTILE]") - . ($ns->afk ? " [AFK]" : "") - . ($ob->flag (cf::FLAG_WIZ) ? " [WIZ]" : "") - . " [" . $pl->ns->version . "]" - . " [" . ($pl->peaceful || $privileged ? $ob->map->visible_name : $ob->region->name) . "]" - . (sprintf " [rtt %.3fs]", $pl->ns->rtt * 1e-6) - . ($privileged ? " " . $pl->ns->host : "") - } sort { (lc $a->ob->name) cmp (lc $b->ob->name) } @pl + (grep /$select/, + map { + my ($pl, $ob, $ns) = ($_, $_->ob, $_->ns); + + "* " . $ob->name . "/" . $ob->level . " " . (length $pl->own_title ? $pl->own_title : "the " . $pl->title) + . ($pl->peaceful ? " [peaceful]" : " [HOSTILE]") + . ($ns->afk ? " [AFK]" : "") + . ($ob->flag (cf::FLAG_WIZ) ? " [WIZ]" : "") + . " [" . $pl->ns->version . "]" + . " [" . ($pl->peaceful || $privileged ? $ob->map->visible_name : $ob->region->name) . "]" + . (sprintf " [rtt %.3fs]", $pl->ns->rtt * 1e-6) + . ($privileged ? " " . $pl->ns->host : "") + } sort { (lc $a->ob->name) cmp (lc $b->ob->name) } @pl ), eval { "* IRC: " . join ", ", ext::schmorp_irc::users }, ) @@ -82,13 +82,36 @@ cf::register_command who => sub { my ($ob, $arg) = @_; - $ob->speed_left ($ob->speed_left - 0.25); + $ob->speed_left ($ob->speed_left - 4); - $ob->reply (undef, (join "\n", who_listing $ob->may ("extended_who")), cf::NDI_UNIQUE | cf::NDI_DK_ORANGE); + $ob->reply (undef, (join "\n", who_listing $ob->may ("extended_who"), $arg), cf::NDI_UNIQUE | cf::NDI_DK_ORANGE); 1 }; +cf::register_command seen => sub { + my ($pl, $args) = @_; + + if (my ($login) = $args =~ /(\S+)/) { + if ($login eq $pl->name) { + $pl->message ("Very funny, $login. Ha. Ha.", cf::NDI_UNIQUE); + } elsif (cf::player::find_active $login) { + $pl->message ("$login is right here on this server!", cf::NDI_UNIQUE); + } elsif (cf::player::exists $login + and stat cf::player::path $login) { + my $time = (stat _)[9]; + + $pl->message ("$login was last seen here " + . (POSIX::strftime "%Y-%m-%d %H:%M:%S +0000", gmtime $time) + . " which was " . (int +(time - $time) / 3600) . " hours ago.", cf::NDI_UNIQUE); + } else { + $pl->message ("No player named $login is known to me.", cf::NDI_UNIQUE); + } + } else { + $pl->message ("Usage: seen ", cf::NDI_UNIQUE); + } +}; + cf::register_command body => sub { my ($ob) = @_; @@ -137,16 +160,6 @@ 1 }; -cf::register_command who => sub { - my ($ob, $arg) = @_; - - $ob->speed_left ($ob->speed_left - 0.25); - - $ob->reply (undef, (join "\n", who_listing $ob->may ("extended_who")), cf::NDI_UNIQUE | cf::NDI_DK_ORANGE); - - 1 -}; - for my $cmd ("run", "fire") { my $oncmd = "${cmd}_on"; cf::register_command $cmd => sub { @@ -265,8 +278,9 @@ return $ob->reply (undef, sprintf "Output rate is presently %dbps.", $ob->contr->ns->max_rate / $cf::TICK) unless $arg > 0; - $ob->contr->ns->max_rate ($arg * $cf::TICK); - $ob->reply (undef, sprintf "Output rate now set to%dbps.", $ob->contr->ns->max_rate / $cf::TICK); + # minimum is 2k/s + $ob->contr->ns->max_rate ((List::Util::max 2048, $arg) * $cf::TICK); + $ob->reply (undef, sprintf "Output rate now set to %dbps.", $ob->contr->ns->max_rate / $cf::TICK); 1 }; @@ -277,6 +291,8 @@ return $ob->reply (undef, "Output count is presently " . $ob->contr->outputs_count) unless $arg > 0; + $arg = 4 if $arg < 4; + $ob->contr->outputs_count ($arg); $ob->reply (undef, "Output count now set to " . $ob->contr->outputs_count); @@ -286,11 +302,13 @@ cf::register_command 'output-sync' => sub { my ($ob, $arg) = @_; - return $ob->reply (undef, "Output sync time is presently " . $ob->contr->outputs_sync) - unless $arg > 0; + return $ob->reply (undef, sprintf "Output sync time is presently %.1fs", $ob->contr->outputs_sync * $cf::TICK) + unless length $arg; + + $arg = 0.5 if $arg < 0.5; - $ob->contr->outputs_sync ($arg); - $ob->reply (undef, "Output sync time now set to " . $ob->contr->outputs_sync); + $ob->contr->outputs_sync ($arg / $cf::TICK); + $ob->reply (undef, sprintf "Output sync time now set to %.1fs", $ob->contr->outputs_sync * $cf::TICK); 1 };