--- deliantra/server/ext/commands.ext 2008/09/08 18:34:35 1.68 +++ deliantra/server/ext/commands.ext 2009/01/11 06:08:40 1.72 @@ -55,24 +55,26 @@ 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_REPLY); - } 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) { - 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_REPLY); + cf::async { + if (my ($login) = $args =~ /(\S+)/) { + if ($login eq $pl->name) { + $pl->message ("Very funny, $login. Ha. Ha.", cf::NDI_REPLY); + } 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) { + 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_REPLY); + } else { + $pl->message ("No player named $login is known to me.", cf::NDI_REPLY); + } } else { - $pl->message ("No player named $login is known to me.", cf::NDI_REPLY); + $pl->message ("Usage: seen ", cf::NDI_REPLY); } - } else { - $pl->message ("Usage: seen ", cf::NDI_REPLY); - } + }; }; cf::register_command body => sub { @@ -83,14 +85,28 @@ my $reply = "The first column is the name of the body location.\r" . "The second column is how many of those locations your body has.\r" - . "The third column is how many slots in that location are available.\r"; + . "The third column is how many slots in that location are available.\r" + . "The last column shows the items currently using the slot\n\n"; + + # first process all applied items and hash them into their slots + my @slot; + + for my $item (grep $_->flag (cf::FLAG_APPLIED), $ob->inv) { + $item->slot_info ($_) + and push @{ $slot[$_] }, $item + for 0 .. cf::NUM_BODY_LOCATIONS-1; + } - $reply .= sprintf " %-20s %3s %5s\n", "Location", "You", "Avail"; + $reply .= sprintf " %-20s %3s %5s %s\n", "Location", "You", "Avail", "What"; for (0 .. cf::NUM_BODY_LOCATIONS - 1) { my $msg = cf::object::slot_nonuse_name $_; $msg =~ s/^.*? a //; - $reply .= sprintf " %-20s %3d %5d\n", $msg, $ob->slot_info ($_), $ob->slot_used ($_) - if $ob->slot_info ($_) or $ob->slot_used ($_); + $reply .= sprintf " %-20s %3d %5d %s\n", + $msg, + $ob->slot_info ($_), + $ob->slot_used ($_), + join ", ", map $_->query_short_name, @{ $slot[$_] } + if $ob->slot_info ($_) || $ob->slot_used ($_); } $reply .= "You are not allowed to wear armor\r" @@ -148,8 +164,8 @@ my $map = $observe->map or return; - my $msg = sprintf "%s (%s) %s\r", $map->name, $map->path, $observe->region->longname; - $msg .= sprintf "players: %d difficulty: %d size: %d start: %dx%d timeout: %d", + 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 if $ob->flag (cf::FLAG_WIZ); @@ -160,7 +176,7 @@ my ($ob) = @_; my $reg = $ob->contr->observe->region; - $ob->send_msg ("c/who" => (sprintf "You are %s.\n%s", $reg->longname, $reg->msg), cf::NDI_REPLY | cf::NDI_CLEAR); + $ob->send_msg ("c/who" => (sprintf "You are %s.\n\n%s", $reg->longname, $reg->msg), cf::NDI_REPLY | cf::NDI_CLEAR); }; cf::register_command whereabouts => sub { @@ -172,8 +188,8 @@ ++$count{$pl->ob->region->longname}; } - my $msg = "In the world currently there are:\n\n" - . join "", map "$count{$_} player(s) $_\n\n", sort keys %count; + my $msg = "T\n\n" + . join "", map { sprintf " C<%3d >player(s) %s\r", $count{$_}, $_ } sort keys %count; $ob->send_msg ("c/who" => $msg, cf::NDI_REPLY | cf::NDI_CLEAR); };