--- deliantra/server/lib/cf.pm 2007/10/25 09:01:24 1.390
+++ deliantra/server/lib/cf.pm 2007/10/26 04:22:05 1.391
@@ -1550,44 +1550,83 @@
=cut
+ use re 'eval';
+
+my $group;
+my $interior; $interior = qr{
+ (?:
+ \ (.*?)\ (?{ $group = $^N })
+ | < (??{$interior}) >
+ )
+}x;
+
sub expand_cfpod {
- ((my $self), (local $_)) = @_;
+ my ($self, $pod) = @_;
+
+ my $xml;
+
+ while () {
+ if ($pod =~ /\G( (?: [^BCGHITU]+ | .(?=[^<]) )+ )/xgcs) {
+ $group = $1;
+
+ $group =~ s/&/&/g;
+ $group =~ s/</g;
+
+ $xml .= $group;
+ } elsif ($pod =~ m%\G
+ ([BCGHITU])
+ <
+ (?:
+ ([^<>]*) (?{ $group = $^N })
+ | < $interior >
+ )
+ >
+ %gcsx
+ ) {
+ my ($code, $data) = ($1, $group);
+
+ if ($code eq "B") {
+ $xml .= "" . expand_cfpod ($self, $data) . "";
+ } elsif ($code eq "I") {
+ $xml .= "" . expand_cfpod ($self, $data) . "";
+ } elsif ($code eq "U") {
+ $xml .= "" . expand_cfpod ($self, $data) . "";
+ } elsif ($code eq "C") {
+ $xml .= "" . expand_cfpod ($self, $data) . "";
+ } elsif ($code eq "T") {
+ $xml .= "" . expand_cfpod ($self, $data) . "";
+ } elsif ($code eq "G") {
+ my ($male, $female) = split /\|/, $data;
+ $data = $self->gender ? $female : $male;
+ $xml .= expand_cfpod ($self, $data);
+ } elsif ($code eq "H") {
+ $xml .= ("[" . expand_cfpod ($self, $data) . " (Use hintmode to suppress hints)]",
+ "[Hint suppressed, see hintmode]",
+ "")
+ [$self->{hintmode}];
+ } else {
+ $xml .= "error processing '$code($data)' directive";
+ }
+ } else {
+ if ($pod =~ /\G(.+)/) {
+ warn "parse error while expanding $pod (at $1)";
+ }
+ last;
+ }
+ }
- # escape & and <
- s/&/&/g;
- s/(?, I<>, U<> etc.
- s/B<([^\>]*)>/$1<\/b>/
- || s/I<([^\>]*)>/$1<\/i>/
- || s/U<([^\>]*)>/$1<\/u>/
- || s/T<([^\>]*)>/$1<\/b><\/big>/
- # replace G tags
- || s{G<([^>|]*)\|([^>]*)>}{
- $self->gender ? $2 : $1
- }ge
- # replace H
- || s{H<([^\>]*)>}
- {
- ("[$1 (Use hintmode to suppress hints)]",
- "[Hint suppressed, see hintmode]",
- "")
- [$self->{hintmode}]
- }ge;
-
- # create single paragraphs (very hackish)
- s/(?<=\S)\n(?=\w)/ /g;
-
- # compress some whitespace
- s/\s+\n/\n/g; # ws line-ends
- s/\n\n+/\n/g; # double lines
- s/^\n+//; # beginning lines
- s/\n+$//; # ending lines
+ for ($xml) {
+ # create single paragraphs (very hackish)
+ s/(?<=\S)\n(?=\w)/ /g;
+
+ # compress some whitespace
+ s/\s+\n/\n/g; # ws line-ends
+ s/\n\n+/\n/g; # double lines
+ s/^\n+//; # beginning lines
+ s/\n+$//; # ending lines
+ }
- $_
+ $xml
}
sub hintmode {
@@ -2668,6 +2707,7 @@
=cut
+# non-persistent channels (usually the info channel)
our %CHANNEL = (
"c/identify" => {
id => "infobox",
@@ -2709,7 +2749,7 @@
id => "infobox",
title => "Uptime",
reply => undef,
- tooltip => "How long the server has been running sicne last restart",
+ tooltip => "How long the server has been running since last restart",
},
"c/mapinfo" => {
id => "infobox",