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.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
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}->visible_name : $ob->map->region ? $ob->map->region->name : "the unknown") . "]" 73 . " [" . ($pl->peaceful || $privileged ? $ob->map->visible_name : $ob->region->name) . "]"
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 },
86 86
87 $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);
88 88
89 1 89 1
90}; 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
91 134
92cf::register_command rename => sub { 135cf::register_command rename => sub {
93 my ($ob, $arg) = @_; 136 my ($ob, $arg) = @_;
94 137
95 $ob->speed_left ($ob->speed_left - 0.25); 138 $ob->speed_left ($ob->speed_left - 0.25);
123 $ob->reply (undef, "server started $startup, uptime ${runtime}\d"); 166 $ob->reply (undef, "server started $startup, uptime ${runtime}\d");
124 167
125 1 168 1
126}; 169};
127 170
171my %IN_MEMORY = (
172 cf::MAP_IN_MEMORY => "I",
173 cf::MAP_SWAPPED => "S",
174 cf::MAP_LOADING => "L",
175);
176
128cf::register_command maps => sub { 177cf::register_command maps => sub {
129 my ($ob, $arg) = @_; 178 my ($ob, $arg) = @_;
130 179
131 no re 'eval'; $arg = qr<$arg>; 180 no re 'eval'; $arg = qr<$arg>;
132 181
133 my $format = "%2s %2s %5s %-30.30s\n"; 182 my $format = "%2s %1s %3s %5s %.60s\n";
134 183
135 my $msg = sprintf $format, "Pl", "Fl", "Reset", "Name"; 184 $ob->reply (undef, (sprintf $format, "Pl", "I", "Svd", "Reset", "Name"), cf::NDI_BLACK | cf::NDI_UNIQUE);
136 185
137 for (sort keys %cf::MAP) { 186 for (sort keys %cf::MAP) {
138 my $map = $cf::MAP{$_} 187 my $map = $cf::MAP{$_}
139 or next; 188 or next;
140 189
141 next unless $map->path =~ $arg; 190 next unless $map->path =~ $arg;
191 next if $map->{deny_list};
142 192
143 $msg .= sprintf $format, 193 my $svd = int $cf::RUNTIME - $map->{last_save};
194 $svd = "++" if $svd > 99;
195
196 $ob->reply (undef,
197 (sprintf $format,
144 (scalar $map->players), 198 (scalar $map->players),
145 0, 199 $IN_MEMORY{$map->in_memory} || "?",
200 $svd,
146 (int $map->reset_at - $cf::RUNTIME), 201 (int $map->reset_at - $cf::RUNTIME),
147 $map->{path}->visible_name; 202 $map->visible_name),
148 } 203 cf::NDI_BLACK | cf::NDI_UNIQUE);
149
150 $ob->reply (undef, $msg);
151
152 1 204 }
153};
154 205
206 1
207};
208

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines