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.463 by root, Sun Dec 28 06:59:27 2008 UTC

2809 2809
2810 # check predefined channels, for the benefit of C 2810 # check predefined channels, for the benefit of C
2811 if ($CHANNEL{$channel}) { 2811 if ($CHANNEL{$channel}) {
2812 $channel = $CHANNEL{$channel}; 2812 $channel = $CHANNEL{$channel};
2813 2813
2814 $self->ext_msg (channel_info => $channel) 2814 $self->ext_msg (channel_info => $channel);
2815 if $self->can_msg;
2816
2817 $channel = $channel->{id}; 2815 $channel = $channel->{id};
2818 2816
2819 } elsif (ref $channel) { 2817 } elsif (ref $channel) {
2820 # send meta info to client, if not yet sent 2818 # send meta info to client, if not yet sent
2821 unless (exists $self->{channel}{$channel->{id}}) { 2819 unless (exists $self->{channel}{$channel->{id}}) {
2822 $self->{channel}{$channel->{id}} = $channel; 2820 $self->{channel}{$channel->{id}} = $channel;
2823 $self->ext_msg (channel_info => $channel) 2821 $self->ext_msg (channel_info => $channel);
2824 if $self->can_msg;
2825 } 2822 }
2826 2823
2827 $channel = $channel->{id}; 2824 $channel = $channel->{id};
2828 } 2825 }
2829 2826
2830 return unless @extra || length $msg; 2827 return unless @extra || length $msg;
2831 2828
2832 if ($self->can_msg) {
2833 # default colour, mask it out 2829 # default colour, mask it out
2834 $color &= ~(cf::NDI_COLOR_MASK | cf::NDI_DEF) 2830 $color &= ~(cf::NDI_COLOR_MASK | cf::NDI_DEF)
2835 if $color & cf::NDI_DEF; 2831 if $color & cf::NDI_DEF;
2836 2832
2837 my $pkt = "msg " 2833 my $pkt = "msg "
2838 . $self->{json_coder}->encode ( 2834 . $self->{json_coder}->encode (
2839 [$color & cf::NDI_CLIENT_MASK, $channel, $msg, @extra] 2835 [$color & cf::NDI_CLIENT_MASK, $channel, $msg, @extra]
2840 ); 2836 );
2841 2837
2842 # try lzf for large packets 2838 # try lzf for large packets
2843 $pkt = "lzf " . Compress::LZF::compress $pkt 2839 $pkt = "lzf " . Compress::LZF::compress $pkt
2844 if 1024 <= length $pkt and $self->{can_lzf}; 2840 if 1024 <= length $pkt and $self->{can_lzf};
2845 2841
2846 # split very large packets 2842 # split very large packets
2847 if (8192 < length $pkt and $self->{can_lzf}) { 2843 if (8192 < length $pkt and $self->{can_lzf}) {
2848 $self->send_packet ("frag $_") for unpack "(a8192)*", $pkt; 2844 $self->send_packet ("frag $_") for unpack "(a8192)*", $pkt;
2849 $pkt = "frag"; 2845 $pkt = "frag";
2850 } 2846 }
2851 2847
2852 $self->send_packet ($pkt); 2848 $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} 2849}
2879 2850
2880=item $client->ext_msg ($type, @msg) 2851=item $client->ext_msg ($type, @msg)
2881 2852
2882Sends an ext event to the client. 2853Sends an ext event to the client.

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines