… | |
… | |
5 | # miscellaneous commands |
5 | # miscellaneous commands |
6 | |
6 | |
7 | sub rename_to($$$) { |
7 | sub 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 | |
… | |
… | |
68 | "* " . $ob->name . "/" . $ob->level . " " . (length $pl->own_title ? $pl->own_title : "the " . $pl->title) |
68 | "* " . $ob->name . "/" . $ob->level . " " . (length $pl->own_title ? $pl->own_title : "the " . $pl->title) |
69 | . ($pl->peaceful ? " [peaceful]" : " [HOSTILE]") |
69 | . ($pl->peaceful ? " [peaceful]" : " [HOSTILE]") |
70 | . ($ns->afk ? " [AFK]" : "") |
70 | . ($ns->afk ? " [AFK]" : "") |
71 | . ($ob->flag (cf::FLAG_WIZ) ? " [WIZ]" : "") |
71 | . ($ob->flag (cf::FLAG_WIZ) ? " [WIZ]" : "") |
72 | . " [" . $pl->ns->version . "]" |
72 | . " [" . $pl->ns->version . "]" |
73 | . " [" . ($pl->peaceful || $privileged ? $ob->map->path : $ob->map->region ? $ob->map->region->name : "the unknown") . "]" |
73 | . " [" . ($pl->peaceful || $privileged ? $ob->map->{path}->visible_name : $ob->map->region ? $ob->map->region->name : "the unknown") . "]" |
74 | . (sprintf " [rtt %.3fs]", $pl->ns->rtt * 1e-6) |
74 | . (sprintf " [rtt %.3fs]", $pl->ns->rtt * 1e-6) |
75 | . ($privileged ? " " . $pl->ns->host : "") |
75 | . ($privileged ? " " . $pl->ns->host : "") |
76 | } sort { (lc $a->ob->name) cmp (lc $b->ob->name) } @pl |
76 | } sort { (lc $a->ob->name) cmp (lc $b->ob->name) } @pl |
77 | ), |
77 | ), |
78 | eval { "* IRC: " . join ", ", ext::schmorp_irc::users }, |
78 | eval { "* IRC: " . join ", ", ext::schmorp_irc::users }, |
… | |
… | |
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 | |
|
|
128 | my %IN_MEMORY = ( |
|
|
129 | cf::MAP_IN_MEMORY => "I", |
|
|
130 | cf::MAP_SWAPPED => "S", |
|
|
131 | cf::MAP_LOADING => "L", |
|
|
132 | ); |
|
|
133 | |
|
|
134 | cf::register_command maps => sub { |
|
|
135 | my ($ob, $arg) = @_; |
|
|
136 | |
|
|
137 | no re 'eval'; $arg = qr<$arg>; |
|
|
138 | |
|
|
139 | my $format = "%2s %1s %3s %5s %.60s\n"; |
|
|
140 | |
|
|
141 | $ob->reply (undef, (sprintf $format, "Pl", "I", "Svd", "Reset", "Name"), cf::NDI_BLACK | cf::NDI_UNIQUE); |
|
|
142 | |
|
|
143 | for (sort keys %cf::MAP) { |
|
|
144 | my $map = $cf::MAP{$_} |
|
|
145 | or next; |
|
|
146 | |
|
|
147 | next unless $map->path =~ $arg; |
|
|
148 | next if $map->{path}->is_style_map; |
|
|
149 | |
|
|
150 | my $svd = int $cf::RUNTIME - $map->{last_save}; |
|
|
151 | $svd = "++" if $svd > 99; |
|
|
152 | |
|
|
153 | $ob->reply (undef, |
|
|
154 | (sprintf $format, |
|
|
155 | (scalar $map->players), |
|
|
156 | $IN_MEMORY{$map->in_memory} || "?", |
|
|
157 | $svd, |
|
|
158 | (int $map->reset_at - $cf::RUNTIME), |
|
|
159 | $map->{path}->visible_name), |
|
|
160 | cf::NDI_BLACK | cf::NDI_UNIQUE); |
|
|
161 | } |
|
|
162 | |
|
|
163 | 1 |
|
|
164 | }; |
|
|
165 | |