… | |
… | |
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 | sub expand_cfpod { |
|
|
1631 | my ($self, $pod) = @_; |
|
|
1632 | |
|
|
1633 | my @nest = [qr<\G$>, undef, ""]; |
|
|
1634 | my $xml; |
|
|
1635 | |
|
|
1636 | for ($pod) { |
|
|
1637 | while () { |
|
|
1638 | if (/\G( (?: [^BCEGHITUZ&>\n\ ]+ | [BCEGHITUZ](?!<) | \ (?!>) )+ )/xgcs) { |
|
|
1639 | $xml .= $1; |
|
|
1640 | } elsif (/\G\n(?=\S)/xgcs) { |
|
|
1641 | $xml .= " "; |
|
|
1642 | } elsif (/\G\n/xgcs) { |
|
|
1643 | $xml .= "\n"; |
|
|
1644 | } elsif (/\G ([BCEGHITUZ]) (< (?: <+\ | (?!<) ) )/xgcs) { |
|
|
1645 | my ($code, $delim) = ($1, scalar reverse $2); |
|
|
1646 | $delim =~ y/</>/; # delim now contains the stop sequence |
|
|
1647 | $delim = qr{\G\Q$delim}; |
|
|
1648 | |
|
|
1649 | my $cb; |
|
|
1650 | |
|
|
1651 | if ($code eq "B") { |
|
|
1652 | $cb = sub { "<b>$_[0]</b>" }; |
|
|
1653 | } elsif ($code eq "C") { |
|
|
1654 | $cb = sub { "<tt>$_[0]</tt>" }; |
|
|
1655 | } elsif ($code eq "E") { |
|
|
1656 | $cb = sub { warn "E<$_[0]>\n";"&$_[0];" }; |
|
|
1657 | } elsif ($code eq "G") { |
|
|
1658 | $cb = sub { |
|
|
1659 | my ($male, $female) = split /\|/, $_[0]; |
|
|
1660 | $self->gender ? $female : $male |
|
|
1661 | }; |
|
|
1662 | } elsif ($code eq "H") { |
|
|
1663 | $cb = sub { |
|
|
1664 | ( |
|
|
1665 | "<fg name=\"lightblue\">[$_[0] (Use hintmode to suppress hints)]</fg>", |
|
|
1666 | "<fg name=\"lightblue\">[Hint suppressed, see hintmode]</fg>", |
|
|
1667 | "", |
|
|
1668 | )[$self->{hintmode}]; |
|
|
1669 | }; |
|
|
1670 | } elsif ($code eq "I") { |
|
|
1671 | $cb = sub { "<i>$_[0]</i>" }; |
|
|
1672 | } elsif ($code eq "T") { |
|
|
1673 | $cb = sub { "<big><b>$_[0]</b></big>" }; |
|
|
1674 | } elsif ($code eq "U") { |
|
|
1675 | $cb = sub { "<u>$_[0]</u>" }; |
|
|
1676 | } elsif ($code eq "Z") { |
|
|
1677 | $cb = sub { }; |
|
|
1678 | } else { |
|
|
1679 | die "FATAL error in expand_cfpod"; |
|
|
1680 | } |
|
|
1681 | |
|
|
1682 | push @nest, [$delim, $cb, $xml]; |
|
|
1683 | undef $xml; |
|
|
1684 | |
|
|
1685 | } elsif ($_ =~ /$nest[-1][0]/gcs) { |
|
|
1686 | my $nest = pop @nest; |
|
|
1687 | |
|
|
1688 | if ($nest->[1]) { |
|
|
1689 | $xml = $nest->[2] . $nest->[1]->($xml); |
|
|
1690 | } else { |
|
|
1691 | last; |
|
|
1692 | } |
|
|
1693 | } elsif (/\G</xgcs) { |
|
|
1694 | $xml .= "<"; |
|
|
1695 | } elsif (/\G&/xgcs) { |
|
|
1696 | $xml .= "&"; |
|
|
1697 | } elsif (/\G>/xgcs) { |
|
|
1698 | $xml .= ">"; |
|
|
1699 | } else { |
|
|
1700 | if ($pod =~ /\G(.+)/xgcs) { |
|
|
1701 | warn "parse error (at $1)($nest[-1][0]) while expanding cfpod:\n$pod"; |
|
|
1702 | last; |
|
|
1703 | } else { |
|
|
1704 | warn "parse error (unclosed interior sequence at end of cfpod) while expanding cfpod:\n$pod"; |
|
|
1705 | return "<b>Sorry, the server encountered an internal error when formatting this message, please report this.</b>"; |
|
|
1706 | } |
|
|
1707 | } |
|
|
1708 | } |
|
|
1709 | } |
|
|
1710 | |
|
|
1711 | $xml |
|
|
1712 | } |
|
|
1713 | |
|
|
1714 | sub hintmode { |
|
|
1715 | $_[0]{hintmode} = $_[1] if @_ > 1; |
|
|
1716 | $_[0]{hintmode} |
|
|
1717 | } |
|
|
1718 | |
1627 | |
1719 | =item $player->ext_reply ($msgid, @msg) |
1628 | =item $player->ext_reply ($msgid, @msg) |
1720 | |
1629 | |
1721 | Sends an ext reply to the player. |
1630 | Sends an ext reply to the player. |
1722 | |
1631 | |
… | |
… | |
2907 | if ($self->can_msg) { |
2816 | if ($self->can_msg) { |
2908 | # default colour, mask it out |
2817 | # default colour, mask it out |
2909 | $color &= ~(cf::NDI_COLOR_MASK | cf::NDI_DEF) |
2818 | $color &= ~(cf::NDI_COLOR_MASK | cf::NDI_DEF) |
2910 | if $color & cf::NDI_DEF; |
2819 | if $color & cf::NDI_DEF; |
2911 | |
2820 | |
2912 | $self->send_packet ("msg " . $self->{json_coder}->encode ( |
2821 | my $pkt = "msg " |
|
|
2822 | . $self->{json_coder}->encode ( |
2913 | [$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); |
2914 | } else { |
2837 | } else { |
2915 | if ($color >= 0) { |
2838 | if ($color >= 0) { |
2916 | # replace some tags by gcfclient-compatible ones |
2839 | # replace some tags by gcfclient-compatible ones |
2917 | for ($msg) { |
2840 | for ($msg) { |
2918 | 1 while |
2841 | 1 while |