ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/ext/commands.ext
(Generate patch)

Comparing deliantra/server/ext/commands.ext (file contents):
Revision 1.7 by root, Mon Jan 1 16:00:09 2007 UTC vs.
Revision 1.15 by root, Thu Jan 11 00:16:58 2007 UTC

5# miscellaneous commands 5# miscellaneous commands
6 6
7sub rename_to($$$) { 7sub rename_to($$$) {
8 my ($ob, $from, $to) = @_; 8 my ($ob, $from, $to) = @_;
9 9
10 $to =~ /^[a-zA-Z0-9.,=#\/%$!^]*$/ 10 $to =~ /^[a-zA-Z0-9.,=#\/%$!^ ]*$/
11 or return $ob->message ("rename: name must consist only of letters, digits, spaces and a few other things."); 11 or return $ob->message ("rename: name must consist only of letters, digits, spaces and a few other things.");
12 12
13 127 >= length $to 13 127 >= length $to
14 or return $ob->message ("rename: new name must be <= 127 characters."); 14 or return $ob->message ("rename: new name must be <= 127 characters.");
15 15
123 $ob->reply (undef, "server started $startup, uptime ${runtime}\d"); 123 $ob->reply (undef, "server started $startup, uptime ${runtime}\d");
124 124
125 1 125 1
126}; 126};
127 127
128my %IN_MEMORY = (
129 cf::MAP_IN_MEMORY => "I",
130 cf::MAP_SWAPPED => "S",
131 cf::MAP_LOADING => "L",
132);
133
128cf::register_command maps => sub { 134cf::register_command maps => sub {
129 my ($ob, $arg) = @_; 135 my ($ob, $arg) = @_;
130 136
131 no re 'eval'; $arg = qr<$arg>; 137 no re 'eval'; $arg = qr<$arg>;
132 138
133 my $format = "%2s %2s %5s %-30.30s\n"; 139 my $format = "%2s %1s %3s %5s %.60s\n";
134 140
135 my $msg = sprintf $format, "Pl", "Fl", "Reset", "Name"; 141 $ob->reply (undef, (sprintf $format, "Pl", "I", "Svd", "Reset", "Name"), cf::NDI_BLACK | cf::NDI_UNIQUE);
136 142
137 for (sort keys %cf::MAP) { 143 for (sort keys %cf::MAP) {
138 my $map = $cf::MAP{$_} 144 my $map = $cf::MAP{$_}
139 or next; 145 or next;
140 146
141 next unless $map->path =~ $arg; 147 next unless $map->path =~ $arg;
142 148
143 $msg .= sprintf $format, 149 my $svd = int $cf::RUNTIME - $map->{last_save};
150 $svd = "++" if $svd > 99;
151
152 $ob->reply (undef,
153 (sprintf $format,
144 (scalar $map->players), 154 (scalar $map->players),
145 0, 155 $IN_MEMORY{$map->in_memory} || "?",
156 $svd,
146 (int $map->reset_at - $cf::RUNTIME), 157 (int $map->reset_at - $cf::RUNTIME),
147 $map->{path}->visible_name; 158 $map->{path}->visible_name),
159 cf::NDI_BLACK | cf::NDI_UNIQUE);
148 } 160 }
149
150 $ob->reply (undef, $msg);
151 161
152 1 162 1
153}; 163};
154 164

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines