ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/lib/cf.pm
(Generate patch)

Comparing deliantra/server/lib/cf.pm (file contents):
Revision 1.433 by root, Sat May 10 22:38:52 2008 UTC vs.
Revision 1.438 by elmex, Sun Jul 13 20:15:51 2008 UTC

34use Storable (); 34use Storable ();
35 35
36use Coro (); 36use Coro ();
37use Coro::State; 37use Coro::State;
38use Coro::Handle; 38use Coro::Handle;
39use Coro::EV; 39use Coro::AnyEvent;
40use Coro::Timer; 40use Coro::Timer;
41use Coro::Signal; 41use Coro::Signal;
42use Coro::Semaphore; 42use Coro::Semaphore;
43use Coro::AnyEvent; 43use Coro::AnyEvent;
44use Coro::AIO; 44use Coro::AIO;
45use Coro::BDB; 45use Coro::BDB 1.6;
46use Coro::Storable; 46use Coro::Storable;
47use Coro::Util (); 47use Coro::Util ();
48 48
49use JSON::XS 2.01 (); 49use JSON::XS 2.01 ();
50use BDB (); 50use BDB ();
2613Moves the player to the given map-path and coordinates by first freezing 2613Moves the player to the given map-path and coordinates by first freezing
2614her, loading and preparing them map, calling the provided $check callback 2614her, loading and preparing them map, calling the provided $check callback
2615that has to return the map if sucecssful, and then unfreezes the player on 2615that has to return the map if sucecssful, and then unfreezes the player on
2616the new (success) or old (failed) map position. In either case, $done will 2616the new (success) or old (failed) map position. In either case, $done will
2617be called at the end of this process. 2617be called at the end of this process.
2618
2619Note that $check will be called with a potentially non-loaded map, so if
2620it needs a loaded map it has to call C<< ->load >>.
2618 2621
2619=cut 2622=cut
2620 2623
2621our $GOTOGEN; 2624our $GOTOGEN;
2622 2625
3125=cut 3128=cut
3126 3129
3127for ( 3130for (
3128 ["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
3129 insert remove inv nrof name archname title slaying race 3132 insert remove inv nrof name archname title slaying race
3130 decrease split destroy)], 3133 decrease split destroy change_exp)],
3131 ["cf::object::player" => qw(player)], 3134 ["cf::object::player" => qw(player)],
3132 ["cf::player" => qw(peaceful)], 3135 ["cf::player" => qw(peaceful)],
3133 ["cf::map" => qw(trigger)], 3136 ["cf::map" => qw(trigger)],
3134) { 3137) {
3135 no strict 'refs'; 3138 no strict 'refs';
3395 warn "finished reloading resource files\n"; 3398 warn "finished reloading resource files\n";
3396} 3399}
3397 3400
3398sub init { 3401sub init {
3399 my $guard = freeze_mainloop; 3402 my $guard = freeze_mainloop;
3403
3404 evthread_start IO::AIO::poll_fileno;
3400 3405
3401 reload_resources; 3406 reload_resources;
3402} 3407}
3403 3408
3404sub reload_config { 3409sub reload_config {
3437 reload_config; 3442 reload_config;
3438 db_init; 3443 db_init;
3439 load_extensions; 3444 load_extensions;
3440 3445
3441 $Coro::current->prio (Coro::PRIO_MAX); # give the main loop max. priority 3446 $Coro::current->prio (Coro::PRIO_MAX); # give the main loop max. priority
3442 evthread_start IO::AIO::poll_fileno;
3443 } 3447 }
3444 3448
3445 EV::loop; 3449 EV::loop;
3446} 3450}
3447 3451
3792 BDB::max_poll_reqs $TICK * 0.1; 3796 BDB::max_poll_reqs $TICK * 0.1;
3793 $AnyEvent::BDB::WATCHER->priority (1); 3797 $AnyEvent::BDB::WATCHER->priority (1);
3794 3798
3795 unless ($DB_ENV) { 3799 unless ($DB_ENV) {
3796 $DB_ENV = BDB::db_env_create; 3800 $DB_ENV = BDB::db_env_create;
3797 $DB_ENV->set_flags (BDB::AUTO_COMMIT | BDB::REGION_INIT | BDB::TXN_NOSYNC 3801 $DB_ENV->set_flags (BDB::AUTO_COMMIT | BDB::REGION_INIT);
3798 | 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;
3799 $DB_ENV->set_timeout (30, BDB::SET_TXN_TIMEOUT); 3804 $DB_ENV->set_timeout (30, BDB::SET_TXN_TIMEOUT);
3800 $DB_ENV->set_timeout (30, BDB::SET_LOCK_TIMEOUT); 3805 $DB_ENV->set_timeout (30, BDB::SET_LOCK_TIMEOUT);
3801 3806
3802 cf::sync_job { 3807 cf::sync_job {
3803 eval { 3808 eval {
3829{ 3834{
3830 # configure IO::AIO 3835 # configure IO::AIO
3831 3836
3832 IO::AIO::min_parallel 8; 3837 IO::AIO::min_parallel 8;
3833 IO::AIO::max_poll_time $TICK * 0.1; 3838 IO::AIO::max_poll_time $TICK * 0.1;
3834 $AnyEvent::AIO::WATCHER->priority (1); 3839 undef $AnyEvent::AIO::WATCHER;
3835} 3840}
3836 3841
3837my $_log_backtrace; 3842my $_log_backtrace;
3838 3843
3839sub _log_backtrace { 3844sub _log_backtrace {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines