--- cfmaps/cfmap2html 2005/11/18 06:57:15 1.2 +++ cfmaps/cfmap2html 2005/11/20 01:05:34 1.10 @@ -1,5 +1,24 @@ #!/opt/bin/perl +# cfmap2html - convert crossfire maps to html +# Copyright (C) 2005 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 gvpe; if not, write to the Free Software +# Foundation, Inc. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +our $VERSION = '1.05'; + use Storable; my $LIBDIR = $ENV{CROSSFIRE_LIBDIR} @@ -18,6 +37,8 @@ } for my $path (@ARGV) { +# print STDERR "$path\n"; + if (!-e "$path.png" || !-e "$path.pst" || -M "$path.pst" > -M $path @@ -43,37 +64,43 @@ print "", "", "", - "$path", + "Crossfire Map \"$path\"", "", "", ""; - print "", - "", + "", + "", + "", + ""; my $W1 = $W + 600; - print "

[about cfmaps.schmorp.de]

"; - print "

", + print "

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

"; - print ""; + print "
"; - my %ignore = map +($_ => 1), qw(_name x y); + my %ignore = map +($_ => 1), qw(name _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 "
    ($x|$y)"; + + sub print_archs { + print "
      "; + for my $a (@{$_[0]}) { + my $o = $arch->{$a->{_name}}; + my $type = $a->{type} || $o->{type}; + my $aname = escape_html $a->{_name}; + my $name = escape_html $a->{name} || $o->{name}; + + print "
    • $aname \"$name\"\n"; + for (sort keys %$a) { + next if $ignore{$_}; + my $v = escape_html $a->{$_}; + + if (($type == 66 || $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 "other_arch") { + print "$_ => $v\n"; + } elsif ($_ eq "inventory") { + print "inventory =>\n"; + print_archs ($a->{$_}); + } elsif ($_ eq "msg") { + print "

      $v

      "; + } else { + print "$_ => $v\n"; + } } + print "
    • "; } + print "
    "; } - print "
"; + + print_archs $as; + print ""; } print "

"; + my $W2 = $W + 600; + + print "


created by cfmap2html version $VERSION

", + "

"; close $fh;