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