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.349 by root, Fri Aug 31 04:10:43 2007 UTC vs.
Revision 1.355 by root, Sun Sep 2 12:45:44 2007 UTC

481sub fork_call(&@) { 481sub fork_call(&@) {
482 my ($cb, @args) = @_; 482 my ($cb, @args) = @_;
483 483
484 # we seemingly have to make a local copy of the whole thing, 484 # we seemingly have to make a local copy of the whole thing,
485 # otherwise perl prematurely frees the stuff :/ 485 # otherwise perl prematurely frees the stuff :/
486 # TODO: investigate and fix (liekly this will be rather laborious) 486 # TODO: investigate and fix (likely this will be rather laborious)
487 487
488 my @res = Coro::Util::fork_eval { 488 my @res = Coro::Util::fork_eval {
489 reset_signals; 489 reset_signals;
490 &$cb 490 &$cb
491 }, @args; 491 }, @args;
1413 or return []; 1413 or return [];
1414 1414
1415 my @logins; 1415 my @logins;
1416 1416
1417 for my $login (@$dirs) { 1417 for my $login (@$dirs) {
1418 my $path = path $login;
1419
1420 # a .pst is a dead give-away for a valid player
1421 unless (-e "$path.pst") {
1418 my $fh = aio_open path $login, Fcntl::O_RDONLY, 0 or next; 1422 my $fh = aio_open $path, Fcntl::O_RDONLY, 0 or next;
1419 aio_read $fh, 0, 512, my $buf, 0 or next; 1423 aio_read $fh, 0, 512, my $buf, 0 or next;
1420 $buf !~ /^password -------------$/m or next; # official not-valid tag 1424 $buf !~ /^password -------------$/m or next; # official not-valid tag
1425 }
1421 1426
1422 utf8::decode $login; 1427 utf8::decode $login;
1423 push @logins, $login; 1428 push @logins, $login;
1424 } 1429 }
1425 1430
1463sub expand_cfpod { 1468sub expand_cfpod {
1464 ((my $self), (local $_)) = @_; 1469 ((my $self), (local $_)) = @_;
1465 1470
1466 # escape & and < 1471 # escape & and <
1467 s/&/&amp;/g; 1472 s/&/&amp;/g;
1468 s/(?<![BIUGH])</&lt;/g; 1473 s/(?<![BIUGHT])</&lt;/g;
1469 1474
1470 # this is buggy, it needs to properly take care of nested <'s 1475 # this is buggy, it needs to properly take care of nested <'s
1471 1476
1472 1 while 1477 1 while
1473 # replace B<>, I<>, U<> etc. 1478 # replace B<>, I<>, U<> etc.
1474 s/B<([^\>]*)>/<b>$1<\/b>/ 1479 s/B<([^\>]*)>/<b>$1<\/b>/
1475 || s/I<([^\>]*)>/<i>$1<\/i>/ 1480 || s/I<([^\>]*)>/<i>$1<\/i>/
1476 || s/U<([^\>]*)>/<u>$1<\/u>/ 1481 || s/U<([^\>]*)>/<u>$1<\/u>/
1482 || s/T<([^\>]*)>/<big><b>$1<\/b><\/big>/
1477 # replace G<male|female> tags 1483 # replace G<male|female> tags
1478 || s{G<([^>|]*)\|([^>]*)>}{ 1484 || s{G<([^>|]*)\|([^>]*)>}{
1479 $self->gender ? $2 : $1 1485 $self->gender ? $2 : $1
1480 }ge 1486 }ge
1481 # replace H<hint text> 1487 # replace H<hint text>
2091 { 2097 {
2092 my $lock = cf::lock_acquire "map_data:$self->{path}"; 2098 my $lock = cf::lock_acquire "map_data:$self->{path}";
2093 2099
2094 delete $cf::MAP{$self->path}; 2100 delete $cf::MAP{$self->path};
2095 2101
2102 $self->unlink_save;
2103
2096 bless $self, "cf::map"; 2104 bless $self, "cf::map";
2097 delete $self->{deny_reset}; 2105 delete $self->{deny_reset};
2098 $self->{deny_save} = 1; 2106 $self->{deny_save} = 1;
2099 $self->reset_timeout (1); 2107 $self->reset_timeout (1);
2100 $self->path ($self->{path} = "{nuke}/" . ($nuke_counter++)); 2108 $self->path ($self->{path} = "{nuke}/" . ($nuke_counter++));
2101
2102 $self->unlink_save;
2103 2109
2104 $cf::MAP{$self->path} = $self; 2110 $cf::MAP{$self->path} = $self;
2105 } 2111 }
2106 2112
2107 $self->reset; # polite request, might not happen 2113 $self->reset; # polite request, might not happen
2504the message, with C<log> being the default. If C<$color> is negative, suppress 2510the message, with C<log> being the default. If C<$color> is negative, suppress
2505the message unless the client supports the msg packet. 2511the message unless the client supports the msg packet.
2506 2512
2507=cut 2513=cut
2508 2514
2515our %CHANNEL = (
2516 "c/identify" => {
2517 id => "identify",
2518 title => "Identify",
2519 reply => undef,
2520 tooltip => "Items recently identified",
2521 },
2522 "c/examine" => {
2523 id => "examine",
2524 title => "Examine",
2525 reply => undef,
2526 tooltip => "Signs and other items you examined",
2527 },
2528);
2529
2509sub cf::client::send_msg { 2530sub cf::client::send_msg {
2510 my ($self, $channel, $msg, $color, @extra) = @_; 2531 my ($self, $channel, $msg, $color, @extra) = @_;
2511 2532
2512 $msg = $self->pl->expand_cfpod ($msg); 2533 $msg = $self->pl->expand_cfpod ($msg);
2513 2534
2514 $color &= cf::NDI_CLIENT_MASK; # just in case... 2535 $color &= cf::NDI_CLIENT_MASK; # just in case...
2536
2537 # check predefined channels, for the benefit of C
2538 $channel = $CHANNEL{$channel} if $CHANNEL{$channel};
2515 2539
2516 if (ref $channel) { 2540 if (ref $channel) {
2517 # send meta info to client, if not yet sent 2541 # send meta info to client, if not yet sent
2518 unless (exists $self->{channel}{$channel->{id}}) { 2542 unless (exists $self->{channel}{$channel->{id}}) {
2519 $self->{channel}{$channel->{id}} = $channel; 2543 $self->{channel}{$channel->{id}} = $channel;
2520 $self->ext_msg (channel_info => $channel); 2544 $self->ext_msg (channel_info => $channel)
2545 if $self->can_msg;
2521 } 2546 }
2522 2547
2523 $channel = $channel->{id}; 2548 $channel = $channel->{id};
2524 } 2549 }
2525 2550

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines