… | |
… | |
15 | # |
15 | # |
16 | # You should have received a copy of the GNU General Public License |
16 | # You should have received a copy of the GNU General Public License |
17 | # along with gvpe; if not, write to the Free Software |
17 | # along with gvpe; if not, write to the Free Software |
18 | # Foundation, Inc. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
18 | # Foundation, Inc. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
19 | |
19 | |
20 | # tower of stars: missing craters? |
|
|
21 | # world_108_123 (8|18), hole below grass but shouldn't? |
|
|
22 | |
|
|
23 | our $VERSION = '1.11'; |
20 | our $VERSION = '1.21'; |
24 | |
21 | |
25 | use strict; |
22 | use strict; |
26 | |
23 | |
27 | use Storable; |
24 | use Storable; |
28 | use List::Util qw(max); |
25 | use List::Util qw(max); |
… | |
… | |
75 | |
72 | |
76 | $smooth{$1} = $2 if /^(\S+)\s+(\S+)$/; |
73 | $smooth{$1} = $2 if /^(\S+)\s+(\S+)$/; |
77 | } |
74 | } |
78 | |
75 | |
79 | Storable::nstore \%smooth, "$path.pst"; |
76 | Storable::nstore \%smooth, "$path.pst"; |
|
|
77 | utime +(stat $path)[8,9], "$path.pst"; |
80 | |
78 | |
81 | \%smooth |
79 | \%smooth |
82 | } |
80 | } |
83 | } |
81 | } |
84 | |
82 | |
… | |
… | |
152 | } |
150 | } |
153 | } |
151 | } |
154 | |
152 | |
155 | undef $parse_block; # work around bug in perl not freeing $fh etc. |
153 | undef $parse_block; # work around bug in perl not freeing $fh etc. |
156 | |
154 | |
|
|
155 | if ($cache) { |
157 | Storable::nstore \%arc, "$path.pst" |
156 | Storable::nstore \%arc, "$path.pst"; |
158 | if $cache; |
157 | utime +(stat $path)[8,9], "$path.pst"; |
|
|
158 | } |
159 | |
159 | |
160 | \%arc |
160 | \%arc |
161 | } |
161 | } |
162 | } |
162 | } |
163 | |
163 | |
… | |
… | |
223 | # first pass, gather face stacking order, border and corner info |
223 | # first pass, gather face stacking order, border and corner info |
224 | for my $x (0 .. $mapx - 1) { |
224 | for my $x (0 .. $mapx - 1) { |
225 | my $col = $map->[$x]; |
225 | my $col = $map->[$x]; |
226 | for my $y (0 .. $mapy - 1) { |
226 | for my $y (0 .. $mapy - 1) { |
227 | my $as = $col->[$y] || []; |
227 | my $as = $col->[$y] || []; |
228 | |
228 | |
|
|
229 | my $minsmooth = 0; |
|
|
230 | |
229 | for my $layer (0 .. $#$as) { |
231 | for my $layer (0 .. $#$as) { |
230 | my $a = $as->[$layer]; |
232 | my $a = $as->[$layer]; |
231 | |
233 | |
232 | my $o = $arch->{$a->{_name}} |
234 | my $o = $arch->{$a->{_name}} |
233 | or (warn "$mapname: arch '$a->{_name}' not found at ($x|$y)\n"), next; |
235 | or (warn "$mapname: arch '$a->{_name}' not found at ($x|$y)\n"), next; |
234 | |
236 | |
235 | my $smoothlevel = exists $a->{smoothlevel} ? $a->{smoothlevel} : $o->{smoothlevel}; |
237 | my $smoothlevel = exists $a->{smoothlevel} ? $a->{smoothlevel} : $o->{smoothlevel}; |
|
|
238 | |
|
|
239 | # hack to ensure somewhat correct ordering in case of conflicting |
|
|
240 | # smoothlevel/stacking order |
|
|
241 | $smoothlevel = $minsmooth + 0.01 if $minsmooth >= $smoothlevel; |
|
|
242 | $minsmooth = $smoothlevel; |
|
|
243 | |
236 | my $is_floor = exists $a->{is_floor} ? $a->{is_floor} : $o->{is_floor}; |
244 | #my $is_floor = exists $a->{is_floor} ? $a->{is_floor} : $o->{is_floor}; |
237 | my $level = $smoothlevel ? $smoothlevel |
245 | my $level = $smoothlevel + $layer * 256; |
238 | : $is_floor ? $layer - 1000 |
246 | |
239 | : $layer + 1000; |
247 | $level -= 100 * 256 if $o->{_name} eq "blocked"; |
240 | |
248 | |
241 | while ($o) { |
249 | while ($o) { |
242 | my $face = $a->{face} || $o->{face}; |
250 | my $face = $a->{face} || $o->{face}; |
243 | |
251 | |
244 | my $pb = tile $face |
252 | my $pb = tile $face |
… | |
… | |
278 | $draw_info{$smoothlevel}{$sface}{$mx - 1, $my - 1} |= 0x0400; |
286 | $draw_info{$smoothlevel}{$sface}{$mx - 1, $my - 1} |= 0x0400; |
279 | $draw_info{$smoothlevel}{$sface}{$mx + 1, $my - 1} |= 0x0800; |
287 | $draw_info{$smoothlevel}{$sface}{$mx + 1, $my - 1} |= 0x0800; |
280 | } |
288 | } |
281 | |
289 | |
282 | $o = $o->{more}; |
290 | $o = $o->{more}; |
|
|
291 | $level = ($layer + 1000) * 2; # put "big things" on top, no matter what |
283 | } |
292 | } |
284 | } |
293 | } |
285 | } |
294 | } |
286 | } |
295 | } |
287 | |
296 | |
… | |
… | |
364 | } |
373 | } |
365 | |
374 | |
366 | for my $file (@ARGV) { |
375 | for my $file (@ARGV) { |
367 | my $mapa = read_arch $file; |
376 | my $mapa = read_arch $file; |
368 | my ($pb, $meta) = cfmap_render $mapa, $file; |
377 | my ($pb, $meta) = cfmap_render $mapa, $file; |
369 | $pb->save ("$file.png~", "png"); |
378 | $pb->save ("$file.png~~", "png"); |
370 | system "convert", "$file.png~", "-filter" => "lanczos", "-geometry" => "3.125%", "-quality" => 85, "$file.jpg"; |
379 | system "convert", "$file.png~~", "-filter" => "lanczos", "-geometry" => "3.125%", "-quality" => 85, "$file.jpg"; |
371 | #system "mogrify", "-colors" => 65536, "$file.png~"; # destroys transparency |
380 | #system "mogrify", "-colors" => 65536, "$file.png~"; # destroys transparency |
372 | system "pngcrush", "-q", "-m" => 7, "-rem", "alla", "-cc", "-reduce", "$file.png~", "$file.png"; |
381 | system "pngcrush", "-q", "-m" => 7, "-rem", "alla", "-cc", "-reduce", "$file.png~~", "$file.png~"; |
373 | # system "pngnq <\Q$file.png~\E >\Q$file.png\E"; |
382 | # system "pngnq <\Q$file.png~\E >\Q$file.png\E"; |
374 | unlink "$file.png~"; |
383 | unlink "$file.png~~"; |
375 | Storable::nstore $meta, "$file.pst"; |
384 | Storable::nstore $meta, "$file.pst"; |
|
|
385 | utime +(stat $file)[8,9], "$file.pst"; |
|
|
386 | utime +(stat $file)[8,9], "$file.jpg"; |
|
|
387 | utime +(stat $file)[8,9], "$file.png~"; |
|
|
388 | rename "$file.png~", "$file.png"; |
376 | } |
389 | } |
377 | |
390 | |
378 | |
391 | |
379 | |
392 | |
380 | |
393 | |