… | |
… | |
47 | cf::register_command who => sub { |
47 | cf::register_command who => sub { |
48 | my ($ob, $arg) = @_; |
48 | my ($ob, $arg) = @_; |
49 | |
49 | |
50 | $ob->speed_left ($ob->speed_left - 4); |
50 | $ob->speed_left ($ob->speed_left - 4); |
51 | |
51 | |
52 | $ob->reply (undef, (join "\n", who_listing $ob->may ("extended_who"), $arg), cf::NDI_UNIQUE | cf::NDI_DK_ORANGE); |
52 | $ob->send_msg ("c/who" => (join "\n\n", who_listing $ob->may ("extended_who"), $arg), cf::NDI_DK_ORANGE | cf::NDI_REPLY | cf::NDI_CLEAR | cf::NDI_DEF); |
53 | }; |
53 | }; |
54 | |
54 | |
55 | cf::register_command seen => sub { |
55 | cf::register_command seen => sub { |
56 | my ($pl, $args) = @_; |
56 | my ($pl, $args) = @_; |
57 | |
57 | |
58 | if (my ($login) = $args =~ /(\S+)/) { |
58 | if (my ($login) = $args =~ /(\S+)/) { |
59 | if ($login eq $pl->name) { |
59 | if ($login eq $pl->name) { |
60 | $pl->message ("Very funny, $login. Ha. Ha.", cf::NDI_UNIQUE); |
60 | $pl->message ("Very funny, $login. Ha. Ha.", cf::NDI_REPLY); |
61 | } elsif (cf::player::find_active $login) { |
61 | } elsif (cf::player::find_active $login) { |
62 | $pl->message ("$login is right here on this server!", cf::NDI_UNIQUE); |
62 | $pl->message ("$login is right here on this server!", cf::NDI_REPLY); |
63 | } elsif (cf::player::exists $login |
63 | } elsif (cf::player::exists $login |
64 | and stat cf::player::path $login) { |
64 | and stat cf::player::path $login) { |
65 | my $time = (stat _)[9]; |
65 | my $time = (stat _)[9]; |
66 | |
66 | |
67 | $pl->message ("$login was last seen here " |
67 | $pl->message ("$login was last seen here " |
68 | . (POSIX::strftime "%Y-%m-%d %H:%M:%S +0000", gmtime $time) |
68 | . (POSIX::strftime "%Y-%m-%d %H:%M:%S +0000", gmtime $time) |
69 | . " which was " . (int +(time - $time) / 3600) . " hours ago.", cf::NDI_UNIQUE); |
69 | . " which was " . (int +(time - $time) / 3600) . " hours ago.", cf::NDI_REPLY); |
70 | } else { |
70 | } else { |
71 | $pl->message ("No player named $login is known to me.", cf::NDI_UNIQUE); |
71 | $pl->message ("No player named $login is known to me.", cf::NDI_REPLY); |
72 | } |
72 | } |
73 | } else { |
73 | } else { |
74 | $pl->message ("Usage: seen <player>", cf::NDI_UNIQUE); |
74 | $pl->message ("Usage: seen <player>", cf::NDI_REPLY); |
75 | } |
75 | } |
76 | }; |
76 | }; |
77 | |
77 | |
78 | cf::register_command body => sub { |
78 | cf::register_command body => sub { |
79 | my ($ob) = @_; |
79 | my ($ob) = @_; |
… | |
… | |
96 | $reply .= "You are not allowed to wear armor\n\n" |
96 | $reply .= "You are not allowed to wear armor\n\n" |
97 | unless $ob->flag (cf::FLAG_USE_ARMOUR); |
97 | unless $ob->flag (cf::FLAG_USE_ARMOUR); |
98 | $reply .= "You are not allowed to use weapons\n\n" |
98 | $reply .= "You are not allowed to use weapons\n\n" |
99 | unless $ob->flag (cf::FLAG_USE_WEAPON); |
99 | unless $ob->flag (cf::FLAG_USE_WEAPON); |
100 | |
100 | |
101 | $ob->reply (undef, $reply); |
101 | $ob->send_msg ("c/body" => $reply, cf::NDI_REPLY); |
102 | }; |
102 | }; |
103 | |
103 | |
104 | cf::register_command mark => sub { |
104 | cf::register_command mark => sub { |
105 | my ($pl, $arg) = @_; |
105 | my ($pl, $arg) = @_; |
106 | |
106 | |
… | |
… | |
145 | |
145 | |
146 | my $observe = $ob->contr->observe; |
146 | my $observe = $ob->contr->observe; |
147 | |
147 | |
148 | my $map = $observe->map |
148 | my $map = $observe->map |
149 | or return; |
149 | or return; |
|
|
150 | |
150 | $ob->reply (undef, (sprintf "%s (%s) %s", $map->name, $map->path, $observe->region->longname)); |
151 | my $msg = sprintf "%s (%s) %s", $map->name, $map->path, $observe->region->longname; |
151 | $ob->reply (undef, (sprintf "players: %d difficulty: %d size: %d start: %dx%d timeout: %d", |
152 | $msg .= sprintf "\n\nplayers: %d difficulty: %d size: %d start: %dx%d timeout: %d", |
152 | (scalar $map->players), $map->difficulty, $map->width, $map->height, $map->enter_x, $map->enter_y, $map->timeout)) |
153 | (scalar $map->players), $map->difficulty, $map->width, $map->height, $map->enter_x, $map->enter_y, $map->timeout |
153 | if $ob->flag (cf::FLAG_WIZ); |
154 | if $ob->flag (cf::FLAG_WIZ); |
154 | $ob->reply (undef, $map->msg); |
155 | |
|
|
156 | $ob->send_msg ("c/mapinfo" => $msg, cf::NDI_REPLY | cf::NDI_CLEAR); |
155 | }; |
157 | }; |
156 | |
158 | |
157 | cf::register_command whereami => sub { |
159 | cf::register_command whereami => sub { |
158 | my ($ob) = @_; |
160 | my ($ob) = @_; |
159 | |
161 | |
160 | my $reg = $ob->contr->observe->region; |
162 | my $reg = $ob->contr->observe->region; |
161 | $ob->reply (undef, (sprintf "You are %s.\n%s", $reg->longname, $reg->msg)); |
163 | $ob->send_msg ("c/mapinfo" => (sprintf "You are %s.\n%s", $reg->longname, $reg->msg), cf::NDI_REPLY | cf::NDI_CLEAR); |
162 | }; |
164 | }; |
163 | |
165 | |
164 | cf::register_command whereabouts => sub { |
166 | cf::register_command whereabouts => sub { |
165 | my ($ob, $arg) = @_; |
167 | my ($ob, $arg) = @_; |
166 | |
168 | |
… | |
… | |
169 | for my $pl (cf::player::list) { |
171 | for my $pl (cf::player::list) { |
170 | ++$count{$pl->ob->region->longname}; |
172 | ++$count{$pl->ob->region->longname}; |
171 | } |
173 | } |
172 | |
174 | |
173 | my $msg = "In the world currently there are:\n\n" |
175 | my $msg = "In the world currently there are:\n\n" |
174 | . join "", map "$count{$_} player(s) in $_\n\n", sort keys %count; |
176 | . join "", map "$count{$_} player(s) $_\n\n", sort keys %count; |
175 | |
177 | |
176 | $ob->contr->ns->send_msg (log => $msg, cf::NDI_REPLY); |
178 | $ob->send_msg ("c/mapinfo" => $msg, cf::NDI_REPLY | cf::NDI_CLEAR); |
177 | }; |
179 | }; |
178 | |
180 | |
179 | cf::register_command hiscore => sub { |
181 | cf::register_command hiscore => sub { |
180 | my ($ob, $arg) = @_; |
182 | my ($ob, $arg) = @_; |
181 | |
183 | |
182 | my $url = $cf::CFG->{hiscore_url}; |
184 | my $url = $cf::CFG{hiscore_url}; |
183 | $ob->contr->ns->send_msg (log => "See $url", cf::NDI_REPLY); |
185 | $ob->send_msg (log => "See $url", cf::NDI_REPLY); |
184 | }; |
186 | }; |
185 | |
187 | |
186 | sub _set_mode($$$@) { |
188 | sub _set_mode($$$@) { |
187 | my ($name, $ob, $arg, $slot, @choices) = @_; |
189 | my ($name, $ob, $arg, $slot, @choices) = @_; |
188 | |
190 | |
… | |
… | |
368 | cf::register_command uptime => sub { |
370 | cf::register_command uptime => sub { |
369 | my ($ob, $arg) = @_; |
371 | my ($ob, $arg) = @_; |
370 | |
372 | |
371 | my $startup = POSIX::strftime "%Y-%m-%d %H:%M:%S %Z", localtime $cf::UPTIME; |
373 | my $startup = POSIX::strftime "%Y-%m-%d %H:%M:%S %Z", localtime $cf::UPTIME; |
372 | my $runtime = sprintf "%.1f", (time - $cf::UPTIME) / 86400; |
374 | my $runtime = sprintf "%.1f", (time - $cf::UPTIME) / 86400; |
373 | $ob->reply (undef, "server started $startup, uptime ${runtime}\d"); |
375 | $ob->send_msg ("c/uptime" => "server started $startup, uptime ${runtime}\d", cf::NDI_REPLY); |
374 | }; |
376 | }; |
375 | |
377 | |
376 | my %IN_MEMORY = ( |
378 | my %IN_MEMORY = ( |
377 | cf::MAP_IN_MEMORY => "I", |
379 | cf::MAP_IN_MEMORY => "I", |
378 | cf::MAP_SWAPPED => "S", |
380 | cf::MAP_SWAPPED => "S", |
… | |
… | |
384 | |
386 | |
385 | no re 'eval'; $arg = qr<$arg>; |
387 | no re 'eval'; $arg = qr<$arg>; |
386 | |
388 | |
387 | my $format = "%2s %1s %3s %5s %.60s\n"; |
389 | my $format = "%2s %1s %3s %5s %.60s\n"; |
388 | |
390 | |
389 | $ob->reply (undef, (sprintf $format, "Pl", "I", "Svd", "Reset", "Name"), cf::NDI_BLACK | cf::NDI_UNIQUE); |
391 | $ob->send_msg ("c/mapinfo" => (sprintf $format, "Pl", "I", "Svd", "Reset", "Name"), cf::NDI_REPLY | cf::NDI_CLEAR); |
390 | |
392 | |
391 | for (sort keys %cf::MAP) { |
393 | for (sort keys %cf::MAP) { |
392 | my $map = $cf::MAP{$_} |
394 | my $map = $cf::MAP{$_} |
393 | or next; |
395 | or next; |
394 | |
396 | |
… | |
… | |
396 | next if $map->{deny_list}; |
398 | next if $map->{deny_list}; |
397 | |
399 | |
398 | my $svd = int $cf::RUNTIME - $map->{last_save}; |
400 | my $svd = int $cf::RUNTIME - $map->{last_save}; |
399 | $svd = "++" if $svd > 99; |
401 | $svd = "++" if $svd > 99; |
400 | |
402 | |
401 | $ob->reply (undef, |
403 | $ob->send_msg ("c/mapinfo" => |
402 | (sprintf $format, |
404 | (sprintf $format, |
403 | (scalar $map->players), |
405 | (scalar $map->players), |
404 | $IN_MEMORY{$map->in_memory} || "?", |
406 | $IN_MEMORY{$map->in_memory} || "?", |
405 | $svd, |
407 | $svd, |
406 | (int $map->reset_at - $cf::RUNTIME), |
408 | (int $map->reset_at - $cf::RUNTIME), |
407 | $map->visible_name), |
409 | $map->visible_name) |
408 | cf::NDI_BLACK | cf::NDI_UNIQUE); |
410 | ); |
409 | } |
411 | } |
410 | }; |
412 | }; |
411 | |
413 | |