… | |
… | |
43 | my $CACHE = 0; |
43 | my $CACHE = 0; |
44 | my $FORCE; |
44 | my $FORCE; |
45 | my $TMPDIR = "/tmp/cfutil$$~"; |
45 | my $TMPDIR = "/tmp/cfutil$$~"; |
46 | my $TMPFILE = "aaaa0"; |
46 | my $TMPFILE = "aaaa0"; |
47 | |
47 | |
|
|
48 | our %COLOR = ( |
|
|
49 | black => 0, |
|
|
50 | white => 1, |
|
|
51 | navy => 2, |
|
|
52 | red => 3, |
|
|
53 | orange => 4, |
|
|
54 | blue => 5, |
|
|
55 | darkorange => 6, |
|
|
56 | green => 7, |
|
|
57 | lightgreen => 8, |
|
|
58 | grey => 9, |
|
|
59 | brown => 10, |
|
|
60 | gold => 11, |
|
|
61 | tan => 12, |
|
|
62 | ); |
|
|
63 | |
48 | END { system "rm", "-rf", $TMPDIR } |
64 | END { system "rm", "-rf", $TMPDIR } |
49 | |
65 | |
50 | Event->signal (signal => "INT", cb => sub { exit 1 }); |
66 | Event->signal (signal => "INT", cb => sub { exit 1 }); |
51 | Event->signal (signal => "TERM", cb => sub { exit 1 }); |
67 | Event->signal (signal => "TERM", cb => sub { exit 1 }); |
52 | |
68 | |
… | |
… | |
177 | |
193 | |
178 | # reduce smoothfaces >10000 bytes |
194 | # reduce smoothfaces >10000 bytes |
179 | if ($stem =~ /_S\./ && (-s "$other~") > 10000) { |
195 | if ($stem =~ /_S\./ && (-s "$other~") > 10000) { |
180 | my $ncolor = 256; |
196 | my $ncolor = 256; |
181 | while () { |
197 | while () { |
182 | system "<\Q$other~\E $PNGNQ -n$ncolor >\Q$other~~\E"; |
198 | system "<\Q$other~\E $PNGNQ -s1 -n$ncolor >\Q$other~~\E"; |
183 | system $OPTIPNG, "-i0", "-q", "$other~~"; |
199 | system $OPTIPNG, "-i0", "-q", "$other~~"; |
184 | last if 10000 > -s "$other~~"; |
200 | last if 10000 > -s "$other~~"; |
185 | $ncolor = int $ncolor * 0.9; |
201 | $ncolor = int $ncolor * 0.9; |
186 | $ncolor > 8 or die "cannot reduce filesize to < 10000 bytes"; |
202 | $ncolor > 8 or die "cannot reduce filesize to < 10000 bytes"; |
187 | } |
203 | } |
… | |
… | |
301 | |
317 | |
302 | my $ext = $x|$y ? "+$x+$y" : ""; |
318 | my $ext = $x|$y ? "+$x+$y" : ""; |
303 | |
319 | |
304 | $o->{face} .= $ext unless /^blank.x11$|^empty.x11$/ || !$o->{face}; |
320 | $o->{face} .= $ext unless /^blank.x11$|^empty.x11$/ || !$o->{face}; |
305 | |
321 | |
306 | my $visibility = delete $o->{visibility} if exists $o->{visibility}; |
322 | $visibility = delete $o->{visibility} if exists $o->{visibility}; |
307 | my $magicmap = delete $o->{magicmap} if exists $o->{magicmap}; |
323 | $magicmap = delete $o->{magicmap} if exists $o->{magicmap}; |
308 | |
324 | |
309 | my $anim = delete $o->{anim}; |
325 | my $anim = delete $o->{anim}; |
310 | |
326 | |
311 | if ($anim) { |
327 | if ($anim) { |
312 | # possibly add $ext to the animation name to avoid |
328 | # possibly add $ext to the animation name to avoid |
… | |
… | |
386 | } elsif ($file =~ /\.trs$/) { |
402 | } elsif ($file =~ /\.trs$/) { |
387 | push @trs, [$path, $file]; |
403 | push @trs, [$path, $file]; |
388 | } elsif ($file =~ /\.arc$/) { |
404 | } elsif ($file =~ /\.arc$/) { |
389 | push @arc, [$path, $file]; |
405 | push @arc, [$path, $file]; |
390 | } else { |
406 | } else { |
391 | warn "ignoring $path/$file\n" if $VERBOSE >= 2; |
407 | warn "ignoring $path/$file\n" if $VERBOSE >= 3; |
392 | } |
408 | } |
393 | } |
409 | } |
394 | }; |
410 | }; |
395 | } |
411 | } |
396 | |
412 | |
… | |
… | |
457 | |
473 | |
458 | last; |
474 | last; |
459 | } |
475 | } |
460 | } |
476 | } |
461 | |
477 | |
|
|
478 | # remove base classes (by naming scheme, should use something like "baseclass xxx" to inherit |
|
|
479 | @ARC = grep $_->{_name} !~ /^(?:type|class)_/, @ARC; |
|
|
480 | |
462 | open my $fh, ">:utf8", "$DATADIR/archetypes~" |
481 | open my $fh, ">:utf8", "$DATADIR/archetypes~" |
463 | or die "$DATADIR/archetypes~: $!"; |
482 | or die "$DATADIR/archetypes~: $!"; |
464 | print $fh Crossfire::archlist_to_string [sort { $a->{_name} cmp $b->{_name} } @ARC]; |
483 | print $fh Crossfire::archlist_to_string [sort { $a->{_name} cmp $b->{_name} } @ARC]; |
465 | } |
484 | } |
466 | |
485 | |
… | |
… | |
478 | length $v->{data32} <= 10000 or warn "$k: face32 larger than 10000 bytes, will not work with crossfire client.\n"; |
497 | length $v->{data32} <= 10000 or warn "$k: face32 larger than 10000 bytes, will not work with crossfire client.\n"; |
479 | #length $v->{data64} <= 10000 or warn "$k: face64 larger than 10000 bytes.\n"; |
498 | #length $v->{data64} <= 10000 or warn "$k: face64 larger than 10000 bytes.\n"; |
480 | |
499 | |
481 | $v->{chksum32} = Digest::MD5::md5 $v->{data32}; |
500 | $v->{chksum32} = Digest::MD5::md5 $v->{data32}; |
482 | $v->{chksum64} = Digest::MD5::md5 $v->{data64}; |
501 | $v->{chksum64} = Digest::MD5::md5 $v->{data64}; |
|
|
502 | |
|
|
503 | if (my $magicmap = $v->{magicmap}) { |
|
|
504 | $magicmap =~ y/A-Z_\-/a-z/d; |
|
|
505 | $v->{magicmap} = $COLOR{$magicmap}; |
|
|
506 | } |
483 | } |
507 | } |
484 | |
508 | |
485 | open my $fh, ">:perlio", "$DATADIR/facedata~" |
509 | open my $fh, ">:perlio", "$DATADIR/facedata~" |
486 | or die "$DATADIR/facedata~: $!"; |
510 | or die "$DATADIR/facedata~: $!"; |
487 | |
511 | |