… | |
… | |
40 | use Coro::Timer; |
40 | use Coro::Timer; |
41 | use Coro::Signal; |
41 | use Coro::Signal; |
42 | use Coro::Semaphore; |
42 | use Coro::Semaphore; |
43 | use Coro::AnyEvent; |
43 | use Coro::AnyEvent; |
44 | use Coro::AIO; |
44 | use Coro::AIO; |
45 | use Coro::BDB; |
45 | use Coro::BDB 1.6; |
46 | use Coro::Storable; |
46 | use Coro::Storable; |
47 | use Coro::Util (); |
47 | use Coro::Util (); |
48 | |
48 | |
49 | use JSON::XS 2.01 (); |
49 | use JSON::XS 2.01 (); |
50 | use BDB (); |
50 | use BDB (); |
… | |
… | |
56 | use Time::HiRes; |
56 | use Time::HiRes; |
57 | use Compress::LZF; |
57 | use Compress::LZF; |
58 | use Digest::MD5 (); |
58 | use Digest::MD5 (); |
59 | |
59 | |
60 | AnyEvent::detect; |
60 | AnyEvent::detect; |
61 | |
|
|
62 | IO::AIO::max_poll_reqs 1;#d# |
|
|
63 | |
61 | |
64 | # configure various modules to our taste |
62 | # configure various modules to our taste |
65 | # |
63 | # |
66 | $Storable::canonical = 1; # reduce rsync transfers |
64 | $Storable::canonical = 1; # reduce rsync transfers |
67 | Coro::State::cctx_stacksize 256000; # 1-2MB stack, for deep recursions in maze generator |
65 | Coro::State::cctx_stacksize 256000; # 1-2MB stack, for deep recursions in maze generator |
… | |
… | |
2615 | Moves the player to the given map-path and coordinates by first freezing |
2613 | Moves the player to the given map-path and coordinates by first freezing |
2616 | her, loading and preparing them map, calling the provided $check callback |
2614 | her, loading and preparing them map, calling the provided $check callback |
2617 | that has to return the map if sucecssful, and then unfreezes the player on |
2615 | that has to return the map if sucecssful, and then unfreezes the player on |
2618 | the new (success) or old (failed) map position. In either case, $done will |
2616 | the new (success) or old (failed) map position. In either case, $done will |
2619 | be called at the end of this process. |
2617 | be called at the end of this process. |
|
|
2618 | |
|
|
2619 | Note that $check will be called with a potentially non-loaded map, so if |
|
|
2620 | it needs a loaded map it has to call C<< ->load >>. |
2620 | |
2621 | |
2621 | =cut |
2622 | =cut |
2622 | |
2623 | |
2623 | our $GOTOGEN; |
2624 | our $GOTOGEN; |
2624 | |
2625 | |
… | |
… | |
3127 | =cut |
3128 | =cut |
3128 | |
3129 | |
3129 | for ( |
3130 | for ( |
3130 | ["cf::object" => qw(contr pay_amount pay_player map force_find force_add x y |
3131 | ["cf::object" => qw(contr pay_amount pay_player map force_find force_add x y |
3131 | insert remove inv nrof name archname title slaying race |
3132 | insert remove inv nrof name archname title slaying race |
3132 | decrease split destroy)], |
3133 | decrease split destroy change_exp)], |
3133 | ["cf::object::player" => qw(player)], |
3134 | ["cf::object::player" => qw(player)], |
3134 | ["cf::player" => qw(peaceful)], |
3135 | ["cf::player" => qw(peaceful)], |
3135 | ["cf::map" => qw(trigger)], |
3136 | ["cf::map" => qw(trigger)], |
3136 | ) { |
3137 | ) { |
3137 | no strict 'refs'; |
3138 | no strict 'refs'; |
… | |
… | |
3397 | warn "finished reloading resource files\n"; |
3398 | warn "finished reloading resource files\n"; |
3398 | } |
3399 | } |
3399 | |
3400 | |
3400 | sub init { |
3401 | sub init { |
3401 | my $guard = freeze_mainloop; |
3402 | my $guard = freeze_mainloop; |
|
|
3403 | |
|
|
3404 | evthread_start IO::AIO::poll_fileno; |
3402 | |
3405 | |
3403 | reload_resources; |
3406 | reload_resources; |
3404 | } |
3407 | } |
3405 | |
3408 | |
3406 | sub reload_config { |
3409 | sub reload_config { |
… | |
… | |
3793 | BDB::max_poll_reqs $TICK * 0.1; |
3796 | BDB::max_poll_reqs $TICK * 0.1; |
3794 | $AnyEvent::BDB::WATCHER->priority (1); |
3797 | $AnyEvent::BDB::WATCHER->priority (1); |
3795 | |
3798 | |
3796 | unless ($DB_ENV) { |
3799 | unless ($DB_ENV) { |
3797 | $DB_ENV = BDB::db_env_create; |
3800 | $DB_ENV = BDB::db_env_create; |
3798 | $DB_ENV->set_flags (BDB::AUTO_COMMIT | BDB::REGION_INIT | BDB::TXN_NOSYNC |
3801 | $DB_ENV->set_flags (BDB::AUTO_COMMIT | BDB::REGION_INIT); |
3799 | | BDB::LOG_AUTOREMOVE, 1); |
3802 | $DB_ENV->set_flags (&BDB::LOG_AUTOREMOVE ) if BDB::VERSION v0, v4.7; |
|
|
3803 | $DB_ENV->log_set_config (&BDB::LOG_AUTO_REMOVE) if BDB::VERSION v4.7; |
3800 | $DB_ENV->set_timeout (30, BDB::SET_TXN_TIMEOUT); |
3804 | $DB_ENV->set_timeout (30, BDB::SET_TXN_TIMEOUT); |
3801 | $DB_ENV->set_timeout (30, BDB::SET_LOCK_TIMEOUT); |
3805 | $DB_ENV->set_timeout (30, BDB::SET_LOCK_TIMEOUT); |
3802 | |
3806 | |
3803 | cf::sync_job { |
3807 | cf::sync_job { |
3804 | eval { |
3808 | eval { |
… | |
… | |
3830 | { |
3834 | { |
3831 | # configure IO::AIO |
3835 | # configure IO::AIO |
3832 | |
3836 | |
3833 | IO::AIO::min_parallel 8; |
3837 | IO::AIO::min_parallel 8; |
3834 | IO::AIO::max_poll_time $TICK * 0.1; |
3838 | IO::AIO::max_poll_time $TICK * 0.1; |
3835 | #undef $AnyEvent::AIO::WATCHER; |
3839 | undef $AnyEvent::AIO::WATCHER; |
3836 | } |
3840 | } |
3837 | |
3841 | |
3838 | my $_log_backtrace; |
3842 | my $_log_backtrace; |
3839 | |
3843 | |
3840 | sub _log_backtrace { |
3844 | sub _log_backtrace { |
… | |
… | |
3878 | # load additional modules |
3882 | # load additional modules |
3879 | use cf::pod; |
3883 | use cf::pod; |
3880 | |
3884 | |
3881 | END { cf::emergency_save } |
3885 | END { cf::emergency_save } |
3882 | |
3886 | |
3883 | evthread_start IO::AIO::poll_fileno; |
|
|
3884 | |
|
|
3885 | 1 |
3887 | 1 |
3886 | |
3888 | |