… | |
… | |
63 | |
63 | |
64 | # configure various modules to our taste |
64 | # configure various modules to our taste |
65 | # |
65 | # |
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 | |
|
|
69 | $Coro::main->prio (Coro::PRIO_MAX); # run main coroutine ("the server") with very high priority |
|
|
70 | |
|
|
71 | # make sure c-lzf reinitialises itself |
|
|
72 | Compress::LZF::set_serializer "Storable", "Storable::net_mstore", "Storable::mretrieve"; |
68 | 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 |
69 | |
|
|
70 | $Coro::main->prio (Coro::PRIO_MAX); # run main coroutine ("the server") with very high priority |
|
|
71 | |
74 | |
72 | sub WF_AUTOCANCEL () { 1 } # automatically cancel this watcher on reload |
75 | sub WF_AUTOCANCEL () { 1 } # automatically cancel this watcher on reload |
73 | |
76 | |
74 | our %COMMAND = (); |
77 | our %COMMAND = (); |
75 | our %COMMAND_TIME = (); |
78 | our %COMMAND_TIME = (); |
… | |
… | |
730 | |
733 | |
731 | ############################################################################# |
734 | ############################################################################# |
732 | |
735 | |
733 | =head2 ATTACHABLE OBJECTS |
736 | =head2 ATTACHABLE OBJECTS |
734 | |
737 | |
735 | Many objects in crossfire are so-called attachable objects. That means you can |
738 | Many objects in deliantra are so-called attachable objects. That means you can |
736 | attach callbacks/event handlers (a collection of which is called an "attachment") |
739 | attach callbacks/event handlers (a collection of which is called an "attachment") |
737 | to it. All such attachable objects support the following methods. |
740 | to it. All such attachable objects support the following methods. |
738 | |
741 | |
739 | In the following description, CLASS can be any of C<global>, C<object> |
742 | In the following description, CLASS can be any of C<global>, C<object> |
740 | C<player>, C<client> or C<map> (i.e. the attachable objects in |
743 | C<player>, C<client> or C<map> (i.e. the attachable objects in |
… | |
… | |
790 | =item cf::CLASS::attachment $name, ... |
793 | =item cf::CLASS::attachment $name, ... |
791 | |
794 | |
792 | Register an attachment by C<$name> through which attachable objects of the |
795 | Register an attachment by C<$name> through which attachable objects of the |
793 | given CLASS can refer to this attachment. |
796 | given CLASS can refer to this attachment. |
794 | |
797 | |
795 | Some classes such as crossfire maps and objects can specify attachments |
798 | Some classes such as deliantra maps and objects can specify attachments |
796 | that are attached at load/instantiate time, thus the need for a name. |
799 | that are attached at load/instantiate time, thus the need for a name. |
797 | |
800 | |
798 | These calls expect any number of the following handler/hook descriptions: |
801 | These calls expect any number of the following handler/hook descriptions: |
799 | |
802 | |
800 | =over 4 |
803 | =over 4 |
… | |
… | |
1388 | |
1391 | |
1389 | =back |
1392 | =back |
1390 | |
1393 | |
1391 | =head2 CORE EXTENSIONS |
1394 | =head2 CORE EXTENSIONS |
1392 | |
1395 | |
1393 | Functions and methods that extend core crossfire objects. |
1396 | Functions and methods that extend core deliantra objects. |
1394 | |
1397 | |
1395 | =cut |
1398 | =cut |
1396 | |
1399 | |
1397 | package cf::player; |
1400 | package cf::player; |
1398 | |
1401 | |
… | |
… | |
1622 | } |
1625 | } |
1623 | |
1626 | |
1624 | \@paths |
1627 | \@paths |
1625 | } |
1628 | } |
1626 | |
1629 | |
1627 | =item $protocol_xml = $player->expand_cfpod ($crossfire_pod) |
1630 | =item $protocol_xml = $player->expand_cfpod ($cfpod) |
1628 | |
1631 | |
1629 | Expand crossfire pod fragments into protocol xml. |
1632 | Expand deliantra pod fragments into protocol xml. |
1630 | |
1633 | |
1631 | =item $player->ext_reply ($msgid, @msg) |
1634 | =item $player->ext_reply ($msgid, @msg) |
1632 | |
1635 | |
1633 | Sends an ext reply to the player. |
1636 | Sends an ext reply to the player. |
1634 | |
1637 | |
… | |
… | |
2448 | |
2451 | |
2449 | =item $player_object->enter_link |
2452 | =item $player_object->enter_link |
2450 | |
2453 | |
2451 | Freezes the player and moves him/her to a special map (C<{link}>). |
2454 | Freezes the player and moves him/her to a special map (C<{link}>). |
2452 | |
2455 | |
2453 | The player should be reasonably safe there for short amounts of time. You |
2456 | The player should be reasonably safe there for short amounts of time (e.g. |
2454 | I<MUST> call C<leave_link> as soon as possible, though. |
2457 | for loading a map). You I<MUST> call C<leave_link> as soon as possible, |
|
|
2458 | though, as the palyer cannot control the character while it is on the link |
|
|
2459 | map. |
2455 | |
2460 | |
2456 | Will never block. |
2461 | Will never block. |
2457 | |
2462 | |
2458 | =item $player_object->leave_link ($map, $x, $y) |
2463 | =item $player_object->leave_link ($map, $x, $y) |
2459 | |
2464 | |
… | |
… | |
2517 | |
2522 | |
2518 | $map->load; |
2523 | $map->load; |
2519 | $map->load_neighbours; |
2524 | $map->load_neighbours; |
2520 | |
2525 | |
2521 | return unless $self->contr->active; |
2526 | return unless $self->contr->active; |
|
|
2527 | $self->flag (cf::FLAG_DEBUG, 0);#d# temp |
2522 | $self->activate_recursive; |
2528 | $self->activate_recursive; |
2523 | |
2529 | |
2524 | local $self->{_prev_pos} = $link_pos; # ugly hack for rent.ext |
2530 | local $self->{_prev_pos} = $link_pos; # ugly hack for rent.ext |
2525 | $self->enter_map ($map, $x, $y); |
2531 | $self->enter_map ($map, $x, $y); |
2526 | } |
2532 | } |
… | |
… | |
2689 | $self->contr->savebed ($map, $x, $y) |
2695 | $self->contr->savebed ($map, $x, $y) |
2690 | if $exit->flag (cf::FLAG_DAMNED); |
2696 | if $exit->flag (cf::FLAG_DAMNED); |
2691 | |
2697 | |
2692 | 1 |
2698 | 1 |
2693 | }) { |
2699 | }) { |
2694 | $self->message ("Something went wrong deep within the crossfire server. " |
2700 | $self->message ("Something went wrong deep within the deliantra server. " |
2695 | . "I'll try to bring you back to the map you were before. " |
2701 | . "I'll try to bring you back to the map you were before. " |
2696 | . "Please report this to the dungeon master!", |
2702 | . "Please report this to the dungeon master!", |
2697 | cf::NDI_UNIQUE | cf::NDI_RED); |
2703 | cf::NDI_UNIQUE | cf::NDI_RED); |
2698 | |
2704 | |
2699 | warn "ERROR in enter_exit: $@"; |
2705 | warn "ERROR in enter_exit: $@"; |
… | |
… | |
2788 | ); |
2794 | ); |
2789 | |
2795 | |
2790 | sub cf::client::send_msg { |
2796 | sub cf::client::send_msg { |
2791 | my ($self, $channel, $msg, $color, @extra) = @_; |
2797 | my ($self, $channel, $msg, $color, @extra) = @_; |
2792 | |
2798 | |
2793 | $msg = $self->pl->expand_cfpod ($msg); |
2799 | $msg = $self->pl->expand_cfpod ($msg) |
|
|
2800 | unless $color & cf::NDI_VERBATIM; |
2794 | |
2801 | |
2795 | $color &= cf::NDI_CLIENT_MASK; # just in case... |
2802 | $color &= cf::NDI_CLIENT_MASK; # just in case... |
2796 | |
2803 | |
2797 | # check predefined channels, for the benefit of C |
2804 | # check predefined channels, for the benefit of C |
2798 | if ($CHANNEL{$channel}) { |
2805 | if ($CHANNEL{$channel}) { |
… | |
… | |
3832 | $msg =~ s/\n//; |
3839 | $msg =~ s/\n//; |
3833 | |
3840 | |
3834 | # limit the # of concurrent backtraces |
3841 | # limit the # of concurrent backtraces |
3835 | if ($_log_backtrace < 2) { |
3842 | if ($_log_backtrace < 2) { |
3836 | ++$_log_backtrace; |
3843 | ++$_log_backtrace; |
|
|
3844 | my $perl_bt = Carp::longmess $msg; |
3837 | async { |
3845 | async { |
3838 | $Coro::current->{desc} = "abt $msg"; |
3846 | $Coro::current->{desc} = "abt $msg"; |
3839 | |
3847 | |
3840 | my @bt = fork_call { |
3848 | my @bt = fork_call { |
3841 | @addr = map { sprintf "%x", $_ } @addr; |
3849 | @addr = map { sprintf "%x", $_ } @addr; |
… | |
… | |
3852 | } |
3860 | } |
3853 | |
3861 | |
3854 | @funcs |
3862 | @funcs |
3855 | }; |
3863 | }; |
3856 | |
3864 | |
3857 | LOG llevInfo, "[ABT] $msg\n"; |
3865 | LOG llevInfo, "[ABT] $perl_bt\n"; |
|
|
3866 | LOG llevInfo, "[ABT] --- C backtrace follows ---\n"; |
3858 | LOG llevInfo, "[ABT] $_\n" for @bt; |
3867 | LOG llevInfo, "[ABT] $_\n" for @bt; |
3859 | --$_log_backtrace; |
3868 | --$_log_backtrace; |
3860 | }; |
3869 | }; |
3861 | } else { |
3870 | } else { |
3862 | LOG llevInfo, "[ABT] $msg\n"; |
3871 | LOG llevInfo, "[ABT] $msg\n"; |