--- cfmaps/cfmap2html 2005/11/20 00:58:57 1.9 +++ cfmaps/cfmap2html 2007/06/24 16:41:52 1.30 @@ -1,7 +1,7 @@ #!/opt/bin/perl # cfmap2html - convert crossfire maps to html -# Copyright (C) 2005 Marc Lehmann +# 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 @@ -14,21 +14,17 @@ # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License -# along with gvpe; if not, write to the Free Software +# along with cfmaps; if not, write to the Free Software # Foundation, Inc. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -use Storable; +our $VERSION = '2.1'; -my $LIBDIR = $ENV{CROSSFIRE_LIBDIR} - or die "\$CROSSFIRE_LIBDIR must be set\n"; +use strict; -my $T = 32; - -my $arch; - -umask 022; +use List::Util qw(min max); +use Crossfire 1.0; -our $VERSION = '1.04'; +my $T = 32; sub escape_html($) { local $_ = shift; @@ -36,160 +32,178 @@ $_ } +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 + push @cfmap2png, $path; + } +} - 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: $!"; +system "cfmap2png", @cfmap2png + if @cfmap2png; - select $fh; - - my $W = $meta->{width} * $T; - my $H = $meta->{height} * $T; - - my (@path) = split /\//, $path; - - print "", - "", - "", - "Crossfire Map \"$path\"", - "", - "", - ""; - - print "", - "

created by cfmap2html version $VERSION

", - "

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