… | |
… | |
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 | |
… | |
… | |
45 | |
45 | |
46 | my ($numwiz, $numafk) = (0, 0); |
46 | my ($numwiz, $numafk) = (0, 0); |
47 | my @pl; |
47 | my @pl; |
48 | |
48 | |
49 | foreach my $pl (cf::player::list) { |
49 | foreach my $pl (cf::player::list) { |
|
|
50 | my $ns = $pl->ns or next; |
50 | my $ob = $pl->ob; |
51 | my $ob = $pl->ob; |
51 | |
52 | |
52 | next unless $ob->map |
53 | next unless $ob->map |
53 | && ($privileged || !$pl->hidden); |
54 | && ($privileged || !$pl->hidden); |
54 | |
55 | |
55 | $numwiz++ if $ob->flag (cf::FLAG_WIZ); |
56 | $numwiz++ if $ob->flag (cf::FLAG_WIZ); |
56 | $numafk++ if $ob->flag (cf::FLAG_AFK); |
57 | $numafk++ if $ns->afk; |
57 | |
58 | |
58 | push @pl, $pl; |
59 | push @pl, $pl; |
59 | } |
60 | } |
60 | |
61 | |
61 | ( |
62 | ( |
62 | "Total Players in The World. (" . (scalar @pl) . ") -- WIZ($numwiz) AFK($numafk) BOT(0)", |
63 | "Total Players in The World. (" . (scalar @pl) . ") -- WIZ($numwiz) AFK($numafk) BOT(0)", |
63 | ( |
64 | ( |
64 | map { |
65 | map { |
65 | my ($pl, $ob) = ($_, $_->ob); |
66 | my ($pl, $ob, $ns) = ($_, $_->ob, $_->ns); |
66 | |
67 | |
67 | "* " . $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) |
68 | . ($pl->peaceful ? " [peaceful]" : " [HOSTILE]") |
69 | . ($pl->peaceful ? " [peaceful]" : " [HOSTILE]") |
69 | . ($ob->flag (cf::FLAG_AFK) ? " [AFK]" : "") |
70 | . ($ns->afk ? " [AFK]" : "") |
70 | . ($ob->flag (cf::FLAG_WIZ) ? " [WIZ]" : "") |
71 | . ($ob->flag (cf::FLAG_WIZ) ? " [WIZ]" : "") |
71 | . " [" . $pl->socket->version . "]" |
72 | . " [" . $pl->ns->version . "]" |
72 | . " [" . ($pl->peaceful || $privileged ? $ob->map->path : $ob->map->region ? $ob->map->region->name : "the unknown") . "]" |
73 | . " [" . ($pl->peaceful || $privileged ? $ob->map->visible_name : $ob->region->name) . "]" |
73 | . (sprintf " [rtt %.3fs]", $pl->socket->rtt * 1e-6) |
74 | . (sprintf " [rtt %.3fs]", $pl->ns->rtt * 1e-6) |
74 | . ($privileged ? " " . $pl->socket->host : "") |
75 | . ($privileged ? " " . $pl->ns->host : "") |
75 | } sort { (lc $a->ob->name) cmp (lc $b->ob->name) } @pl |
76 | } sort { (lc $a->ob->name) cmp (lc $b->ob->name) } @pl |
76 | ), |
77 | ), |
77 | eval { "* IRC: " . join ", ", ext::schmorp_irc::users }, |
78 | eval { "* IRC: " . join ", ", ext::schmorp_irc::users }, |
78 | ) |
79 | ) |
79 | } |
80 | } |
… | |
… | |
84 | $ob->speed_left ($ob->speed_left - 0.25); |
85 | $ob->speed_left ($ob->speed_left - 0.25); |
85 | |
86 | |
86 | $ob->reply (undef, (join "\n", who_listing $ob->may ("extended_who")), cf::NDI_UNIQUE | cf::NDI_DK_ORANGE); |
87 | $ob->reply (undef, (join "\n", who_listing $ob->may ("extended_who")), cf::NDI_UNIQUE | cf::NDI_DK_ORANGE); |
87 | |
88 | |
88 | 1 |
89 | 1 |
|
|
90 | }; |
|
|
91 | |
|
|
92 | cf::register_command afk => sub { |
|
|
93 | my ($ob, $arg) = @_; |
|
|
94 | |
|
|
95 | $ob->contr->ns->afk ($ob->contr->ns->afk ? 0 : 1); |
|
|
96 | $ob->reply (undef, $ob->contr->ns->afk ? "You are now AFK" : "You are no longer AFK"); |
89 | }; |
97 | }; |
90 | |
98 | |
91 | cf::register_command rename => sub { |
99 | cf::register_command rename => sub { |
92 | my ($ob, $arg) = @_; |
100 | my ($ob, $arg) = @_; |
93 | |
101 | |
… | |
… | |
122 | $ob->reply (undef, "server started $startup, uptime ${runtime}\d"); |
130 | $ob->reply (undef, "server started $startup, uptime ${runtime}\d"); |
123 | |
131 | |
124 | 1 |
132 | 1 |
125 | }; |
133 | }; |
126 | |
134 | |
|
|
135 | my %IN_MEMORY = ( |
|
|
136 | cf::MAP_IN_MEMORY => "I", |
|
|
137 | cf::MAP_SWAPPED => "S", |
|
|
138 | cf::MAP_LOADING => "L", |
|
|
139 | ); |
|
|
140 | |
|
|
141 | cf::register_command maps => sub { |
|
|
142 | my ($ob, $arg) = @_; |
|
|
143 | |
|
|
144 | no re 'eval'; $arg = qr<$arg>; |
|
|
145 | |
|
|
146 | my $format = "%2s %1s %3s %5s %.60s\n"; |
|
|
147 | |
|
|
148 | $ob->reply (undef, (sprintf $format, "Pl", "I", "Svd", "Reset", "Name"), cf::NDI_BLACK | cf::NDI_UNIQUE); |
|
|
149 | |
|
|
150 | for (sort keys %cf::MAP) { |
|
|
151 | my $map = $cf::MAP{$_} |
|
|
152 | or next; |
|
|
153 | |
|
|
154 | next unless $map->path =~ $arg; |
|
|
155 | next if $map->{deny_list}; |
|
|
156 | |
|
|
157 | my $svd = int $cf::RUNTIME - $map->{last_save}; |
|
|
158 | $svd = "++" if $svd > 99; |
|
|
159 | |
|
|
160 | $ob->reply (undef, |
|
|
161 | (sprintf $format, |
|
|
162 | (scalar $map->players), |
|
|
163 | $IN_MEMORY{$map->in_memory} || "?", |
|
|
164 | $svd, |
|
|
165 | (int $map->reset_at - $cf::RUNTIME), |
|
|
166 | $map->visible_name), |
|
|
167 | cf::NDI_BLACK | cf::NDI_UNIQUE); |
|
|
168 | } |
|
|
169 | |
|
|
170 | 1 |
|
|
171 | }; |
|
|
172 | |