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.445 by root, Wed Sep 10 18:18:10 2008 UTC vs.
Revision 1.448 by root, Fri Sep 19 05:30:23 2008 UTC

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
67Coro::State::cctx_stacksize 256000; # 1-2MB stack, for deep recursions in maze generator 67Coro::State::cctx_stacksize 256000; # 1-2MB stack, for deep recursions in maze generator
68Compress::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
72sub WF_AUTOCANCEL () { 1 } # automatically cancel this watcher on reload 88sub WF_AUTOCANCEL () { 1 } # automatically cancel this watcher on reload
73 89
74our %COMMAND = (); 90our %COMMAND = ();
75our %COMMAND_TIME = (); 91our %COMMAND_TIME = ();
730 746
731############################################################################# 747#############################################################################
732 748
733=head2 ATTACHABLE OBJECTS 749=head2 ATTACHABLE OBJECTS
734 750
735Many objects in crossfire are so-called attachable objects. That means you can 751Many objects in deliantra are so-called attachable objects. That means you can
736attach callbacks/event handlers (a collection of which is called an "attachment") 752attach callbacks/event handlers (a collection of which is called an "attachment")
737to it. All such attachable objects support the following methods. 753to it. All such attachable objects support the following methods.
738 754
739In the following description, CLASS can be any of C<global>, C<object> 755In the following description, CLASS can be any of C<global>, C<object>
740C<player>, C<client> or C<map> (i.e. the attachable objects in 756C<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
792Register an attachment by C<$name> through which attachable objects of the 808Register an attachment by C<$name> through which attachable objects of the
793given CLASS can refer to this attachment. 809given CLASS can refer to this attachment.
794 810
795Some classes such as crossfire maps and objects can specify attachments 811Some classes such as deliantra maps and objects can specify attachments
796that are attached at load/instantiate time, thus the need for a name. 812that are attached at load/instantiate time, thus the need for a name.
797 813
798These calls expect any number of the following handler/hook descriptions: 814These 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
1393Functions and methods that extend core crossfire objects. 1409Functions and methods that extend core deliantra objects.
1394 1410
1395=cut 1411=cut
1396 1412
1397package cf::player; 1413package 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
1629Expand crossfire pod fragments into protocol xml. 1645Expand deliantra pod fragments into protocol xml.
1630 1646
1631=item $player->ext_reply ($msgid, @msg) 1647=item $player->ext_reply ($msgid, @msg)
1632 1648
1633Sends an ext reply to the player. 1649Sends an ext reply to the player.
1634 1650
2448 2464
2449=item $player_object->enter_link 2465=item $player_object->enter_link
2450 2466
2451Freezes the player and moves him/her to a special map (C<{link}>). 2467Freezes the player and moves him/her to a special map (C<{link}>).
2452 2468
2453The player should be reasonably safe there for short amounts of time. You 2469The player should be reasonably safe there for short amounts of time (e.g.
2454I<MUST> call C<leave_link> as soon as possible, though. 2470for loading a map). You I<MUST> call C<leave_link> as soon as possible,
2471though, as the palyer cannot control the character while it is on the link
2472map.
2455 2473
2456Will never block. 2474Will never block.
2457 2475
2458=item $player_object->leave_link ($map, $x, $y) 2476=item $player_object->leave_link ($map, $x, $y)
2459 2477
2517 2535
2518 $map->load; 2536 $map->load;
2519 $map->load_neighbours; 2537 $map->load_neighbours;
2520 2538
2521 return unless $self->contr->active; 2539 return unless $self->contr->active;
2540 $self->flag (cf::FLAG_DEBUG, 0);#d# temp
2522 $self->activate_recursive; 2541 $self->activate_recursive;
2523 2542
2524 local $self->{_prev_pos} = $link_pos; # ugly hack for rent.ext 2543 local $self->{_prev_pos} = $link_pos; # ugly hack for rent.ext
2525 $self->enter_map ($map, $x, $y); 2544 $self->enter_map ($map, $x, $y);
2526} 2545}
2689 $self->contr->savebed ($map, $x, $y) 2708 $self->contr->savebed ($map, $x, $y)
2690 if $exit->flag (cf::FLAG_DAMNED); 2709 if $exit->flag (cf::FLAG_DAMNED);
2691 2710
2692 1 2711 1
2693 }) { 2712 }) {
2694 $self->message ("Something went wrong deep within the crossfire server. " 2713 $self->message ("Something went wrong deep within the deliantra server. "
2695 . "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. "
2696 . "Please report this to the dungeon master!", 2715 . "Please report this to the dungeon master!",
2697 cf::NDI_UNIQUE | cf::NDI_RED); 2716 cf::NDI_UNIQUE | cf::NDI_RED);
2698 2717
2699 warn "ERROR in enter_exit: $@"; 2718 warn "ERROR in enter_exit: $@";
2788); 2807);
2789 2808
2790sub cf::client::send_msg { 2809sub cf::client::send_msg {
2791 my ($self, $channel, $msg, $color, @extra) = @_; 2810 my ($self, $channel, $msg, $color, @extra) = @_;
2792 2811
2793 $msg = $self->pl->expand_cfpod ($msg); 2812 $msg = $self->pl->expand_cfpod ($msg)
2813 unless $color & cf::NDI_VERBATIM;
2794 2814
2795 $color &= cf::NDI_CLIENT_MASK; # just in case... 2815 $color &= cf::NDI_CLIENT_MASK; # just in case...
2796 2816
2797 # check predefined channels, for the benefit of C 2817 # check predefined channels, for the benefit of C
2798 if ($CHANNEL{$channel}) { 2818 if ($CHANNEL{$channel}) {
3832 $msg =~ s/\n//; 3852 $msg =~ s/\n//;
3833 3853
3834 # limit the # of concurrent backtraces 3854 # limit the # of concurrent backtraces
3835 if ($_log_backtrace < 2) { 3855 if ($_log_backtrace < 2) {
3836 ++$_log_backtrace; 3856 ++$_log_backtrace;
3857 my $perl_bt = Carp::longmess $msg;
3837 async { 3858 async {
3838 $Coro::current->{desc} = "abt $msg"; 3859 $Coro::current->{desc} = "abt $msg";
3839 3860
3840 my @bt = fork_call { 3861 my @bt = fork_call {
3841 @addr = map { sprintf "%x", $_ } @addr; 3862 @addr = map { sprintf "%x", $_ } @addr;
3852 } 3873 }
3853 3874
3854 @funcs 3875 @funcs
3855 }; 3876 };
3856 3877
3857 LOG llevInfo, "[ABT] $msg\n"; 3878 LOG llevInfo, "[ABT] $perl_bt\n";
3879 LOG llevInfo, "[ABT] --- C backtrace follows ---\n";
3858 LOG llevInfo, "[ABT] $_\n" for @bt; 3880 LOG llevInfo, "[ABT] $_\n" for @bt;
3859 --$_log_backtrace; 3881 --$_log_backtrace;
3860 }; 3882 };
3861 } else { 3883 } else {
3862 LOG llevInfo, "[ABT] $msg\n"; 3884 LOG llevInfo, "[ABT] $msg\n";

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines