--- deliantra/server/ext/login.ext 2007/01/08 14:11:05 1.17 +++ deliantra/server/ext/login.ext 2007/01/08 22:32:10 1.20 @@ -23,10 +23,10 @@ } sub can_cleanup { - my ($playerfile, $mtime) = @_; + my ($pl, $mtime) = @_; my $age = time - $mtime; - my $level = $playerfile =~ /^level (\d+)$/m ? $1 : return; + my $level = $pl->ob->level; ($level <= 3 && $age > 7 * 86400) # 7 days for level 0..3 || ($level <= 9 && $age > 90 * 86400) # 3 months for level 4..9 @@ -147,14 +147,12 @@ check_playing $ns, $user and next; # try to read the user file and check the password - if (my $fh = aio_open cf::player::path $user, O_RDONLY, 0) { - my $mtime = (stat $fh)[9]; + if (my $pl = cf::player::find $user) { + aio_stat $pl->path and next; + my $mtime = (stat _)[9]; + my $hash = $pl->password; - 0 < aio_read $fh, 0, 16384, my $buf, 0 or next; - $buf =~ /^password (\S+)$/m or next; - my $hash = $1; - - if ($hash eq crypt $pass, $hash) { + if ($cf::CFG{ext_login_nocheck} or $hash eq crypt $pass, $hash) { nuke_str $pass; # password matches, wonderful my $pl = cf::player::find $user or next; @@ -162,7 +160,7 @@ check_clean_save $pl; $pl->{clean_save} = 1; last; - } elsif (can_cleanup $buf, $mtime) { + } elsif (can_cleanup $pl, $mtime) { Coro::Timer::sleep 1; $ns->send_drawinfo ( @@ -180,7 +178,7 @@ aio_stat cf::player::path $user and next; $mtime == (stat _)[9] or next; - nuke_playerdir $user; + $pl->quit_character; # fall through to creation } else { @@ -344,7 +342,7 @@ our $SCHEDULE_INTERVAL = 10; # time the player scheduler sleeps between runs our $SAVE_TIMEOUT = 200; # save players every n seconds -our $SAVE_INTERVAL = 0.1; # save at max. one player every $SAVE_INTERVAL +our $SAVE_INTERVAL = 1.1; # save at max. one player every $SAVE_INTERVAL our $SCHEDULER = cf::async_ext { while () { @@ -378,11 +376,11 @@ if ($pl_ref == 2 && $ob_ref == 1) { warn "player-scheduler destroy ", $ob->name;#d# - delete $cf::PLAYER{$ob->name}; - # pl_ref == one from object + one from cf::PLAYER - # ob_ref == one from simply being an object - $ob->destroy; - $pl->destroy; + #delete $cf::PLAYER{$ob->name}; + ## pl_ref == one from object + one from cf::PLAYER + ## ob_ref == one from simply being an object + #$ob->destroy; + #$pl->destroy; } else { warn "player-scheduler refcnt ", $ob->name, " $pl_ref,$a_ $ob_ref,$b_\n";#d# }