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.67 by root, Fri Jul 20 16:11:10 2007 UTC vs.
Revision 1.75 by root, Wed Dec 26 21:38:02 2007 UTC

116# delete a player directory, be non-blocking AND synchronous... 116# delete a player directory, be non-blocking AND synchronous...
117# (thats hard, so we crap out and fork). 117# (thats hard, so we crap out and fork).
118sub nuke_playerdir { 118sub nuke_playerdir {
119 my ($user) = @_; 119 my ($user) = @_;
120 120
121 aio_stat "$PLAYERDIR/$user"; 121 my $temp = "$PLAYERDIR/~$Coro::current~deleting~";
122 system "cd \Q$PLAYERDIR\E " 122
123 . "&& mv \Q$user\E ~\Q$Coro::current\E~deleting~ 2>/dev/null " 123 cf::fork_call {
124 . "&& (rm -rf ~\Q$Coro::current\E~deleting~ &)"; 124 rename "$PLAYERDIR/$user", $temp;
125 system "rm", "-rf", $temp;
126 };
125} 127}
126 128
127cf::client->attach (on_addme => sub { 129cf::client->attach (on_addme => sub {
128 my ($ns) = @_; 130 my ($ns) = @_;
129 131
142*** 144***
143*** CFPlus: all known versions automatically enable the facecache. 145*** CFPlus: all known versions automatically enable the facecache.
144*** cfclient: use the -cache commandline option. 146*** cfclient: use the -cache commandline option.
145*** cfclient: map will not redraw automatically (bug). 147*** cfclient: map will not redraw automatically (bug).
146*** gcfclient: use -cache commandline option, or enable 148*** gcfclient: use -cache commandline option, or enable
147*** gcfclient: Client=>Configure=>Map & Image=>Cache Images. 149*** gcfclient: Client => Configure => Map & Image => Cache Images.
148*** jcrossclient: your client is broken, use CFPlus or gcfclient. 150*** jcrossclient: your client is broken, use CFPlus or gcfclient.
149*** 151***
150*** 152***
151EOF 153EOF
152 if ($ns->version =~ /jcrossclient/) { 154 if ($ns->version =~ /jcrossclient/) {
173 } 175 }
174 176
175 $ns->pl and return $ns->destroy; 177 $ns->pl and return $ns->destroy;
176 178
177 $ns->async (sub { 179 $ns->async (sub {
180 $Coro::current->{desc} = "addme init";
181
178 my ($user, $pass); 182 my ($user, $pass);
179 183
180 $ns->send_packet ("addme_success"); 184 $ns->send_packet ("addme_success");
181 185
182 for (;;) { 186 for (;;) {
209 } 213 }
210 Coro::Timer::sleep 0.4; 214 Coro::Timer::sleep 0.4;
211 } 215 }
212 216
213 check_playing $ns, $user and next; 217 check_playing $ns, $user and next;
218
219 $Coro::current->{desc} = "addme($user) pass";
214 220
215 $ns->send_drawinfo ( 221 $ns->send_drawinfo (
216 "Welcome $user, please enter your password now. " 222 "Welcome $user, please enter your password now. "
217 . "New users should now choose a password. " 223 . "New users should now choose a password. "
218 . "Anything your client lets you enter is fine.", 224 . "Anything your client lets you enter is fine.",
242 } 248 }
243 local $cf::LOGIN_LOCK{$user} = 1; 249 local $cf::LOGIN_LOCK{$user} = 1;
244 250
245 check_playing $ns, $user and next; 251 check_playing $ns, $user and next;
246 252
253 $Coro::current->{desc} = "addme($user) check";
254
247 # try to read the user file and check the password 255 # try to read the user file and check the password
248 if (my $pl = cf::player::find $user) { 256 if (my $pl = cf::player::find $user) {
249 aio_stat $pl->path and next; 257 aio_stat $pl->path and next;
250 my $mtime = (stat _)[9]; 258 my $mtime = (stat _)[9];
251 my $hash = $pl->password; 259 my $hash = $pl->password;
304 next; 312 next;
305 } 313 }
306 } 314 }
307 315
308 # the rest of this function is character creation 316 # the rest of this function is character creation
317 $Coro::current->{desc} = "addme($user) chargen";
309 318
310 # just to make sure nothing is left over 319 # just to make sure nothing is left over
311 nuke_playerdir $user; 320 nuke_playerdir $user;
312 321
313 my $pass2 = query $ns, cf::CS_QUERY_HIDEINPUT, "Please type your password again."; 322 my $pass2 = query $ns, cf::CS_QUERY_HIDEINPUT, "Please type your password again.";
387 last; 396 last;
388 } 397 }
389 Coro::Timer::sleep 0.2; 398 Coro::Timer::sleep 0.2;
390 } 399 }
391 400
392 $ob->reply (undef, "Welcome to Crossfire!"); 401 $ob->reply (undef, "Welcome to Deliantra!");
393 402
394 delete $pl->{deny_save}; 403 delete $pl->{deny_save};
395 404
396 last; 405 last;
397 } 406 }
477 }, 486 },
478); 487);
479 488
480############################################################################# 489#############################################################################
481 490
482our $SCHEDULE_INTERVAL = 10; # time the player scheduler sleeps between runs 491our $SCHEDULE_INTERVAL = $cf::CFG{player_schedule_interval} || 10; # time the player scheduler sleeps between runs
483our $SAVE_TIMEOUT = 20; # save players every n seconds 492our $SAVE_TIMEOUT = $cf::CFG{player_save_interval} || 20; # save players every n seconds
484 493
485our $SCHEDULER = cf::async_ext { 494our $SCHEDULER = cf::async_ext {
486 my $schedule_interval = Coro::Event->timer (after => 1, interval => $SCHEDULE_INTERVAL); 495 $Coro::current->{desc} = "player scheduler";
496
487 while () { 497 while () {
488 $schedule_interval->next; 498 Coro::EV::timer_once $SCHEDULE_INTERVAL;
489 499
490 # this weird form of iteration over values is used because 500 # this weird form of iteration over values is used because
491 # the hash changes underneath us frequently, and for 501 # the hash changes underneath us frequently, and for
492 # keeps a direct reference to the value without (in 5.8 perls) 502 # keeps a direct reference to the value without (in 5.8 perls)
493 # keeping a reference, so this is prone to crashes or worse. 503 # keeping a reference, so this is prone to crashes or worse.
497 or next; 507 or next;
498 $pl->valid or next; 508 $pl->valid or next;
499 509
500 eval { 510 eval {
501 if ($pl->{last_save} + $SAVE_TIMEOUT <= $cf::RUNTIME) { 511 if ($pl->{last_save} + $SAVE_TIMEOUT <= $cf::RUNTIME) {
502 cf::wait_for_tick_begin;
503 $pl->save; 512 $pl->save;
504 513
505 unless ($pl->active || $pl->ns) { 514 unless ($pl->active || $pl->ns) {
506 # check refcounts, this is tricky and needs to be adjusted to fit server internals 515 # check refcounts, this is tricky and needs to be adjusted to fit server internals
507 my $ob = $pl->ob; 516 my $ob = $pl->ob;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines