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.348 by root, Thu Aug 30 08:34:40 2007 UTC vs.
Revision 1.353 by root, Sun Sep 2 08:43:46 2007 UTC

1463sub expand_cfpod { 1463sub expand_cfpod {
1464 ((my $self), (local $_)) = @_; 1464 ((my $self), (local $_)) = @_;
1465 1465
1466 # escape & and < 1466 # escape & and <
1467 s/&/&amp;/g; 1467 s/&/&amp;/g;
1468 s/(?<![BIUGH])</&lt;/g; 1468 s/(?<![BIUGHT])</&lt;/g;
1469 1469
1470 # this is buggy, it needs to properly take care of nested <'s 1470 # this is buggy, it needs to properly take care of nested <'s
1471 1471
1472 1 while 1472 1 while
1473 # replace B<>, I<>, U<> etc. 1473 # replace B<>, I<>, U<> etc.
1474 s/B<([^\>]*)>/<b>$1<\/b>/ 1474 s/B<([^\>]*)>/<b>$1<\/b>/
1475 || s/I<([^\>]*)>/<i>$1<\/i>/ 1475 || s/I<([^\>]*)>/<i>$1<\/i>/
1476 || s/U<([^\>]*)>/<u>$1<\/u>/ 1476 || s/U<([^\>]*)>/<u>$1<\/u>/
1477 || s/T<([^\>]*)>/<big><b>$1<\/b><\/big>/
1477 # replace G<male|female> tags 1478 # replace G<male|female> tags
1478 || s{G<([^>|]*)\|([^>]*)>}{ 1479 || s{G<([^>|]*)\|([^>]*)>}{
1479 $self->gender ? $2 : $1 1480 $self->gender ? $2 : $1
1480 }ge 1481 }ge
1481 # replace H<hint text> 1482 # replace H<hint text>
2086my $nuke_counter = "aaaa"; 2087my $nuke_counter = "aaaa";
2087 2088
2088sub nuke { 2089sub nuke {
2089 my ($self) = @_; 2090 my ($self) = @_;
2090 2091
2092 {
2093 my $lock = cf::lock_acquire "map_data:$self->{path}";
2094
2091 delete $cf::MAP{$self->path}; 2095 delete $cf::MAP{$self->path};
2092 2096
2093 $self->unlink_save; 2097 $self->unlink_save;
2094 2098
2095 bless $self, "cf::map"; 2099 bless $self, "cf::map";
2096 delete $self->{deny_reset}; 2100 delete $self->{deny_reset};
2097 $self->{deny_save} = 1; 2101 $self->{deny_save} = 1;
2098 $self->reset_timeout (1); 2102 $self->reset_timeout (1);
2099 $self->path ($self->{path} = "{nuke}/" . ($nuke_counter++)); 2103 $self->path ($self->{path} = "{nuke}/" . ($nuke_counter++));
2100 2104
2101 $cf::MAP{$self->path} = $self; 2105 $cf::MAP{$self->path} = $self;
2106 }
2102 2107
2103 $self->reset; # polite request, might not happen 2108 $self->reset; # polite request, might not happen
2104} 2109}
2105 2110
2106=item $maps = cf::map::tmp_maps 2111=item $maps = cf::map::tmp_maps
2500the message, with C<log> being the default. If C<$color> is negative, suppress 2505the message, with C<log> being the default. If C<$color> is negative, suppress
2501the message unless the client supports the msg packet. 2506the message unless the client supports the msg packet.
2502 2507
2503=cut 2508=cut
2504 2509
2510our %CHANNEL = (
2511 "c/identify" => {
2512 id => "identify",
2513 title => "Identify",
2514 reply => undef,
2515 tooltip => "Items recently identified",
2516 },
2517 "c/examine" => {
2518 id => "examine",
2519 title => "Examine",
2520 reply => undef,
2521 tooltip => "Signs and other items you examined",
2522 },
2523);
2524
2505sub cf::client::send_msg { 2525sub cf::client::send_msg {
2506 my ($self, $channel, $msg, $color, @extra) = @_; 2526 my ($self, $channel, $msg, $color, @extra) = @_;
2507 2527
2508 $msg = $self->pl->expand_cfpod ($msg); 2528 $msg = $self->pl->expand_cfpod ($msg);
2509 2529
2510 $color &= cf::NDI_CLIENT_MASK; # just in case... 2530 $color &= cf::NDI_CLIENT_MASK; # just in case...
2531
2532 # check predefined channels, for the benefit of C
2533 $channel = $CHANNEL{$channel} if $CHANNEL{$channel};
2511 2534
2512 if (ref $channel) { 2535 if (ref $channel) {
2513 # send meta info to client, if not yet sent 2536 # send meta info to client, if not yet sent
2514 unless (exists $self->{channel}{$channel->{id}}) { 2537 unless (exists $self->{channel}{$channel->{id}}) {
2515 $self->{channel}{$channel->{id}} = $channel; 2538 $self->{channel}{$channel->{id}} = $channel;
2516 $self->ext_msg (channel_info => $channel); 2539 $self->ext_msg (channel_info => $channel)
2540 if $self->can_msg;
2517 } 2541 }
2518 2542
2519 $channel = $channel->{id}; 2543 $channel = $channel->{id};
2520 } 2544 }
2521 2545

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines