… | |
… | |
477 | }, |
477 | }, |
478 | ); |
478 | ); |
479 | |
479 | |
480 | ############################################################################# |
480 | ############################################################################# |
481 | |
481 | |
482 | our $SCHEDULE_INTERVAL = 10; # time the player scheduler sleeps between runs |
482 | our $SCHEDULE_INTERVAL = $cf::CFG{player_schedule_interval} || 10; # time the player scheduler sleeps between runs |
483 | our $SAVE_TIMEOUT = 20; # save players every n seconds |
483 | our $SAVE_TIMEOUT = $cf::CFG{player_save_interval} || 20; # save players every n seconds |
484 | |
484 | |
485 | our $SCHEDULER = cf::async_ext { |
485 | our $SCHEDULER = cf::async_ext { |
486 | my $schedule_interval = Coro::Event->timer (after => 1); |
486 | my $schedule_interval = Coro::Event->timer (after => 1); |
487 | while () { |
487 | while () { |
488 | $schedule_interval->interval ($SCHEDULE_INTERVAL); |
488 | $schedule_interval->interval ($SCHEDULE_INTERVAL); |
… | |
… | |
498 | or next; |
498 | or next; |
499 | $pl->valid or next; |
499 | $pl->valid or next; |
500 | |
500 | |
501 | eval { |
501 | eval { |
502 | if ($pl->{last_save} + $SAVE_TIMEOUT <= $cf::RUNTIME) { |
502 | if ($pl->{last_save} + $SAVE_TIMEOUT <= $cf::RUNTIME) { |
503 | cf::wait_for_tick_begin; |
|
|
504 | $pl->save; |
503 | $pl->save; |
505 | |
504 | |
506 | unless ($pl->active || $pl->ns) { |
505 | unless ($pl->active || $pl->ns) { |
507 | # check refcounts, this is tricky and needs to be adjusted to fit server internals |
506 | # check refcounts, this is tricky and needs to be adjusted to fit server internals |
508 | my $ob = $pl->ob; |
507 | my $ob = $pl->ob; |