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.46 by root, Tue Apr 24 11:36:39 2007 UTC vs.
Revision 1.49 by root, Sun Jun 10 03:11:16 2007 UTC

51 ); 51 );
52 52
53 1 53 1
54} 54}
55 55
56sub check_clean_save { 56sub enter_map {
57 my ($pl) = @_; 57 my ($pl) = @_;
58 58
59 my ($map, $x, $y)
60 = $pl->ob->{_link_pos}
61 ? @{delete $pl->ob->{_link_pos}}
62 : ($pl->maplevel, $pl->ob->x, $pl->ob->y);
63
64 $pl->ob->enter_link;
65
59 if (my $time = delete $pl->{unclean_save}) { 66 if (my $time = delete $pl->{unclean_save}) {
67 if (my $m = cf::map::find $map) {
68 if ($time < $m->{instantiate_time}) {
69 # the map was reset in the meantime
70 my $age = $cf::RUNTIME - $time;
71 warn $pl->ob->name, " map reset after logout, logout age $age\n";#d#
72
73 # for now, just go back to savebed
74 ($map, $x, $y) = $pl->savebed;
75
60 $pl->ns->send_drawinfo ( 76 $pl->ns->send_drawinfo (
77 "You didn't use a bed to reality to leave this realm, leaving your body in great danger. "
78 . "Fortunately, some friendly dwellers found you, checked your passport, and brought you to safety. "
79 . "Better use a savebed next time, much worse things could have happened...",
80 cf::NDI_RED
81 );
82 } else {
83 $pl->ns->send_drawinfo (
61 "You didn't use a savebed to leave this realm. This is very dangerous, " 84 "You didn't use a bed to reality to leave this realm. This is very dangerous, "
62 . "as lots of things could happen when you leave by other means, such as cave-ins, " 85 . "as lots of things could happen when you leave by other means, such as cave-ins, "
63 . "or monsters suddenly snapping your body. Better use a savebed next time.", 86 . "or monsters suddenly snapping your body. Better use a savebed next time.",
64 cf::NDI_RED 87 cf::NDI_RED
88 );
89 }
65 ); 90 }
66 #d#TODO
67 } 91 }
92
93 $pl->ob->goto ($map, $x, $y);
68} 94}
69 95
70# delete a player directory, be non-blocking AND synchronous... 96# delete a player directory, be non-blocking AND synchronous...
71# (thats hard, so we crap out and fork). 97# (thats hard, so we crap out and fork).
72sub nuke_playerdir { 98sub nuke_playerdir {
332 if ($cf::CFG{ext_login_nocheck} or $hash eq crypt $pass, $hash) { 358 if ($cf::CFG{ext_login_nocheck} or $hash eq crypt $pass, $hash) {
333 nuke_str $pass; 359 nuke_str $pass;
334 # password matches, wonderful 360 # password matches, wonderful
335 my $pl = cf::player::find $user or next; 361 my $pl = cf::player::find $user or next;
336 $pl->connect ($ns); 362 $pl->connect ($ns);
337 check_clean_save $pl; 363 enter_map $pl;
338 last; 364 last;
339 } elsif (can_cleanup $pl, $mtime) { 365 } elsif (can_cleanup $pl, $mtime) {
340 Coro::Timer::sleep 1; 366 Coro::Timer::sleep 1;
341 367
342 $ns->send_drawinfo ( 368 $ns->send_drawinfo (
405 431
406 my $pl = cf::player::new $user; 432 my $pl = cf::player::new $user;
407 $pl->password (crypt $pass, join '', ('.', '/', 0..9, 'A'..'Z', 'a'..'z')[rand 64, rand 64]); 433 $pl->password (crypt $pass, join '', ('.', '/', 0..9, 'A'..'Z', 'a'..'z')[rand 64, rand 64]);
408 nuke_str $pass; 434 nuke_str $pass;
409 $pl->connect ($ns); 435 $pl->connect ($ns);
410
411 my $ob = $pl->ob; 436 my $ob = $pl->ob;
437
438 $ob->goto ($pl->maplevel, $ob->x, $ob->y);
412 439
413 while () { 440 while () {
414 $ob->update_stats; 441 $ob->update_stats;
415 $pl->save_stats; 442 $pl->save_stats;
416 443
563 eval { 590 eval {
564 if ($pl->{last_save} + $SAVE_TIMEOUT <= $cf::RUNTIME) { 591 if ($pl->{last_save} + $SAVE_TIMEOUT <= $cf::RUNTIME) {
565 cf::wait_for_tick_begin; 592 cf::wait_for_tick_begin;
566 $pl->save; 593 $pl->save;
567 594
568 unless ($pl->active) { 595 unless ($pl->active || $pl->ns) {
569 # check refcounts, this is tricky and needs to be adjusted to fit server internals 596 # check refcounts, this is tricky and needs to be adjusted to fit server internals
570 my $ob = $pl->ob; 597 my $ob = $pl->ob;
571 Scalar::Util::weaken $pl; 598 Scalar::Util::weaken $pl;
572 Scalar::Util::weaken $ob; 599 Scalar::Util::weaken $ob;
573 my $a_ = $pl->refcnt;#d# 600 my $a_ = $pl->refcnt;#d#
574 my $b_ = $ob->refcnt;#d# 601 my $b_ = $ob->refcnt;#d#
575 my $pl_ref = $pl->refcnt_cnt; 602 my $pl_ref = $pl->refcnt_cnt;
576 my $ob_ref = $ob->refcnt_cnt; 603 my $ob_ref = $ob->refcnt_cnt;
577 604
578 ## pl_ref == one from object + one from cf::PLAYER 605 ## pl_ref == one from object + one from cf::PLAYER
579 ## ob_ref == one from simply being an object 606 ## ob_ref == one from simply being an object + one from pl->observe
580 if ($pl_ref == 2 && $ob_ref == 1) { 607 if ($pl_ref == 2 && $ob_ref == 2) {
581 warn "player-scheduler destroy ", $ob->name;#d# 608 warn "player-scheduler destroy ", $ob->name;#d#
582 609
583 # remove from sight and get fresh "copies" 610 # remove from sight and get fresh "copies"
584 $pl = delete $cf::PLAYER{$ob->name}; 611 $pl = delete $cf::PLAYER{$ob->name};
585 $ob = $pl->ob; 612 $ob = $pl->ob;
586 613
587 $ob->destroy; 614 $ob->destroy;
588 $pl->destroy; 615 $pl->destroy;
589 } else { 616 } else {
590 warn "player-scheduler refcnt ", $ob->name, " $pl_ref,$a_ $ob_ref,$b_\n";#d# 617 warn "player-scheduler refcnt ", $ob->name, " pp$pl_ref,pc$a_ op$ob_ref,oc$b_\n";#d#
591 } 618 }
592 } 619 }
593 } 620 }
594 }; 621 };
595 warn $@ if $@; 622 warn $@ if $@;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines