… | |
… | |
590 | eval { |
590 | eval { |
591 | if ($pl->{last_save} + $SAVE_TIMEOUT <= $cf::RUNTIME) { |
591 | if ($pl->{last_save} + $SAVE_TIMEOUT <= $cf::RUNTIME) { |
592 | cf::wait_for_tick_begin; |
592 | cf::wait_for_tick_begin; |
593 | $pl->save; |
593 | $pl->save; |
594 | |
594 | |
595 | unless ($pl->active) { |
595 | unless ($pl->active || $pl->ns) { |
596 | # 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 |
597 | my $ob = $pl->ob; |
597 | my $ob = $pl->ob; |
598 | Scalar::Util::weaken $pl; |
598 | Scalar::Util::weaken $pl; |
599 | Scalar::Util::weaken $ob; |
599 | Scalar::Util::weaken $ob; |
600 | my $a_ = $pl->refcnt;#d# |
600 | my $a_ = $pl->refcnt;#d# |
601 | my $b_ = $ob->refcnt;#d# |
601 | my $b_ = $ob->refcnt;#d# |
602 | my $pl_ref = $pl->refcnt_cnt; |
602 | my $pl_ref = $pl->refcnt_cnt; |
603 | my $ob_ref = $ob->refcnt_cnt; |
603 | my $ob_ref = $ob->refcnt_cnt; |
604 | |
604 | |
605 | ## pl_ref == one from object + one from cf::PLAYER |
605 | ## pl_ref == one from object + one from cf::PLAYER |
606 | ## ob_ref == one from simply being an object |
606 | ## ob_ref == one from simply being an object + one from pl->observe |
607 | if ($pl_ref == 2 && $ob_ref == 1) { |
607 | if ($pl_ref == 2 && $ob_ref == 2) { |
608 | warn "player-scheduler destroy ", $ob->name;#d# |
608 | warn "player-scheduler destroy ", $ob->name;#d# |
609 | |
609 | |
610 | # remove from sight and get fresh "copies" |
610 | # remove from sight and get fresh "copies" |
611 | $pl = delete $cf::PLAYER{$ob->name}; |
611 | $pl = delete $cf::PLAYER{$ob->name}; |
612 | $ob = $pl->ob; |
612 | $ob = $pl->ob; |