… | |
… | |
340 | |
340 | |
341 | ############################################################################# |
341 | ############################################################################# |
342 | |
342 | |
343 | our $SCHEDULE_INTERVAL = 10; # time the player scheduler sleeps between runs |
343 | our $SCHEDULE_INTERVAL = 10; # time the player scheduler sleeps between runs |
344 | our $SAVE_TIMEOUT = 200; # save players every n seconds |
344 | our $SAVE_TIMEOUT = 200; # save players every n seconds |
345 | our $SAVE_INTERVAL = 0.1; # save at max. one player every $SAVE_INTERVAL |
345 | our $SAVE_INTERVAL = 1.1; # save at max. one player every $SAVE_INTERVAL |
346 | |
346 | |
347 | our $SCHEDULER = cf::async_ext { |
347 | our $SCHEDULER = cf::async_ext { |
348 | while () { |
348 | while () { |
349 | Coro::Timer::sleep $SCHEDULE_INTERVAL; |
349 | Coro::Timer::sleep $SCHEDULE_INTERVAL; |
350 | |
350 | |
… | |
… | |
374 | my $pl_ref = $pl->refcnt_cnt; |
374 | my $pl_ref = $pl->refcnt_cnt; |
375 | my $ob_ref = $ob->refcnt_cnt; |
375 | my $ob_ref = $ob->refcnt_cnt; |
376 | |
376 | |
377 | if ($pl_ref == 2 && $ob_ref == 1) { |
377 | if ($pl_ref == 2 && $ob_ref == 1) { |
378 | warn "player-scheduler destroy ", $ob->name;#d# |
378 | warn "player-scheduler destroy ", $ob->name;#d# |
379 | delete $cf::PLAYER{$ob->name}; |
379 | #delete $cf::PLAYER{$ob->name}; |
380 | # pl_ref == one from object + one from cf::PLAYER |
380 | ## pl_ref == one from object + one from cf::PLAYER |
381 | # ob_ref == one from simply being an object |
381 | ## ob_ref == one from simply being an object |
382 | $ob->destroy; |
382 | #$ob->destroy; |
383 | $pl->destroy; |
383 | #$pl->destroy; |
384 | } else { |
384 | } else { |
385 | warn "player-scheduler refcnt ", $ob->name, " $pl_ref,$a_ $ob_ref,$b_\n";#d# |
385 | warn "player-scheduler refcnt ", $ob->name, " $pl_ref,$a_ $ob_ref,$b_\n";#d# |
386 | } |
386 | } |
387 | } |
387 | } |
388 | }; |
388 | }; |