… | |
… | |
1523 | my ($pl) = @_; |
1523 | my ($pl) = @_; |
1524 | |
1524 | |
1525 | my $name = $pl->ob->name; |
1525 | my $name = $pl->ob->name; |
1526 | |
1526 | |
1527 | $pl->{deny_save} = 1; |
1527 | $pl->{deny_save} = 1; |
1528 | $pl->password ("*"); # this should lock out the player until we nuked the dir |
1528 | $pl->password ("*"); # this should lock out the player until we have nuked the dir |
1529 | |
1529 | |
1530 | $pl->invoke (cf::EVENT_PLAYER_LOGOUT, 1) if $pl->active; |
1530 | $pl->invoke (cf::EVENT_PLAYER_LOGOUT, 1) if $pl->active; |
1531 | $pl->deactivate; |
1531 | $pl->deactivate; |
1532 | my $killer = cf::arch::get "killer_quit"; $pl->killer ($killer); $killer->destroy; |
1532 | my $killer = cf::arch::get "killer_quit"; $pl->killer ($killer); $killer->destroy; |
1533 | $pl->ob->check_score; |
1533 | $pl->ob->check_score; |
… | |
… | |
1622 | } |
1622 | } |
1623 | |
1623 | |
1624 | =item $protocol_xml = $player->expand_cfpod ($crossfire_pod) |
1624 | =item $protocol_xml = $player->expand_cfpod ($crossfire_pod) |
1625 | |
1625 | |
1626 | Expand crossfire pod fragments into protocol xml. |
1626 | Expand crossfire pod fragments into protocol xml. |
1627 | |
|
|
1628 | =cut |
|
|
1629 | |
|
|
1630 | use re 'eval'; |
|
|
1631 | |
|
|
1632 | my $group; |
|
|
1633 | my $interior; $interior = qr{ |
|
|
1634 | # match a pod interior sequence sans C<< >> |
|
|
1635 | (?: |
|
|
1636 | \ (.*?)\ (?{ $group = $^N }) |
|
|
1637 | | < (??{$interior}) > |
|
|
1638 | ) |
|
|
1639 | }x; |
|
|
1640 | |
|
|
1641 | sub expand_cfpod { |
|
|
1642 | my ($self, $pod) = @_; |
|
|
1643 | |
|
|
1644 | my $xml; |
|
|
1645 | |
|
|
1646 | while () { |
|
|
1647 | if ($pod =~ /\G( (?: [^BCGHITU]+ | .(?!<) )+ )/xgcs) { |
|
|
1648 | $group = $1; |
|
|
1649 | |
|
|
1650 | $group =~ s/&/&/g; |
|
|
1651 | $group =~ s/</</g; |
|
|
1652 | |
|
|
1653 | $xml .= $group; |
|
|
1654 | } elsif ($pod =~ m%\G |
|
|
1655 | ([BCGHITU]) |
|
|
1656 | < |
|
|
1657 | (?: |
|
|
1658 | ([^<>]*) (?{ $group = $^N }) |
|
|
1659 | | < $interior > |
|
|
1660 | ) |
|
|
1661 | > |
|
|
1662 | %gcsx |
|
|
1663 | ) { |
|
|
1664 | my ($code, $data) = ($1, $group); |
|
|
1665 | |
|
|
1666 | if ($code eq "B") { |
|
|
1667 | $xml .= "<b>" . expand_cfpod ($self, $data) . "</b>"; |
|
|
1668 | } elsif ($code eq "I") { |
|
|
1669 | $xml .= "<i>" . expand_cfpod ($self, $data) . "</i>"; |
|
|
1670 | } elsif ($code eq "U") { |
|
|
1671 | $xml .= "<u>" . expand_cfpod ($self, $data) . "</u>"; |
|
|
1672 | } elsif ($code eq "C") { |
|
|
1673 | $xml .= "<tt>" . expand_cfpod ($self, $data) . "</tt>"; |
|
|
1674 | } elsif ($code eq "T") { |
|
|
1675 | $xml .= "<big><b>" . expand_cfpod ($self, $data) . "</b></big>"; |
|
|
1676 | } elsif ($code eq "G") { |
|
|
1677 | my ($male, $female) = split /\|/, $data; |
|
|
1678 | $data = $self->gender ? $female : $male; |
|
|
1679 | $xml .= expand_cfpod ($self, $data); |
|
|
1680 | } elsif ($code eq "H") { |
|
|
1681 | $xml .= ("<fg name=\"lightblue\">[" . expand_cfpod ($self, $data) . " (Use hintmode to suppress hints)]</fg>", |
|
|
1682 | "<fg name=\"lightblue\">[Hint suppressed, see hintmode]</fg>", |
|
|
1683 | "") |
|
|
1684 | [$self->{hintmode}]; |
|
|
1685 | } else { |
|
|
1686 | $xml .= "error processing '$code($data)' directive"; |
|
|
1687 | } |
|
|
1688 | } else { |
|
|
1689 | if ($pod =~ /\G(.+)/) { |
|
|
1690 | warn "parse error while expanding $pod (at $1)"; |
|
|
1691 | } |
|
|
1692 | last; |
|
|
1693 | } |
|
|
1694 | } |
|
|
1695 | |
|
|
1696 | for ($xml) { |
|
|
1697 | # create single paragraphs (very hackish) |
|
|
1698 | s/(?<=\S)\n(?=\w)/ /g; |
|
|
1699 | |
|
|
1700 | # compress some whitespace |
|
|
1701 | s/\s+\n/\n/g; # ws line-ends |
|
|
1702 | s/\n\n+/\n/g; # double lines |
|
|
1703 | s/^\n+//; # beginning lines |
|
|
1704 | s/\n+$//; # ending lines |
|
|
1705 | } |
|
|
1706 | |
|
|
1707 | $xml |
|
|
1708 | } |
|
|
1709 | |
|
|
1710 | no re 'eval'; |
|
|
1711 | |
|
|
1712 | sub hintmode { |
|
|
1713 | $_[0]{hintmode} = $_[1] if @_ > 1; |
|
|
1714 | $_[0]{hintmode} |
|
|
1715 | } |
|
|
1716 | |
1627 | |
1717 | =item $player->ext_reply ($msgid, @msg) |
1628 | =item $player->ext_reply ($msgid, @msg) |
1718 | |
1629 | |
1719 | Sends an ext reply to the player. |
1630 | Sends an ext reply to the player. |
1720 | |
1631 | |
… | |
… | |
2905 | if ($self->can_msg) { |
2816 | if ($self->can_msg) { |
2906 | # default colour, mask it out |
2817 | # default colour, mask it out |
2907 | $color &= ~(cf::NDI_COLOR_MASK | cf::NDI_DEF) |
2818 | $color &= ~(cf::NDI_COLOR_MASK | cf::NDI_DEF) |
2908 | if $color & cf::NDI_DEF; |
2819 | if $color & cf::NDI_DEF; |
2909 | |
2820 | |
2910 | $self->send_packet ("msg " . $self->{json_coder}->encode ( |
2821 | my $pkt = "msg " |
|
|
2822 | . $self->{json_coder}->encode ( |
2911 | [$color & cf::NDI_CLIENT_MASK, $channel, $msg, @extra])); |
2823 | [$color & cf::NDI_CLIENT_MASK, $channel, $msg, @extra] |
|
|
2824 | ); |
|
|
2825 | |
|
|
2826 | # try lzf for large packets |
|
|
2827 | $pkt = "lzf " . Compress::LZF::compress $pkt |
|
|
2828 | if 1024 <= length $pkt and $self->{can_lzf}; |
|
|
2829 | |
|
|
2830 | # split very large packets |
|
|
2831 | if (8192 < length $pkt and $self->{can_lzf}) { |
|
|
2832 | $self->send_packet ("frag $_") for unpack "(a8192)*", $pkt; |
|
|
2833 | $pkt = "frag"; |
|
|
2834 | } |
|
|
2835 | |
|
|
2836 | $self->send_packet ($pkt); |
2912 | } else { |
2837 | } else { |
2913 | if ($color >= 0) { |
2838 | if ($color >= 0) { |
2914 | # replace some tags by gcfclient-compatible ones |
2839 | # replace some tags by gcfclient-compatible ones |
2915 | for ($msg) { |
2840 | for ($msg) { |
2916 | 1 while |
2841 | 1 while |