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.310 by elmex, Mon Jul 16 15:43:49 2007 UTC vs.
Revision 1.313 by root, Sun Jul 22 14:17:58 2007 UTC

918 918
919=cut 919=cut
920 920
921############################################################################# 921#############################################################################
922# object support 922# object support
923#
924
925sub _can_merge {
926 my ($ob1, $ob2) = @_;
927
928 local $Storable::canonical = 1;
929 my $fob1 = Storable::freeze $ob1;
930 my $fob2 = Storable::freeze $ob2;
931
932 $fob1 eq $fob2
933}
923 934
924sub reattach { 935sub reattach {
925 # basically do the same as instantiate, without calling instantiate 936 # basically do the same as instantiate, without calling instantiate
926 my ($obj) = @_; 937 my ($obj) = @_;
927 938
2425 2436
2426 utf8::encode $text; 2437 utf8::encode $text;
2427 $self->send_packet (sprintf "drawinfo %d %s", $flags || cf::NDI_BLACK, $text); 2438 $self->send_packet (sprintf "drawinfo %d %s", $flags || cf::NDI_BLACK, $text);
2428} 2439}
2429 2440
2430=item $client->send_msg ($color, $type, $msg, [extra...]) 2441=item $client->send_msg ($channel, $msg, $color, [extra...])
2431 2442
2432Send a drawinfo or msg packet to the client, formatting the msg for the 2443Send a drawinfo or msg packet to the client, formatting the msg for the
2433client if neccessary. C<$type> should be a string identifying the type of 2444client if neccessary. C<$type> should be a string identifying the type of
2434the message, with C<log> being the default. If C<$color> is negative, suppress 2445the message, with C<log> being the default. If C<$color> is negative, suppress
2435the message unless the client supports the msg packet. 2446the message unless the client supports the msg packet.
2436 2447
2437=cut 2448=cut
2438 2449
2439sub cf::client::send_msg { 2450sub cf::client::send_msg {
2440 my ($self, $color, $type, $msg, @extra) = @_; 2451 my ($self, $channel, $msg, $color, @extra) = @_;
2441 2452
2442 $msg = $self->pl->expand_cfpod ($msg); 2453 $msg = $self->pl->expand_cfpod ($msg);
2443 2454
2455 $color &= ~cf::NDI_UNIQUE; # just in case...
2456
2457 if (ref $channel) {
2458 # send meta info to client, if not yet sent
2459 unless (exists $self->{channel}{$channel->{id}}) {
2460 $self->{channel}{$channel->{id}} = $channel;
2461 $self->ext_event (channel_info => %$channel);
2462 }
2463
2464 $channel = $channel->{id};
2465 }
2466
2444 return unless @extra || length $msg; 2467 return unless @extra || length $msg;
2445 2468
2446 if ($self->can_msg) { 2469 if ($self->can_msg) {
2447 $self->send_packet ("msg " . $self->{json_coder}->encode ([$color, $type, $msg, @extra])); 2470 $self->send_packet ("msg " . $self->{json_coder}->encode ([$color, $channel, $msg, @extra]));
2448 } else { 2471 } else {
2449 # replace some tags by gcfclient-compatible ones 2472 # replace some tags by gcfclient-compatible ones
2450 for ($msg) { 2473 for ($msg) {
2451 1 while 2474 1 while
2452 s/<b>([^<]*)<\/b>/[b]${1}[\/b]/ 2475 s/<b>([^<]*)<\/b>/[b]${1}[\/b]/

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines