… | |
… | |
294 | |
294 | |
295 | my $pl = $ob->contr; |
295 | my $pl = $ob->contr; |
296 | |
296 | |
297 | # update respawn position |
297 | # update respawn position |
298 | $pl->savebed ($bed->map->path, $bed->x, $bed->y); |
298 | $pl->savebed ($bed->map->path, $bed->x, $bed->y); |
|
|
299 | cf::async { $pl->save }; |
299 | |
300 | |
300 | $pl->killer ("left"); |
301 | $pl->killer ("left"); |
301 | $ob->check_score; |
302 | $ob->check_score; |
302 | |
303 | |
303 | $ob->reply (undef, "In the future, you will wake up here when you die."); |
304 | $ob->reply (undef, "In the future, you will wake up here when you die."); |
… | |
… | |
340 | |
341 | |
341 | ############################################################################# |
342 | ############################################################################# |
342 | |
343 | |
343 | our $SCHEDULE_INTERVAL = 10; # time the player scheduler sleeps between runs |
344 | our $SCHEDULE_INTERVAL = 10; # time the player scheduler sleeps between runs |
344 | our $SAVE_TIMEOUT = 20; # save players every n seconds |
345 | our $SAVE_TIMEOUT = 20; # save players every n seconds |
345 | our $SAVE_INTERVAL = 1.1; # save at max. one player every $SAVE_INTERVAL |
346 | our $SAVE_INTERVAL = 0.5; # save at max. one player every $SAVE_INTERVAL |
346 | |
347 | |
347 | our $SCHEDULER = cf::async_ext { |
348 | our $SCHEDULER = cf::async_ext { |
348 | while () { |
349 | while () { |
349 | Coro::Timer::sleep $SCHEDULE_INTERVAL; |
350 | Coro::Timer::sleep $SCHEDULE_INTERVAL; |
350 | |
351 | |
… | |
… | |
365 | unless ($pl->active) { |
366 | unless ($pl->active) { |
366 | # check refcounts, this is tricky and needs to be adjusted to fit server internals |
367 | # check refcounts, this is tricky and needs to be adjusted to fit server internals |
367 | my $ob = $pl->ob; |
368 | my $ob = $pl->ob; |
368 | Scalar::Util::weaken $pl; |
369 | Scalar::Util::weaken $pl; |
369 | Scalar::Util::weaken $ob; |
370 | Scalar::Util::weaken $ob; |
370 | my $a_ = $pl->refcnt; |
371 | my $a_ = $pl->refcnt;#d# |
371 | my $b_ = $ob->refcnt; |
372 | my $b_ = $ob->refcnt;#d# |
372 | my $pl_ref = $pl->refcnt_cnt; |
373 | my $pl_ref = $pl->refcnt_cnt; |
373 | my $ob_ref = $ob->refcnt_cnt; |
374 | my $ob_ref = $ob->refcnt_cnt; |
374 | |
375 | |
375 | ## pl_ref == one from object + one from cf::PLAYER |
376 | ## pl_ref == one from object + one from cf::PLAYER |
376 | ## ob_ref == one from simply being an object |
377 | ## ob_ref == one from simply being an object |