… | |
… | |
75 | |
75 | |
76 | # strictly for debugging |
76 | # strictly for debugging |
77 | $SIG{QUIT} = sub { Carp::cluck "SIGQUIT" }; |
77 | $SIG{QUIT} = sub { Carp::cluck "SIGQUIT" }; |
78 | |
78 | |
79 | sub WF_AUTOCANCEL () { 1 } # automatically cancel this watcher on reload |
79 | sub WF_AUTOCANCEL () { 1 } # automatically cancel this watcher on reload |
|
|
80 | |
|
|
81 | our @ORIG_INC; |
80 | |
82 | |
81 | our %COMMAND = (); |
83 | our %COMMAND = (); |
82 | our %COMMAND_TIME = (); |
84 | our %COMMAND_TIME = (); |
83 | |
85 | |
84 | our @EXTS = (); # list of extension package names |
86 | our @EXTS = (); # list of extension package names |
… | |
… | |
3356 | =cut |
3358 | =cut |
3357 | |
3359 | |
3358 | ############################################################################# |
3360 | ############################################################################# |
3359 | # the server's init and main functions |
3361 | # the server's init and main functions |
3360 | |
3362 | |
|
|
3363 | # async inc loader. yay. |
|
|
3364 | sub inc_loader { |
|
|
3365 | my $mod = $_[1]; |
|
|
3366 | |
|
|
3367 | if (in_main && !tick_inhibit) { |
|
|
3368 | Carp::cluck "ERROR: attempted synchronous perl module load ($mod)"; |
|
|
3369 | } else { |
|
|
3370 | debug "loading perl module $mod\n"; |
|
|
3371 | } |
|
|
3372 | |
|
|
3373 | # 1. find real file |
|
|
3374 | for my $dir (@ORIG_INC) { |
|
|
3375 | warn "$dir/$mod\n";#d# |
|
|
3376 | ref $dir and next; |
|
|
3377 | 0 <= Coro::AIO::aio_load "$dir/$mod", my $data |
|
|
3378 | or next; |
|
|
3379 | |
|
|
3380 | $data = "#line 1 $dir/$mod\n$data"; |
|
|
3381 | |
|
|
3382 | open my $fh, "<", \$data or die; |
|
|
3383 | |
|
|
3384 | return $fh; |
|
|
3385 | } |
|
|
3386 | |
|
|
3387 | () |
|
|
3388 | } |
|
|
3389 | |
|
|
3390 | sub init_inc { |
|
|
3391 | # save original @INC |
|
|
3392 | @ORIG_INC = ($LIBDIR, @INC) unless @ORIG_INC; |
|
|
3393 | |
|
|
3394 | # make sure we can do scalar-opens |
|
|
3395 | open my $dummy, "<", \my $dummy2; |
|
|
3396 | |
|
|
3397 | # execute some stuff so perl load's some of the core modules |
|
|
3398 | /Ü/ =~ /ü/i; |
|
|
3399 | eval { &Storable::nstore_fd }; |
|
|
3400 | |
|
|
3401 | @INC = (\&inc_loader, @ORIG_INC); # @ORIG_INC is needed for DynaLoader, AutoLoad etc. |
|
|
3402 | |
|
|
3403 | debug "module loading will be asynchronous from this point on."; |
|
|
3404 | } |
|
|
3405 | |
3361 | sub load_facedata($) { |
3406 | sub load_facedata($) { |
3362 | my ($path) = @_; |
3407 | my ($path) = @_; |
3363 | |
3408 | |
3364 | # HACK to clear player env face cache, we need some signal framework |
3409 | # HACK to clear player env face cache, we need some signal framework |
3365 | # for this (global event?) |
3410 | # for this (global event?) |
… | |
… | |
3588 | |
3633 | |
3589 | sub main { |
3634 | sub main { |
3590 | cf::init_globals; # initialise logging |
3635 | cf::init_globals; # initialise logging |
3591 | |
3636 | |
3592 | LOG llevInfo, "Welcome to Deliantra, v" . VERSION; |
3637 | LOG llevInfo, "Welcome to Deliantra, v" . VERSION; |
3593 | LOG llevInfo, "Copyright (C) 2005-2008 Marc Alexander Lehmann / Robin Redeker / the Deliantra team."; |
3638 | LOG llevInfo, "Copyright (C) 2005-2010 Marc Alexander Lehmann / Robin Redeker / the Deliantra team."; |
3594 | LOG llevInfo, "Copyright (C) 1994 Mark Wedel."; |
3639 | LOG llevInfo, "Copyright (C) 1994 Mark Wedel."; |
3595 | LOG llevInfo, "Copyright (C) 1992 Frank Tore Johansen."; |
3640 | LOG llevInfo, "Copyright (C) 1992 Frank Tore Johansen."; |
3596 | |
3641 | |
3597 | $Coro::current->prio (Coro::PRIO_MAX); # give the main loop max. priority |
3642 | $Coro::current->prio (Coro::PRIO_MAX); # give the main loop max. priority |
3598 | |
3643 | |
… | |
… | |
3606 | }; |
3651 | }; |
3607 | |
3652 | |
3608 | evthread_start IO::AIO::poll_fileno; |
3653 | evthread_start IO::AIO::poll_fileno; |
3609 | |
3654 | |
3610 | cf::sync_job { |
3655 | cf::sync_job { |
|
|
3656 | init_inc; |
|
|
3657 | |
3611 | cf::init_experience; |
3658 | cf::init_experience; |
3612 | cf::init_anim; |
3659 | cf::init_anim; |
3613 | cf::init_attackmess; |
3660 | cf::init_attackmess; |
3614 | cf::init_dynamic; |
3661 | cf::init_dynamic; |
3615 | |
3662 | |
… | |
… | |
3640 | }; |
3687 | }; |
3641 | |
3688 | |
3642 | cf::object::thawer::errors_are_fatal 0; |
3689 | cf::object::thawer::errors_are_fatal 0; |
3643 | info "parse errors in files are no longer fatal from this point on.\n"; |
3690 | info "parse errors in files are no longer fatal from this point on.\n"; |
3644 | |
3691 | |
|
|
3692 | my $free_main; $free_main = EV::idle sub { |
|
|
3693 | undef $free_main; |
|
|
3694 | undef &main; # free gobs of memory :) |
|
|
3695 | }; |
|
|
3696 | |
3645 | main_loop; |
3697 | goto &main_loop; |
3646 | } |
3698 | } |
3647 | |
3699 | |
3648 | ############################################################################# |
3700 | ############################################################################# |
3649 | # initialisation and cleanup |
3701 | # initialisation and cleanup |
3650 | |
3702 | |
… | |
… | |
3991 | reload_perl; |
4043 | reload_perl; |
3992 | }; |
4044 | }; |
3993 | } |
4045 | } |
3994 | }; |
4046 | }; |
3995 | |
4047 | |
3996 | unshift @INC, $LIBDIR; |
4048 | ############################################################################# |
3997 | |
4049 | |
3998 | my $bug_warning = 0; |
4050 | my $bug_warning = 0; |
3999 | |
4051 | |
4000 | our @WAIT_FOR_TICK; |
4052 | our @WAIT_FOR_TICK; |
4001 | our @WAIT_FOR_TICK_BEGIN; |
4053 | our @WAIT_FOR_TICK_BEGIN; |