--- deliantra/server/ext/commands.ext 2010/04/08 17:36:53 1.75 +++ deliantra/server/ext/commands.ext 2011/05/04 07:41:13 1.82 @@ -62,7 +62,7 @@ } elsif (cf::player::find_active $login) { $pl->message ("$login is right here on this server!", cf::NDI_REPLY); } elsif (cf::player::exists $login - and stat cf::player::path $login) { + and !Coro::AIO::aio_stat cf::player::path $login) { my $time = (stat _)[9]; $pl->message ("$login was last seen here " @@ -131,7 +131,7 @@ # $pl->contr->mark ($ob); # $pl->reply (undef, (sprintf "Marked item %s", $ob->name, $ob->title)); # } else { -# my $ob = $pl->find_marked_object; +# my $ob = $pl->mark; # # $pl->reply (undef, $ob # ? (sprintf "%s %s * is marked.", $ob->name, $ob->title) @@ -147,9 +147,28 @@ my $map = $observe->map or return; - my $msg = sprintf "%s (%s)\r%s", $map->name, $map->path, $observe->region->longname; - $msg .= sprintf "\rplayers: %d difficulty: %d size: %d start: %dx%d timeout: %d", - (scalar $map->players), $map->difficulty, $map->width, $map->height, $map->enter_x, $map->enter_y, $map->timeout + my $msg = ''; + + if ($map->name ne '') { + $msg .= sprintf "%s [%s] ", $map->name, $map->visible_name + } else { + $msg .= sprintf "%s ", $map->visible_name + } + + if ($map->visible_name ne $map->path) { + $msg .= sprintf "(%s) ", $map->path; + } + + $msg .= sprintf "\r%s", $observe->region->longname; + + $msg .= sprintf "\rplayers: %d difficulty: %d" + . "\rsize: %dx%d start: %dx%d position: (%d|%d) timeout: %d", + (scalar $map->players), + $map->difficulty, + $map->width, $map->height, + $map->enter_x, $map->enter_y, + $ob->x, $ob->y, + $map->timeout if $ob->flag (cf::FLAG_WIZ); $ob->send_msg ("c/mapinfo" => $msg, cf::NDI_REPLY | cf::NDI_CLEAR); @@ -226,34 +245,39 @@ cf::register_command afk => sub { my ($ob, $arg) = @_; - $ob->contr->ns->afk ($ob->contr->ns->afk ? 0 : 1); - $ob->reply (undef, $ob->contr->ns->afk ? "You are now AFK" : "You are no longer AFK"); + $ob->contr->ns->afk (!(length $arg ? !$arg : $ob->contr->ns->afk)); + $ob->reply (undef, $ob->contr->ns->afk ? "You are now AFK." : "You are no longer AFK."); }; -cf::register_command sound => sub { +cf::register_command bumpmsg => sub { my ($ob, $arg) = @_; - $ob->contr->ns->sound ($ob->contr->ns->sound ? 0 : 1); - $ob->reply (undef, $ob->contr->ns->sound ? "The sounds are enabled." : "Silence is golden..."); + $ob->contr->ns->bumpmsg (!(length $arg ? !$arg : $ob->contr->ns->bumpmsg)); + $ob->reply (undef, $ob->contr->ns->bumpmsg ? "Bumping into walls sounds more painful now." : "Bumping into walls will now be silent."); }; cf::register_command brace => sub { my ($ob, $arg) = @_; - $ob->contr->braced ($ob->contr->braced ? 0 : 1); + $ob->contr->braced (!(length $arg ? !$arg : $ob->contr->ns->braced)); $ob->reply (undef, $ob->contr->braced ? "You are braced." : "Not braced."); }; +cf::register_command sound => sub { + my ($ob, $arg) = @_; + + $ob->contr->ns->sound (!(length $arg ? !$arg : $ob->contr->ns->sound)); + $ob->reply (undef, $ob->contr->ns->sound ? "The sounds are enabled." : "Silence is golden..."); +}; + cf::register_command 'output-rate' => sub { my ($ob, $arg) = @_; return $ob->reply (undef, sprintf "Output rate is presently %dbps.", $ob->contr->ns->max_rate / $cf::TICK) unless $arg > 0; - # minimum is 5k/s - # maximum is 100k/s, this should be configurable - $ob->contr->ns->max_rate ((List::Util::max 5000, List::Util::min 100000, $arg) * $cf::TICK); - $ob->reply (undef, sprintf "Output rate now set to %dbps.", $ob->contr->ns->max_rate / $cf::TICK); + $ob->contr->ns->max_rate ((cf::clamp $arg, $OUTPUT_RATE_MIN, $OUTPUT_RATE_MAX) * $TICK); + $ob->reply (undef, sprintf "Output rate now set to %dbps.", $ob->contr->ns->max_rate / $TICK); }; cf::register_command 'output-count' => sub { @@ -323,7 +347,7 @@ $item = $ob->find_best_object_match ($from) or return $ob->message ("rename: could not find a matching item to rename."); } else { - $item = $ob->find_marked_object + $item = $ob->mark or return $ob->message ("rename: no from name and no marked item found to rename."); } @@ -374,10 +398,10 @@ $ob->send_msg ("c/uptime" => "server started $startup, uptime ${runtime}\d", cf::NDI_REPLY | cf::NDI_CLEAR); }; -my %IN_MEMORY = ( - cf::MAP_ACTIVE => "I", - cf::MAP_SWAPPED => "S", - cf::MAP_LOADING => "L", +my %MAP_STATE = ( + cf::MAP_ACTIVE => "A", + cf::MAP_INACTIVE => "I", + cf::MAP_SWAPPED => "S", ); cf::register_command maps => sub { @@ -387,7 +411,7 @@ my $format = " %2s %1s %3s %5s %.60s\n"; - my $msg = "\n" . sprintf $format, "Pl", "I", "Svd", "Reset", "Name"; + my $msg = "\n" . sprintf $format, "Pl", "S", "Svd", "Reset", "Name"; for (sort keys %cf::MAP) { my $map = $cf::MAP{$_} @@ -401,7 +425,7 @@ $msg .= sprintf $format, (scalar $map->players), - $IN_MEMORY{$map->in_memory} || "?", + $MAP_STATE{$map->state} || "?", $svd, (int $map->reset_at - $cf::RUNTIME), $map->visible_name;