ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/cfmaps/cfmap2png
(Generate patch)

Comparing cfmaps/cfmap2png (file contents):
Revision 1.12 by root, Tue Nov 22 06:46:43 2005 UTC vs.
Revision 1.18 by root, Mon Dec 12 01:41:50 2005 UTC

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
23our $VERSION = '1.11'; 20our $VERSION = '1.21';
24 21
25use strict; 22use strict;
26 23
27use Storable; 24use Storable;
28use List::Util qw(max); 25use 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
300 my ($x, $y) = split $;, $xy; 309 my ($x, $y) = split $;, $xy;
301 310
302 next if $x < 0 || $x >= $mapx 311 next if $x < 0 || $x >= $mapx
303 || $y < 0 || $y >= $mapy; 312 || $y < 0 || $y >= $mapy;
304 313
305 # bits is 00XX XXXX YYYY YYFX cccc CCCC BBBB 314 # bits is xxxx xxxx yyyy yyyy __fn cccc CCCC bbbb
306 # X don't draw
307 # F full tile draw with x|y bigface displacement 315 # f full tile draw with x|y bigface displacement
308 # c maybe draw these corners
309 # C do not draw these corners 316 # n do not draw borders&corners
317 # c draw these corners, but...
318 # C ... not these
310 # b draw these borders 319 # b draw these borders
311 320
312 if ($bits & 0x2000) { 321 if ($bits & 0x2000) {
313 my $dx = (($bits >> 24) & 0xff) - 128; 322 my $dx = (($bits >> 24) & 0xff) - 128;
314 my $dy = (($bits >> 16) & 0xff) - 128; 323 my $dy = (($bits >> 16) & 0xff) - 128;
364} 373}
365 374
366for my $file (@ARGV) { 375for 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~";
382# system "pngnq <\Q$file.png~\E >\Q$file.png\E";
373 unlink "$file.png~"; 383 unlink "$file.png~~";
374 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";
375} 389}
376 390
377 391
378 392
379 393

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines