… | |
… | |
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 | Compress::LZF::sfreeze_cr { }; # prime Compress::LZF so it does not use require later |
|
|
69 | |
68 | |
70 | $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 | |
|
|
71 | { |
|
|
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"; |
|
|
85 | Compress::LZF::sfreeze_cr { }; # prime Compress::LZF so it does not use require later |
|
|
86 | } |
71 | |
87 | |
72 | sub WF_AUTOCANCEL () { 1 } # automatically cancel this watcher on reload |
88 | sub WF_AUTOCANCEL () { 1 } # automatically cancel this watcher on reload |
73 | |
89 | |
74 | our %COMMAND = (); |
90 | our %COMMAND = (); |
75 | our %COMMAND_TIME = (); |
91 | our %COMMAND_TIME = (); |
… | |
… | |
730 | |
746 | |
731 | ############################################################################# |
747 | ############################################################################# |
732 | |
748 | |
733 | =head2 ATTACHABLE OBJECTS |
749 | =head2 ATTACHABLE OBJECTS |
734 | |
750 | |
735 | Many objects in crossfire are so-called attachable objects. That means you can |
751 | 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") |
752 | attach callbacks/event handlers (a collection of which is called an "attachment") |
737 | to it. All such attachable objects support the following methods. |
753 | to it. All such attachable objects support the following methods. |
738 | |
754 | |
739 | In the following description, CLASS can be any of C<global>, C<object> |
755 | 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 |
756 | C<player>, C<client> or C<map> (i.e. the attachable objects in |
… | |
… | |
790 | =item cf::CLASS::attachment $name, ... |
806 | =item cf::CLASS::attachment $name, ... |
791 | |
807 | |
792 | Register an attachment by C<$name> through which attachable objects of the |
808 | Register an attachment by C<$name> through which attachable objects of the |
793 | given CLASS can refer to this attachment. |
809 | given CLASS can refer to this attachment. |
794 | |
810 | |
795 | Some classes such as crossfire maps and objects can specify attachments |
811 | 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. |
812 | that are attached at load/instantiate time, thus the need for a name. |
797 | |
813 | |
798 | These calls expect any number of the following handler/hook descriptions: |
814 | These calls expect any number of the following handler/hook descriptions: |
799 | |
815 | |
800 | =over 4 |
816 | =over 4 |
… | |
… | |
1388 | |
1404 | |
1389 | =back |
1405 | =back |
1390 | |
1406 | |
1391 | =head2 CORE EXTENSIONS |
1407 | =head2 CORE EXTENSIONS |
1392 | |
1408 | |
1393 | Functions and methods that extend core crossfire objects. |
1409 | Functions and methods that extend core deliantra objects. |
1394 | |
1410 | |
1395 | =cut |
1411 | =cut |
1396 | |
1412 | |
1397 | package cf::player; |
1413 | package cf::player; |
1398 | |
1414 | |
… | |
… | |
1622 | } |
1638 | } |
1623 | |
1639 | |
1624 | \@paths |
1640 | \@paths |
1625 | } |
1641 | } |
1626 | |
1642 | |
1627 | =item $protocol_xml = $player->expand_cfpod ($crossfire_pod) |
1643 | =item $protocol_xml = $player->expand_cfpod ($cfpod) |
1628 | |
1644 | |
1629 | Expand crossfire pod fragments into protocol xml. |
1645 | Expand deliantra pod fragments into protocol xml. |
1630 | |
1646 | |
1631 | =item $player->ext_reply ($msgid, @msg) |
1647 | =item $player->ext_reply ($msgid, @msg) |
1632 | |
1648 | |
1633 | Sends an ext reply to the player. |
1649 | Sends an ext reply to the player. |
1634 | |
1650 | |
… | |
… | |
2692 | $self->contr->savebed ($map, $x, $y) |
2708 | $self->contr->savebed ($map, $x, $y) |
2693 | if $exit->flag (cf::FLAG_DAMNED); |
2709 | if $exit->flag (cf::FLAG_DAMNED); |
2694 | |
2710 | |
2695 | 1 |
2711 | 1 |
2696 | }) { |
2712 | }) { |
2697 | $self->message ("Something went wrong deep within the crossfire server. " |
2713 | $self->message ("Something went wrong deep within the deliantra server. " |
2698 | . "I'll try to bring you back to the map you were before. " |
2714 | . "I'll try to bring you back to the map you were before. " |
2699 | . "Please report this to the dungeon master!", |
2715 | . "Please report this to the dungeon master!", |
2700 | cf::NDI_UNIQUE | cf::NDI_RED); |
2716 | cf::NDI_UNIQUE | cf::NDI_RED); |
2701 | |
2717 | |
2702 | warn "ERROR in enter_exit: $@"; |
2718 | warn "ERROR in enter_exit: $@"; |
… | |
… | |
2791 | ); |
2807 | ); |
2792 | |
2808 | |
2793 | sub cf::client::send_msg { |
2809 | sub cf::client::send_msg { |
2794 | my ($self, $channel, $msg, $color, @extra) = @_; |
2810 | my ($self, $channel, $msg, $color, @extra) = @_; |
2795 | |
2811 | |
2796 | $msg = $self->pl->expand_cfpod ($msg); |
2812 | $msg = $self->pl->expand_cfpod ($msg) |
|
|
2813 | unless $color & cf::NDI_VERBATIM; |
2797 | |
2814 | |
2798 | $color &= cf::NDI_CLIENT_MASK; # just in case... |
2815 | $color &= cf::NDI_CLIENT_MASK; # just in case... |
2799 | |
2816 | |
2800 | # check predefined channels, for the benefit of C |
2817 | # check predefined channels, for the benefit of C |
2801 | if ($CHANNEL{$channel}) { |
2818 | if ($CHANNEL{$channel}) { |