--- deliantra/server/ext/commands.ext 2007/01/01 16:00:09 1.7 +++ deliantra/server/ext/commands.ext 2007/03/02 10:15:38 1.20 @@ -7,7 +7,7 @@ sub rename_to($$$) { my ($ob, $from, $to) = @_; - $to =~ /^[a-zA-Z0-9.,=#\/%$!^]*$/ + $to =~ /^[a-zA-Z0-9.,=#\/%$!^ ]*$/ or return $ob->message ("rename: name must consist only of letters, digits, spaces and a few other things."); 127 >= length $to @@ -70,7 +70,7 @@ . ($ns->afk ? " [AFK]" : "") . ($ob->flag (cf::FLAG_WIZ) ? " [WIZ]" : "") . " [" . $pl->ns->version . "]" - . " [" . ($pl->peaceful || $privileged ? $ob->map->{path}->visible_name : $ob->map->region ? $ob->map->region->name : "the unknown") . "]" + . " [" . ($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 @@ -89,6 +89,49 @@ 1 }; +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"); +}; + +cf::register_command brace => sub { + my ($ob, $arg) = @_; + + $ob->contr->braced ($ob->contr->braced ? 0 : 1); + $ob->reply (undef, $ob->contr->braced ? "You are braced." : "Not braced."); +}; + +# XXX: This has a bug. After one sets his wimpy level to 0 and resets it to +# some other level (which may also be 0), this does not get echoed, +# but it does get set. +cf::register_command wimpy => sub { + my ($ob, $arg) = @_; + + my $wimpy = $ob->run_away; + return $ob->reply (undef, "Your current wimpy level is $wimpy.") + if $arg eq ""; + + return $ob->run_away ($arg) && $ob->reply (undef, "Your new wimpy level is $arg.") + if $arg =~ /^\d+$/ and $arg <= 100; + + $ob->reply (undef, "Incorrect parameters for wimpy: $arg"); +}; + +cf::register_command peaceful => sub { + my ($ob, $arg) = @_; + + $ob->reply (undef, "You cannot change your peaceful setting with this command." + ." Please speak to the priest in the temple of Gorokh" + ." if you want to become hostile or in temple of Valriel" + ." if you want to become peaceful again."); + + #$ob->contr->peaceful ($ob->contr->peaceful ? 0 : 1); + #$ob->reply (undef, $ob->contr->peaceful ? "You will attack other players." : "You will not attack other players."); +}; + + cf::register_command rename => sub { my ($ob, $arg) = @_; @@ -125,29 +168,40 @@ 1 }; +my %IN_MEMORY = ( + cf::MAP_IN_MEMORY => "I", + cf::MAP_SWAPPED => "S", + cf::MAP_LOADING => "L", +); + cf::register_command maps => sub { my ($ob, $arg) = @_; no re 'eval'; $arg = qr<$arg>; - my $format = "%2s %2s %5s %-30.30s\n"; + my $format = "%2s %1s %3s %5s %.60s\n"; - my $msg = sprintf $format, "Pl", "Fl", "Reset", "Name"; + $ob->reply (undef, (sprintf $format, "Pl", "I", "Svd", "Reset", "Name"), cf::NDI_BLACK | cf::NDI_UNIQUE); for (sort keys %cf::MAP) { my $map = $cf::MAP{$_} or next; next unless $map->path =~ $arg; + next if $map->{deny_list}; - $msg .= sprintf $format, - (scalar $map->players), - 0, - (int $map->reset_at - $cf::RUNTIME), - $map->{path}->visible_name; - } + my $svd = int $cf::RUNTIME - $map->{last_save}; + $svd = "++" if $svd > 99; - $ob->reply (undef, $msg); + $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); + } 1 };