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.1 by root, Fri Dec 15 19:29:18 2006 UTC vs.
Revision 1.20 by pippijn, Fri Mar 2 10:15:38 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
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->client . "]" 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/%.3f]", $pl->socket->rtt * 1e-6, $pl->socket->rttvar * 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}
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
89}; 90};
91
92cf::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");
97};
98
99cf::register_command brace => sub {
100 my ($ob, $arg) = @_;
101
102 $ob->contr->braced ($ob->contr->braced ? 0 : 1);
103 $ob->reply (undef, $ob->contr->braced ? "You are braced." : "Not braced.");
104};
105
106# XXX: This has a bug. After one sets his wimpy level to 0 and resets it to
107# some other level (which may also be 0), this does not get echoed,
108# but it does get set.
109cf::register_command wimpy => sub {
110 my ($ob, $arg) = @_;
111
112 my $wimpy = $ob->run_away;
113 return $ob->reply (undef, "Your current wimpy level is $wimpy.")
114 if $arg eq "";
115
116 return $ob->run_away ($arg) && $ob->reply (undef, "Your new wimpy level is $arg.")
117 if $arg =~ /^\d+$/ and $arg <= 100;
118
119 $ob->reply (undef, "Incorrect parameters for wimpy: $arg");
120};
121
122cf::register_command peaceful => sub {
123 my ($ob, $arg) = @_;
124
125 $ob->reply (undef, "You cannot change your peaceful setting with this command."
126 ." Please speak to the priest in the temple of Gorokh"
127 ." if you want to become hostile or in temple of Valriel"
128 ." if you want to become peaceful again.");
129
130 #$ob->contr->peaceful ($ob->contr->peaceful ? 0 : 1);
131 #$ob->reply (undef, $ob->contr->peaceful ? "You will attack other players." : "You will not attack other players.");
132};
133
90 134
91cf::register_command rename => sub { 135cf::register_command rename => sub {
92 my ($ob, $arg) = @_; 136 my ($ob, $arg) = @_;
93 137
94 $ob->speed_left ($ob->speed_left - 0.25); 138 $ob->speed_left ($ob->speed_left - 0.25);
122 $ob->reply (undef, "server started $startup, uptime ${runtime}\d"); 166 $ob->reply (undef, "server started $startup, uptime ${runtime}\d");
123 167
124 1 168 1
125}; 169};
126 170
171my %IN_MEMORY = (
172 cf::MAP_IN_MEMORY => "I",
173 cf::MAP_SWAPPED => "S",
174 cf::MAP_LOADING => "L",
175);
176
177cf::register_command maps => sub {
178 my ($ob, $arg) = @_;
179
180 no re 'eval'; $arg = qr<$arg>;
181
182 my $format = "%2s %1s %3s %5s %.60s\n";
183
184 $ob->reply (undef, (sprintf $format, "Pl", "I", "Svd", "Reset", "Name"), cf::NDI_BLACK | cf::NDI_UNIQUE);
185
186 for (sort keys %cf::MAP) {
187 my $map = $cf::MAP{$_}
188 or next;
189
190 next unless $map->path =~ $arg;
191 next if $map->{deny_list};
192
193 my $svd = int $cf::RUNTIME - $map->{last_save};
194 $svd = "++" if $svd > 99;
195
196 $ob->reply (undef,
197 (sprintf $format,
198 (scalar $map->players),
199 $IN_MEMORY{$map->in_memory} || "?",
200 $svd,
201 (int $map->reset_at - $cf::RUNTIME),
202 $map->visible_name),
203 cf::NDI_BLACK | cf::NDI_UNIQUE);
204 }
205
206 1
207};
208

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines