--- deliantra/server/ext/commands.ext 2006/12/31 17:17:22 1.6 +++ deliantra/server/ext/commands.ext 2007/01/01 17:50:26 1.10 @@ -125,3 +125,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 %1s %3s %5s %-60.60s\n"; + + my $msg = sprintf $format, "Pl", "I", "Svd", "Reset", "Name"; + + for (sort keys %cf::MAP) { + my $map = $cf::MAP{$_} + or next; + + next unless $map->path =~ $arg; + + my $svd = int $cf::RUNTIME - $map->{last_save}; + $svd = "++" if $svd > 99; + + $msg .= sprintf $format, + (scalar $map->players), + $IN_MEMORY{$map->in_memory} || "?", + $svd, + (int $map->reset_at - $cf::RUNTIME), + $map->{path}->visible_name; + } + + $ob->reply (undef, $msg); + + 1 +}; +