--- cfmaps/cfmap2png 2005/11/22 06:46:43 1.12 +++ cfmaps/cfmap2png 2005/12/12 01:37:11 1.16 @@ -18,9 +18,8 @@ # Foundation, Inc. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA # tower of stars: missing craters? -# world_108_123 (8|18), hole below grass but shouldn't? -our $VERSION = '1.11'; +our $VERSION = '1.2'; use strict; @@ -77,6 +76,7 @@ } Storable::nstore \%smooth, "$path.pst"; + utime +(stat $path)[8,9], "$path.pst"; \%smooth } @@ -154,8 +154,10 @@ undef $parse_block; # work around bug in perl not freeing $fh etc. - Storable::nstore \%arc, "$path.pst" - if $cache; + if ($cache) { + Storable::nstore \%arc, "$path.pst"; + utime +(stat $path)[8,9], "$path.pst"; + } \%arc } @@ -225,7 +227,9 @@ my $col = $map->[$x]; for my $y (0 .. $mapy - 1) { my $as = $col->[$y] || []; - + + my $minsmooth = 0; + for my $layer (0 .. $#$as) { my $a = $as->[$layer]; @@ -233,10 +237,16 @@ or (warn "$mapname: arch '$a->{_name}' not found at ($x|$y)\n"), next; my $smoothlevel = exists $a->{smoothlevel} ? $a->{smoothlevel} : $o->{smoothlevel}; - my $is_floor = exists $a->{is_floor} ? $a->{is_floor} : $o->{is_floor}; - my $level = $smoothlevel ? $smoothlevel - : $is_floor ? $layer - 1000 - : $layer + 1000; + + # hack to ensure somewhat correct ordering in case of conflicting + # smoothlevel/stacking order + $smoothlevel = $minsmooth + 0.01 if $minsmooth >= $smoothlevel; + $minsmooth = $smoothlevel; + + #my $is_floor = exists $a->{is_floor} ? $a->{is_floor} : $o->{is_floor}; + my $level = $smoothlevel + $layer * 256; + + $level -= 100 * 256 if $o->{_name} eq "blocked"; while ($o) { my $face = $a->{face} || $o->{face}; @@ -280,6 +290,7 @@ } $o = $o->{more}; + $level = ($layer + 1000) * 2; # put "big things" on top, no matter what } } } @@ -302,11 +313,11 @@ next if $x < 0 || $x >= $mapx || $y < 0 || $y >= $mapy; - # bits is 00XX XXXX YYYY YYFX cccc CCCC BBBB - # X don't draw - # F full tile draw with x|y bigface displacement - # c maybe draw these corners - # C do not draw these corners + # bits is xxxx xxxx yyyy yyyy __fn cccc CCCC bbbb + # f full tile draw with x|y bigface displacement + # n do not draw borders&corners + # c draw these corners, but... + # C ... not these # b draw these borders if ($bits & 0x2000) { @@ -366,12 +377,16 @@ for my $file (@ARGV) { my $mapa = read_arch $file; my ($pb, $meta) = cfmap_render $mapa, $file; - $pb->save ("$file.png~", "png"); - system "convert", "$file.png~", "-filter" => "lanczos", "-geometry" => "3.125%", "-quality" => 85, "$file.jpg"; + $pb->save ("$file.png~~", "png"); + system "convert", "$file.png~~", "-filter" => "lanczos", "-geometry" => "3.125%", "-quality" => 85, "$file.jpg"; #system "mogrify", "-colors" => 65536, "$file.png~"; # destroys transparency - system "pngcrush", "-q", "-m" => 7, "-rem", "alla", "-cc", "-reduce", "$file.png~", "$file.png"; - unlink "$file.png~"; + system "pngcrush", "-q", "-m" => 7, "-rem", "alla", "-cc", "-reduce", "$file.png~~", "$file.png~"; +# system "pngnq <\Q$file.png~\E >\Q$file.png\E"; + unlink "$file.png~~"; Storable::nstore $meta, "$file.pst"; + utime +(stat $file)[8,9], "$file.pst"; + utime +(stat $file)[8,9], "$file.png~"; + rename "$file.png~", "$file.png"; }