… | |
… | |
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, interval => $SCHEDULE_INTERVAL); |
486 | my $schedule_interval = Coro::Event->timer (after => 1); |
487 | while () { |
487 | while () { |
|
|
488 | $schedule_interval->interval ($SCHEDULE_INTERVAL); |
488 | $schedule_interval->next; |
489 | $schedule_interval->next; |
489 | |
490 | |
490 | # this weird form of iteration over values is used because |
491 | # this weird form of iteration over values is used because |
491 | # the hash changes underneath us frequently, and for |
492 | # the hash changes underneath us frequently, and for |
492 | # keeps a direct reference to the value without (in 5.8 perls) |
493 | # keeps a direct reference to the value without (in 5.8 perls) |
… | |
… | |
497 | or next; |
498 | or next; |
498 | $pl->valid or next; |
499 | $pl->valid or next; |
499 | |
500 | |
500 | eval { |
501 | eval { |
501 | if ($pl->{last_save} + $SAVE_TIMEOUT <= $cf::RUNTIME) { |
502 | if ($pl->{last_save} + $SAVE_TIMEOUT <= $cf::RUNTIME) { |
502 | cf::wait_for_tick_begin; |
|
|
503 | $pl->save; |
503 | $pl->save; |
504 | |
504 | |
505 | unless ($pl->active || $pl->ns) { |
505 | unless ($pl->active || $pl->ns) { |
506 | # 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 |
507 | my $ob = $pl->ob; |
507 | my $ob = $pl->ob; |