… | |
… | |
66 | $Storable::canonical = 1; # reduce rsync transfers |
66 | $Storable::canonical = 1; # reduce rsync transfers |
67 | Coro::State::cctx_stacksize 256000; # 1-2MB stack, for deep recursions in maze generator |
67 | Coro::State::cctx_stacksize 256000; # 1-2MB stack, for deep recursions in maze generator |
68 | |
68 | |
69 | $Coro::main->prio (Coro::PRIO_MAX); # run main coroutine ("the server") with very high priority |
69 | $Coro::main->prio (Coro::PRIO_MAX); # run main coroutine ("the server") with very high priority |
70 | |
70 | |
71 | { |
71 | # make sure c-lzf reinitialises itself |
72 | # very ugly, but ensure we acquire the storable lock |
|
|
73 | |
|
|
74 | sub net_mstore { |
|
|
75 | my $guard = Coro::Storable::guard; |
|
|
76 | &Storable::net_mstore |
|
|
77 | } |
|
|
78 | |
|
|
79 | sub mretrieve { |
|
|
80 | my $guard = Coro::Storable::guard; |
|
|
81 | &Storable::mretrieve |
|
|
82 | } |
|
|
83 | |
|
|
84 | Compress::LZF::set_serializer "Coro::Storable", "cf::net_mstore", "cf::mretrieve"; |
72 | Compress::LZF::set_serializer "Storable", "Storable::net_mstore", "Storable::mretrieve"; |
85 | Compress::LZF::sfreeze_cr { }; # prime Compress::LZF so it does not use require later |
73 | Compress::LZF::sfreeze_cr { }; # prime Compress::LZF so it does not use require later |
86 | } |
|
|
87 | |
74 | |
88 | sub WF_AUTOCANCEL () { 1 } # automatically cancel this watcher on reload |
75 | sub WF_AUTOCANCEL () { 1 } # automatically cancel this watcher on reload |
89 | |
76 | |
90 | our %COMMAND = (); |
77 | our %COMMAND = (); |
91 | our %COMMAND_TIME = (); |
78 | our %COMMAND_TIME = (); |
… | |
… | |
94 | our %EXTCMD = (); |
81 | our %EXTCMD = (); |
95 | our %EXTICMD = (); |
82 | our %EXTICMD = (); |
96 | our %EXT_CORO = (); # coroutines bound to extensions |
83 | our %EXT_CORO = (); # coroutines bound to extensions |
97 | our %EXT_MAP = (); # pluggable maps |
84 | our %EXT_MAP = (); # pluggable maps |
98 | |
85 | |
99 | our $RELOAD; # number of reloads so far |
86 | our $RELOAD; # number of reloads so far, non-zero while in reload |
100 | our @EVENT; |
87 | our @EVENT; |
101 | |
88 | |
102 | our $CONFDIR = confdir; |
89 | our $CONFDIR = confdir; |
103 | our $DATADIR = datadir; |
90 | our $DATADIR = datadir; |
104 | our $LIBDIR = "$DATADIR/ext"; |
91 | our $LIBDIR = "$DATADIR/ext"; |
… | |
… | |
354 | return;#d# |
341 | return;#d# |
355 | }#d# |
342 | }#d# |
356 | |
343 | |
357 | # wait for lock, if any |
344 | # wait for lock, if any |
358 | while ($LOCK{$key}) { |
345 | while ($LOCK{$key}) { |
|
|
346 | #local $Coro::current->{desc} = "$Coro::current->{desc} <waiting for lock $key>"; |
359 | push @{ $LOCK{$key} }, $Coro::current; |
347 | push @{ $LOCK{$key} }, $Coro::current; |
360 | Coro::schedule; |
348 | Coro::schedule; |
361 | } |
349 | } |
362 | } |
350 | } |
363 | |
351 | |
… | |
… | |
1457 | |
1445 | |
1458 | sub exists($) { |
1446 | sub exists($) { |
1459 | my ($login) = @_; |
1447 | my ($login) = @_; |
1460 | |
1448 | |
1461 | $cf::PLAYER{$login} |
1449 | $cf::PLAYER{$login} |
1462 | or cf::sync_job { !aio_stat path $login } |
1450 | or !aio_stat path $login |
1463 | } |
1451 | } |
1464 | |
1452 | |
1465 | sub find($) { |
1453 | sub find($) { |
1466 | return $cf::PLAYER{$_[0]} || do { |
1454 | return $cf::PLAYER{$_[0]} || do { |
1467 | my $login = $_[0]; |
1455 | my $login = $_[0]; |
… | |
… | |
2784 | id => "infobox", |
2772 | id => "infobox", |
2785 | title => "Body Parts", |
2773 | title => "Body Parts", |
2786 | reply => undef, |
2774 | reply => undef, |
2787 | tooltip => "Shows which body parts you posess and are available", |
2775 | tooltip => "Shows which body parts you posess and are available", |
2788 | }, |
2776 | }, |
|
|
2777 | "c/skills" => { |
|
|
2778 | id => "infobox", |
|
|
2779 | title => "Skills", |
|
|
2780 | reply => undef, |
|
|
2781 | tooltip => "Shows your experience per skill and item power", |
|
|
2782 | }, |
2789 | "c/uptime" => { |
2783 | "c/uptime" => { |
2790 | id => "infobox", |
2784 | id => "infobox", |
2791 | title => "Uptime", |
2785 | title => "Uptime", |
2792 | reply => undef, |
2786 | reply => undef, |
2793 | tooltip => "How long the server has been running since last restart", |
2787 | tooltip => "How long the server has been running since last restart", |
… | |
… | |
3587 | my $leaf_symtab = *{$stem_symtab->{$leaf}}{HASH}; |
3581 | my $leaf_symtab = *{$stem_symtab->{$leaf}}{HASH}; |
3588 | for my $name (keys %$leaf_symtab) { |
3582 | for my $name (keys %$leaf_symtab) { |
3589 | _gv_clear *{"$pkg$name"}; |
3583 | _gv_clear *{"$pkg$name"}; |
3590 | # use PApp::Util; PApp::Util::sv_dump *{"$pkg$name"}; |
3584 | # use PApp::Util; PApp::Util::sv_dump *{"$pkg$name"}; |
3591 | } |
3585 | } |
3592 | warn "cleared package #$pkg\n";#d# |
3586 | warn "cleared package $pkg\n";#d# |
3593 | } |
3587 | } |
3594 | |
|
|
3595 | our $RELOAD; # how many times to reload |
|
|
3596 | |
3588 | |
3597 | sub do_reload_perl() { |
3589 | sub do_reload_perl() { |
3598 | # can/must only be called in main |
3590 | # can/must only be called in main |
3599 | if ($Coro::current != $Coro::main) { |
3591 | if ($Coro::current != $Coro::main) { |
3600 | warn "can only reload from main coroutine"; |
3592 | warn "can only reload from main coroutine"; |
… | |
… | |
3714 | |
3706 | |
3715 | sub reload_perl() { |
3707 | sub reload_perl() { |
3716 | # doing reload synchronously and two reloads happen back-to-back, |
3708 | # doing reload synchronously and two reloads happen back-to-back, |
3717 | # coro crashes during coro_state_free->destroy here. |
3709 | # coro crashes during coro_state_free->destroy here. |
3718 | |
3710 | |
3719 | $RELOAD_WATCHER ||= EV::timer 0, 0, sub { |
3711 | $RELOAD_WATCHER ||= EV::timer $TICK * 1.5, 0, sub { |
3720 | do_reload_perl; |
3712 | do_reload_perl; |
3721 | undef $RELOAD_WATCHER; |
3713 | undef $RELOAD_WATCHER; |
3722 | }; |
3714 | }; |
3723 | } |
3715 | } |
3724 | |
3716 | |