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.462 by root, Tue Dec 23 06:58:23 2008 UTC vs.
Revision 1.465 by root, Thu Jan 8 00:54:55 2009 UTC

2769 id => "infobox", 2769 id => "infobox",
2770 title => "Body Parts", 2770 title => "Body Parts",
2771 reply => undef, 2771 reply => undef,
2772 tooltip => "Shows which body parts you posess and are available", 2772 tooltip => "Shows which body parts you posess and are available",
2773 }, 2773 },
2774 "c/statistics" => {
2775 id => "infobox",
2776 title => "Statistics",
2777 reply => undef,
2778 tooltip => "Shows your primary statistics",
2779 },
2774 "c/skills" => { 2780 "c/skills" => {
2775 id => "infobox", 2781 id => "infobox",
2776 title => "Skills", 2782 title => "Skills",
2777 reply => undef, 2783 reply => undef,
2778 tooltip => "Shows your experience per skill and item power", 2784 tooltip => "Shows your experience per skill and item power",
2785 },
2786 "c/resistances" => {
2787 id => "infobox",
2788 title => "Resistances",
2789 reply => undef,
2790 tooltip => "Shows your resistances",
2791 },
2792 "c/pets" => {
2793 id => "infobox",
2794 title => "Pets",
2795 reply => undef,
2796 tooltip => "Shows information abotu your pets/a specific pet",
2779 }, 2797 },
2780 "c/uptime" => { 2798 "c/uptime" => {
2781 id => "infobox", 2799 id => "infobox",
2782 title => "Uptime", 2800 title => "Uptime",
2783 reply => undef, 2801 reply => undef,
2793 id => "party", 2811 id => "party",
2794 title => "Party", 2812 title => "Party",
2795 reply => "gsay ", 2813 reply => "gsay ",
2796 tooltip => "Messages and chat related to your party", 2814 tooltip => "Messages and chat related to your party",
2797 }, 2815 },
2816 "c/death" => {
2817 id => "death",
2818 title => "Death",
2819 reply => undef,
2820 tooltip => "Reason for and more info about your most recent death",
2821 },
2798 "c/say" => $SAY_CHANNEL, 2822 "c/say" => $SAY_CHANNEL,
2799 "c/chat" => $CHAT_CHANNEL, 2823 "c/chat" => $CHAT_CHANNEL,
2800); 2824);
2801 2825
2802sub cf::client::send_msg { 2826sub cf::client::send_msg {
2809 2833
2810 # check predefined channels, for the benefit of C 2834 # check predefined channels, for the benefit of C
2811 if ($CHANNEL{$channel}) { 2835 if ($CHANNEL{$channel}) {
2812 $channel = $CHANNEL{$channel}; 2836 $channel = $CHANNEL{$channel};
2813 2837
2814 $self->ext_msg (channel_info => $channel) 2838 $self->ext_msg (channel_info => $channel);
2815 if $self->can_msg;
2816
2817 $channel = $channel->{id}; 2839 $channel = $channel->{id};
2818 2840
2819 } elsif (ref $channel) { 2841 } elsif (ref $channel) {
2820 # send meta info to client, if not yet sent 2842 # send meta info to client, if not yet sent
2821 unless (exists $self->{channel}{$channel->{id}}) { 2843 unless (exists $self->{channel}{$channel->{id}}) {
2822 $self->{channel}{$channel->{id}} = $channel; 2844 $self->{channel}{$channel->{id}} = $channel;
2823 $self->ext_msg (channel_info => $channel) 2845 $self->ext_msg (channel_info => $channel);
2824 if $self->can_msg;
2825 } 2846 }
2826 2847
2827 $channel = $channel->{id}; 2848 $channel = $channel->{id};
2828 } 2849 }
2829 2850
2830 return unless @extra || length $msg; 2851 return unless @extra || length $msg;
2831 2852
2832 if ($self->can_msg) {
2833 # default colour, mask it out 2853 # default colour, mask it out
2834 $color &= ~(cf::NDI_COLOR_MASK | cf::NDI_DEF) 2854 $color &= ~(cf::NDI_COLOR_MASK | cf::NDI_DEF)
2835 if $color & cf::NDI_DEF; 2855 if $color & cf::NDI_DEF;
2836 2856
2837 my $pkt = "msg " 2857 my $pkt = "msg "
2838 . $self->{json_coder}->encode ( 2858 . $self->{json_coder}->encode (
2839 [$color & cf::NDI_CLIENT_MASK, $channel, $msg, @extra] 2859 [$color & cf::NDI_CLIENT_MASK, $channel, $msg, @extra]
2840 ); 2860 );
2841 2861
2842 # try lzf for large packets 2862 # try lzf for large packets
2843 $pkt = "lzf " . Compress::LZF::compress $pkt 2863 $pkt = "lzf " . Compress::LZF::compress $pkt
2844 if 1024 <= length $pkt and $self->{can_lzf}; 2864 if 1024 <= length $pkt and $self->{can_lzf};
2845 2865
2846 # split very large packets 2866 # split very large packets
2847 if (8192 < length $pkt and $self->{can_lzf}) { 2867 if (8192 < length $pkt and $self->{can_lzf}) {
2848 $self->send_packet ("frag $_") for unpack "(a8192)*", $pkt; 2868 $self->send_packet ("frag $_") for unpack "(a8192)*", $pkt;
2849 $pkt = "frag"; 2869 $pkt = "frag";
2850 } 2870 }
2851 2871
2852 $self->send_packet ($pkt); 2872 $self->send_packet ($pkt);
2853 } else {
2854 if ($color >= 0) {
2855 # replace some tags by gcfclient-compatible ones
2856 for ($msg) {
2857 1 while
2858 s/<b>([^<]*)<\/b>/[b]${1}[\/b]/
2859 || s/<i>([^<]*)<\/i>/[i]${1}[\/i]/
2860 || s/<u>([^<]*)<\/u>/[ul]${1}[\/ul]/
2861 || s/<tt>([^<]*)<\/tt>/[fixed]${1}[\/fixed]/
2862 || s/<fg name=\"([^"]+)\">([^<]*)<\/fg>/[color=$1]${2}[\/color]/;
2863 }
2864
2865 $color &= cf::NDI_COLOR_MASK;
2866
2867 utf8::encode $msg;
2868
2869 if (0 && $msg =~ /\[/) {
2870 # COMMAND/INFO
2871 $self->send_packet ("drawextinfo $color 10 8 $msg")
2872 } else {
2873 $msg =~ s/\[\/?(?:b|i|u|fixed|color)[^\]]*\]//g;
2874 $self->send_packet ("drawinfo $color $msg")
2875 }
2876 }
2877 }
2878} 2873}
2879 2874
2880=item $client->ext_msg ($type, @msg) 2875=item $client->ext_msg ($type, @msg)
2881 2876
2882Sends an ext event to the client. 2877Sends an ext event to the client.

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines