#!/opt/bin/perl use Storable; my $LIBDIR = $ENV{CROSSFIRE_LIBDIR} or die "\$CROSSFIRE_LIBDIR must be set\n"; my $T = 32; my $arch; umask 022; sub escape_html($) { local $_ = shift; s/([<>&])/sprintf "&#%d;", ord $1/ge; $_ } for my $path (@ARGV) { if (!-e "$path.png" || !-e "$path.pst" || -M "$path.pst" > -M $path || -M "$path.png" > -M $path) { # regenerate png and metainfo system "cfmap2png", $path; }; $arch ||= Storable::retrieve "$LIBDIR/archetypes.pst"; my $meta = Storable::retrieve "$path.pst"; open my $fh, ">:utf8", "$path.html" or die "$path.html: $!"; select $fh; my $W = $meta->{width} * $T; my $H = $meta->{height} * $T; my (@path) = split /\//, $path; print "", "", "", "$path", "", "", ""; print "", "", "", ""; print "", "", ""; print ""; my $W1 = $W + 600; print "

[about cfmaps.schmorp.de]

"; print "

", escape_html $meta->{info}{msg}, "

"; print ""; my %ignore = map +($_ => 1), qw(_name x y); for my $y (0.. $meta->{height} - 1) { print ""; for my $x (0.. $meta->{width} - 1) { print ""; } print ""; } print "
"; if (my $as = $meta->{map}[$x][$y]) { print "
($x|$y)
    "; for my $a (@$as) { my $o = $arch->{$a->{_name}}; print "
  • \"$o->{name}\" ($a->{_name})\n"; for (sort keys %$a) { next if $ignore{$_}; my $v = escape_html $a->{$_}; if (($o->{type} == 66 || $o->{type} == 41) && $_ eq "slaying") { # door, teleporter $a->{msg} =~ /^final_map\s*(\S+)\s*$/m, $v = $1 if $v eq "/!"; # random map print "slaying => $v\n"; } elsif ($_ eq "msg") { print "

    $v

    "; } else { print "$_ => $v\n"; } } } print "
"; } print "

"; close $fh; system "gzip", "-7f", "$path.html"; }