--- deliantra/server/ext/commands.ext 2007/08/10 05:27:38 1.59 +++ deliantra/server/ext/commands.ext 2008/09/22 01:33:09 1.70 @@ -49,7 +49,7 @@ $ob->speed_left ($ob->speed_left - 4); - $ob->contr->ns->send_msg (log => (join "\n\n", who_listing $ob->may ("extended_who"), $arg), cf::NDI_DK_ORANGE); + $ob->send_msg ("c/who" => (join "\r", who_listing $ob->may ("extended_who"), $arg), cf::NDI_DK_ORANGE | cf::NDI_REPLY | cf::NDI_CLEAR | cf::NDI_DEF); }; cf::register_command seen => sub { @@ -57,21 +57,21 @@ if (my ($login) = $args =~ /(\S+)/) { if ($login eq $pl->name) { - $pl->message ("Very funny, $login. Ha. Ha.", cf::NDI_UNIQUE); + $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_UNIQUE); + $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_UNIQUE); + . " which was " . (int +(time - $time) / 3600) . " hours ago.", cf::NDI_REPLY); } else { - $pl->message ("No player named $login is known to me.", cf::NDI_UNIQUE); + $pl->message ("No player named $login is known to me.", cf::NDI_REPLY); } } else { - $pl->message ("Usage: seen ", cf::NDI_UNIQUE); + $pl->message ("Usage: seen ", cf::NDI_REPLY); } }; @@ -81,8 +81,8 @@ # Too hard to try and make a header that lines everything up, so just # give a description. (comment from C++) my $reply = - "The first column is the name of the body location.\n\n" - . "The second column is how many of those locations your body has.\n\n" + "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.\n\n"; $reply .= sprintf " %-20s %3s %5s\n", "Location", "You", "Avail"; @@ -93,12 +93,12 @@ if $ob->slot_info ($_) or $ob->slot_used ($_); } - $reply .= "You are not allowed to wear armor\n\n" + $reply .= "You are not allowed to wear armor\r" unless $ob->flag (cf::FLAG_USE_ARMOUR); - $reply .= "You are not allowed to use weapons\n\n" + $reply .= "You are not allowed to use weapons\r" unless $ob->flag (cf::FLAG_USE_WEAPON); - $ob->reply (undef, $reply); + $ob->send_msg ("c/body" => $reply, cf::NDI_REPLY); }; cf::register_command mark => sub { @@ -147,18 +147,20 @@ my $map = $observe->map or return; - $ob->reply (undef, (sprintf "%s (%s) %s", $map->name, $map->path, $observe->region->longname)); - $ob->reply (undef, (sprintf "players: %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 = 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); - $ob->reply (undef, $map->msg); + + $ob->send_msg ("c/mapinfo" => $msg, cf::NDI_REPLY | cf::NDI_CLEAR); }; cf::register_command whereami => sub { my ($ob) = @_; my $reg = $ob->contr->observe->region; - $ob->reply (undef, (sprintf "You are %s.\n%s", $reg->longname, $reg->msg)); + $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 { @@ -170,17 +172,17 @@ ++$count{$pl->ob->region->longname}; } - my $msg = "In the world currently there are:\n\n" - . join "", map "$count{$_} player(s) in $_\n\n", sort keys %count; + my $msg = "T\n\n" + . join "", map { sprintf " C<%3d >player(s) %s\r", $count{$_}, $_ } sort keys %count; - $ob->contr->ns->send_msg (log => $msg, cf::NDI_REPLY); + $ob->send_msg ("c/who" => $msg, cf::NDI_REPLY | cf::NDI_CLEAR); }; cf::register_command hiscore => sub { my ($ob, $arg) = @_; - my $url = $cf::CFG->{hiscore_url}; - $ob->contr->ns->send_msg (log => "See $url", cf::NDI_REPLY); + my $url = $cf::CFG{hiscore_url}; + $ob->send_msg (log => "See $url", cf::NDI_REPLY); }; sub _set_mode($$$@) { @@ -370,11 +372,11 @@ my $startup = POSIX::strftime "%Y-%m-%d %H:%M:%S %Z", localtime $cf::UPTIME; my $runtime = sprintf "%.1f", (time - $cf::UPTIME) / 86400; - $ob->reply (undef, "server started $startup, uptime ${runtime}\d"); + $ob->send_msg ("c/uptime" => "server started $startup, uptime ${runtime}\d", cf::NDI_REPLY | cf::NDI_CLEAR); }; my %IN_MEMORY = ( - cf::MAP_IN_MEMORY => "I", + cf::MAP_ACTIVE => "I", cf::MAP_SWAPPED => "S", cf::MAP_LOADING => "L", ); @@ -384,9 +386,9 @@ no re 'eval'; $arg = qr<$arg>; - my $format = "%2s %1s %3s %5s %.60s\n"; + my $format = " %2s %1s %3s %5s %.60s\n"; - $ob->reply (undef, (sprintf $format, "Pl", "I", "Svd", "Reset", "Name"), cf::NDI_BLACK | cf::NDI_UNIQUE); + my $msg = "\n" . sprintf $format, "Pl", "I", "Svd", "Reset", "Name"; for (sort keys %cf::MAP) { my $map = $cf::MAP{$_} @@ -398,14 +400,14 @@ my $svd = int $cf::RUNTIME - $map->{last_save}; $svd = "++" if $svd > 99; - $ob->reply (undef, - (sprintf $format, - (scalar $map->players), - $IN_MEMORY{$map->in_memory} || "?", - $svd, - (int $map->reset_at - $cf::RUNTIME), - $map->visible_name), - cf::NDI_BLACK | cf::NDI_UNIQUE); + $msg .= sprintf $format, + (scalar $map->players), + $IN_MEMORY{$map->in_memory} || "?", + $svd, + (int $map->reset_at - $cf::RUNTIME), + $map->visible_name; } + + $ob->send_msg ("c/mapinfo" => $msg, cf::NDI_REPLY | cf::NDI_CLEAR); };