#!/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; our $VERSION = '1.0'; sub escape_html($) { local $_ = shift; s/([<>&])/sprintf "%d;", ord $1/ge; $_ } for my $path (@ARGV) { # print STDERR "$path\n"; 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 "", "", "
", "",
"Crossfire Map ", ""; print "/ "; for (0 .. $#path - 1) { print "$path[$_] / "; } my @tile = map { $meta->{info}{"tile_path_$_"} ? "" : "" } 1..4; #"}"# vim misparses without this comment print "$path[-1]", "", "", " | ",
"$tile[0] | ||
$tile[3] | ", "", " | $tile[1] | ", "|
$tile[2] |
", escape_html $meta->{info}{msg}, "
"; print "";
if (my $as = $meta->{map}[$x][$y]) {
print " ($x|$y)";
sub print_archs {
print " ";
}
print "
| ";
}
print "
created by cfmap2html version $VERSION
", ""; close $fh; system "gzip", "-7f", "$path.html"; }