--- cfmaps/cfmap2html 2005/11/18 12:04:12 1.5 +++ cfmaps/cfmap2html 2007/06/21 12:30:10 1.29 @@ -1,165 +1,196 @@ #!/opt/bin/perl -use Storable; +# cfmap2html - convert crossfire maps to html +# Copyright (C) 2005,2007 Marc Lehmann +# +# CFMAP2HTML is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with cfmaps; if not, write to the Free Software +# Foundation, Inc. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -my $LIBDIR = $ENV{CROSSFIRE_LIBDIR} - or die "\$CROSSFIRE_LIBDIR must be set\n"; +our $VERSION = '2.001'; + +use Crossfire 1.0; my $T = 32; my $arch; -umask 022; - -our $VERSION = '1.0'; - sub escape_html($) { local $_ = shift; s/([<>&])/sprintf "&#%d;", ord $1/ge; $_ } +my @cfmap2png; + for my $path (@ARGV) { + (my $base = $path) =~ s/\.map//; # print STDERR "$path\n"; - if (!-e "$path.png" - || !-e "$path.pst" - || -M "$path.pst" > -M $path - || -M "$path.png" > -M $path) { + if (!-e "$base.png" + || -M "$base.png" > -M "$base.map") { # regenerate png and metainfo - - system "cfmap2png", $path; + push @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; +system "cfmap2png", @cfmap2png + if @cfmap2png; - my $W = $meta->{width} * $T; - my $H = $meta->{height} * $T; - - my (@path) = split /\//, $path; - - print "", - "", - "", - "$path", - "", - "", - ""; - - print "", - "", + "

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