ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/ext/login.ext
(Generate patch)

Comparing deliantra/server/ext/login.ext (file contents):
Revision 1.59 by root, Tue Jul 3 01:04:43 2007 UTC vs.
Revision 1.60 by root, Thu Jul 5 20:52:22 2007 UTC

2 2
3# login handling 3# login handling
4 4
5use Fcntl; 5use Fcntl;
6use Coro::AIO; 6use Coro::AIO;
7use List::Util qw(min max);
8
9our %EXT_SETUP;
10 7
11# paranoia function to overwrite a string-in-place 8# paranoia function to overwrite a string-in-place
12sub nuke_str { 9sub nuke_str {
13 substr $_[0], 0, (length $_[0]), "x" x length $_[0] 10 substr $_[0], 0, (length $_[0]), "x" x length $_[0]
14} 11}
104 system "cd \Q$PLAYERDIR\E " 101 system "cd \Q$PLAYERDIR\E "
105 . "&& mv \Q$user\E ~\Q$Coro::current\E~deleting~ 2>/dev/null " 102 . "&& mv \Q$user\E ~\Q$Coro::current\E~deleting~ 2>/dev/null "
106 . "&& (rm -rf ~\Q$Coro::current\E~deleting~ &)"; 103 . "&& (rm -rf ~\Q$Coro::current\E~deleting~ &)";
107} 104}
108 105
109sub send_capabilities { 106cf::client->attach (on_addme => sub {
110 my ($ns) = @_; 107 my ($ns) = @_;
111 108
112 return unless $ns->extcmd;
113
114 $ns->ext_event (capabilities =>
115 # id, name, flags (1 == 2d), edge length
116 tileset => [[1, "default 64x64 faceset", 1, 64], [0, "default 32x32 faceset", 1, 32]],
117 );
118}
119
120sub setup {
121 my ($ns, $args) = @_;
122
123 # run through the cmds of setup
124 # syntax is setup <cmdname1> <parameter> <cmdname2> <parameter> ...
125 #
126 # we send the status of the cmd back, or a FALSE is the cmd is the server unknown
127 # The client then must sort this out
128
129 my %setup = split / +/, $args;
130 while (my ($k, $v) = each %setup) {
131 if ($k eq "sound") {
132 $ns->sound ($v);
133
134 } elsif ($k eq "exp64") {
135 $setup{$k} = 1;
136
137 } elsif ($k eq "spellmon") {
138 $ns->monitor_spells ($v);
139
140 } elsif ($k eq "darkness") {
141 $ns->darkness ($v);
142
143 } elsif ($k eq "map1cmd") {
144 $ns->mapmode (cf::Map1Cmd) if $v > 0;
145
146 } elsif ($k eq "map1acmd") {
147 $ns->mapmode (cf::Map1aCmd) if $v > 0;
148
149 } elsif ($k eq "map2cmd") {
150 # gcfclient bug, map1acmd is sent too late
151 $ns->mapmode (cf::Map1aCmd);
152 $setup{$k} = "FALSE";
153
154 } elsif ($k eq "newmapcmd") {
155 $ns->newmapcmd ($v);
156
157 } elsif ($k eq "mapinfocmd") {
158 $ns->mapinfocmd ($v);
159
160 } elsif ($k eq "extcmd") {
161 $ns->extcmd ($v > 0);
162 send_capabilities $ns;
163
164 } elsif ($k eq "extmap") {
165 $ns->extmap ($v);
166
167 } elsif ($k eq "facecache") {
168 if (!$v) {
169 $v = 1;
170 $setup{$k} = $v;
171 $ns->send_drawinfo ("(trying to forcefully enable facecaching)", cf::NDI_RED);
172 }
173
174 $ns->facecache ($v);
175
176 } elsif ($k eq "faceset") {
177 $ns->faceset (0);
178 $setup{$k} = 0;
179 # $ns->image2 (1)
180
181 } elsif ($k eq "tileset") {
182 $setup{$k} = $ns->faceset ($v & 1);
183
184 } elsif ($k eq "itemcmd") {
185 # Version of the item protocol command to use. Currently,
186 # only supported versions are 1 and 2. Using a numeric
187 # value will make it very easy to extend this in the future.
188 $ns->itemcmd ($v) if $v >= 1 && $v <= 2;
189
190 $setup{$k} = $ns->itemcmd;
191
192 } elsif ($k eq "mapsize") {
193 my ($x, $y) = split /x/, $v;
194
195 $ns->mapx ($x = max 9, min cf::MAP_CLIENT_X, ($x - 1) | 1);
196 $ns->mapy ($y = max 9, min cf::MAP_CLIENT_Y, ($y - 1) | 1);
197
198 $setup{$k} = "${x}x${y}";
199
200 } elsif ($k eq "extendedMapInfos") {
201 $ns->ext_mapinfos ($v);
202
203 } elsif ($k eq "extendedTextInfos") {
204 $ns->has_readable_type ($v);
205
206 } elsif ($k eq "smoothing") { # cfplus-style smoothing
207 $ns->smoothing ($v);
208
209 } elsif ($k eq "fxix") {
210 $v = 2 if $v > 2;
211 $ns->fxix ($v);
212 $setup{$k} = $v;
213
214 } elsif ($k eq "msg") {
215 $v = 2 if $v > 2;
216 $ns->can_msg ($v >= 2);
217 $setup{$k} = $v;
218
219 } elsif ($k eq "xwidget") {
220 # eXperimental server-side widgets
221 $ns->{can_widget} = 1;
222
223 } elsif ($k eq "excmd") {
224 # we support it
225
226 } else {
227 # other commands:
228 # sexp: no idea, probably for oudated servers
229 # tick: more stupidity, server should send a tick per tick
230
231 $setup{$k} = "FALSE";
232 }
233 }
234
235 $ns->send_packet (join " ", setup => %setup);
236
237 cf::datalog setup =>
238 request => $args,
239 reply => \%setup,
240 client => $ns->version,
241 ;
242}
243
244sub addme {
245 my ($ns) = @_;
246
247 if (!$ns->facecache) 109 if (!$ns->facecache)
248 { 110 {
249 $ns->send_drawinfo (<<EOF, cf::NDI_RED); 111 $ns->send_drawinfo (<<EOF, cf::NDI_RED);
250 112
251 113
252*** 114***
253*** WARNING: 115*** WARNING:
254*** Your client does not support face/image caching, 116*** Your client does not support face/image caching,
504 delete $pl->{deny_save}; 366 delete $pl->{deny_save};
505 367
506 last; 368 last;
507 } 369 }
508 }); 370 });
509} 371});
510 372
511cf::register_command quit => sub { 373cf::register_command quit => sub {
512 my ($ob, $arg) = @_; 374 my ($ob, $arg) = @_;
513 375
514 $ob->reply (undef, 376 $ob->reply (undef,
585 $pl->{unclean_save} = $cf::RUNTIME; 447 $pl->{unclean_save} = $cf::RUNTIME;
586 } 448 }
587 }, 449 },
588); 450);
589 451
590cf::client->attach (
591 on_addme => \&addme,
592 on_setup => \&setup,
593);
594
595############################################################################# 452#############################################################################
596 453
597our $SCHEDULE_INTERVAL = 10; # time the player scheduler sleeps between runs 454our $SCHEDULE_INTERVAL = 10; # time the player scheduler sleeps between runs
598our $SAVE_TIMEOUT = 20; # save players every n seconds 455our $SAVE_TIMEOUT = 20; # save players every n seconds
599 456

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines