--- cfmaps/cfmap2html 2007/10/14 01:24:15 1.31 +++ cfmaps/cfmap2html 2010/01/14 18:29:03 1.39 @@ -1,7 +1,7 @@ #!/opt/bin/perl -# cfmap2html - convert crossfire maps to html -# Copyright (C) 2005,2007 Marc Lehmann +# cfmap2html - convert deliantra maps to html +# Copyright (C) 2005,2007,2008,2009 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 @@ -17,12 +17,12 @@ # along with cfmaps; if not, write to the Free Software # Foundation, Inc. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -our $VERSION = '2.1'; +our $VERSION = '2.202'; use strict; use List::Util qw(min max); -use Crossfire 1.0; +use Deliantra; my $T = 32; @@ -42,21 +42,23 @@ || -M "$base.png" > -M "$base.map") { # regenerate png and metainfo push @cfmap2png, $path; + # force xhtml file to be remade as well + utime 1, 1, "$base.xhtml"; } } system "cfmap2png", @cfmap2png if @cfmap2png; +Deliantra::load_archetypes; + for my $path (@ARGV) { (my $base = $path) =~ s/\.map//; if (!-e "$base.xhtml" || -M "$base.xhtml" > -M "$base.map") { - Crossfire::load_archetypes - unless %ARCH; - - my $meta = read_arch "$base.map"; + my $meta = eval { read_arch "$base.map" } + or next; my $arch = $meta->{arch}; open my $fh, ">:utf8", "$base.xhtml" @@ -111,7 +113,7 @@ print "$path[-1]", "", - "

[more about cfmaps.schmorp.de]

", + "

[more about maps.deliantra.net]

", "", "$tile[0]", "$tile[3]", @@ -126,10 +128,18 @@ escape_html delete $info->{msg}, "

"; - print "

", + if (open my $fh, "<", "$base.png.err") { + local $/; + print "

", + (escape_html scalar <$fh>), + "

"; + } + + print "
", (map "", grep !/^_/, keys %$info), - "
" . (escape_html $_) . "" . (escape_html $info->{$_}) . "

"; + "", + "

"; print ""; @@ -142,7 +152,10 @@ if (my $as = $map[$x][$y]) { my @class; - push @class, "fishy" if grep $_->{invisible} || $_->{face} || exists $_->{no_pass} || exists $_->{no_pick}, @$as; + push @class, "fishy" if grep exists $_->{invisible} || exists $_->{face} + || exists $_->{move_block} || exists $_->{move_allow} + || exists $_->{no_pick} || exists $_->{tag} + , @$as push @class, "exit" if grep $is_exit{$ARCH{$_->{_name}}{type}} && $_->{slaying}, @$as; push @class, "dialog" if grep $_->{msg} =~ /^\@match/m, @$as; @@ -157,7 +170,7 @@ sub print_archs { print "
    "; - for my $a (@{$_[0]}) { + for my $a (reverse @{$_[0]}) { my $o = $ARCH{$a->{_name}}; my $type = $a->{type} || $o->{type}; my $aname = escape_html $a->{_name}; @@ -172,7 +185,11 @@ $a->{msg} =~ /^final_map\s*(\S+)\s*$/m, $v = $1 if $v eq "/!"; # random map - print "slaying => $v\n"; + if ($v =~ s/^\*//) { + print "slaying => *$v\n"; + } else { + print "slaying => $v\n"; + } } elsif ($_ eq "other_arch") { print "$_ => $v\n"; } elsif ($_ eq "inventory") {