… | |
… | |
21 | use Crossfire; |
21 | use Crossfire; |
22 | use Coro; |
22 | use Coro; |
23 | use Coro::AIO; |
23 | use Coro::AIO; |
24 | use Coro::Util; |
24 | use Coro::Util; |
25 | use POSIX (); |
25 | use POSIX (); |
26 | use Digest::MD5; |
|
|
27 | use Carp; |
26 | use Carp; |
28 | use Coro::Channel; |
27 | use Coro::Channel; |
29 | use Coro::Storable; $Storable::canonical = 1; |
28 | use Coro::Storable; $Storable::canonical = 1; |
30 | |
29 | |
31 | $SIG{QUIT} = sub { Carp::cluck "QUIT" }; |
30 | $SIG{QUIT} = sub { Carp::cluck "QUIT" }; |
… | |
… | |
174 | |
173 | |
175 | (my $base = $stem) =~ s/^.*\///; |
174 | (my $base = $stem) =~ s/^.*\///; |
176 | |
175 | |
177 | my $fi = $FACEINFO{$base}; |
176 | my $fi = $FACEINFO{$base}; |
178 | unless ($fi) { |
177 | unless ($fi) { |
179 | warn "$path: <$base> not referenced by any archetype, skipping.\n"; |
178 | #warn "$path: <$base> not referenced by any archetype, skipping.\n"; |
180 | next; |
179 | #next; |
181 | } |
180 | } |
182 | |
181 | |
183 | my $arc = $FACEINFO{$base}{arc} |
182 | my $arc = $fi->{arc} || { }; |
184 | or die "FATAL: internal error, cannot continue"; |
|
|
185 | |
183 | |
186 | unless ($path =~ /~$/) { |
184 | unless ($path =~ /~$/) { |
187 | # possibly enlarge |
185 | # possibly enlarge |
188 | if (0 > aio_stat "$stem.64x64.png") { |
186 | if (0 > aio_stat "$stem.64x64.png") { |
189 | my $other = "$stem.64x64.png~"; |
187 | my $other = "$stem.64x64.png~"; |
… | |
… | |
426 | facings => $facings, |
424 | facings => $facings, |
427 | frames => \@frames, |
425 | frames => \@frames, |
428 | }; |
426 | }; |
429 | } |
427 | } |
430 | |
428 | |
431 | for my $face ($o->{face} || (), @{$anim || []}) { |
429 | for ($o->{face} || (), @{$anim || []}) { |
432 | next if $face =~ /^facings\s|^blank.x11$|^empty.x11$/; |
430 | next if /^facings\s/; |
433 | |
431 | |
|
|
432 | my $face = $_; |
|
|
433 | $face =~ s/\+\d+\+\d+$//; # remove tile offset coordinates |
|
|
434 | |
434 | my $info = $FACEINFO{$face} ||= {}; |
435 | my $info = $FACEINFO{$face} ||= { }; |
435 | |
|
|
436 | $info->{arc} = $o; |
436 | $info->{arc} = $o; |
|
|
437 | |
|
|
438 | next if $face =~ /^blank.x11$|^empty.x11$/; |
|
|
439 | |
437 | $info->{visibility} = $visibility if defined $visibility; |
440 | $info->{visibility} = $visibility if defined $visibility; |
438 | $info->{magicmap} = $magicmap if defined $magicmap; |
441 | $info->{magicmap} = $magicmap if defined $magicmap; |
439 | } |
442 | } |
440 | |
443 | |
441 | if (my $smooth = delete $o->{smoothface}) { |
444 | if (my $smooth = delete $o->{smoothface}) { |
… | |
… | |
491 | my ($dir, $file, $type) = @$job; |
494 | my ($dir, $file, $type) = @$job; |
492 | |
495 | |
493 | my $data; |
496 | my $data; |
494 | aio_load "$dir/$file", $data; |
497 | aio_load "$dir/$file", $data; |
495 | |
498 | |
|
|
499 | |
496 | my $meta = load_cached "$dir/meta", sub { JSON::XS::from_json shift }; |
500 | my $meta = load_cached "$dir/meta", sub { JSON::XS->new->utf8->relaxed->decode (shift) }; |
497 | |
501 | |
498 | next if $meta && !exists $meta->{$file}; |
502 | utf8::decode $dir; |
|
|
503 | utf8::decode $file; |
|
|
504 | |
|
|
505 | # a meta file for resources is now mandatory |
|
|
506 | unless (exists $meta->{$file}) { |
|
|
507 | warn "skipping $dir/$file\n" if $VERBOSE >= 3; |
|
|
508 | next; |
|
|
509 | } |
499 | |
510 | |
500 | $meta = { |
511 | $meta = { |
501 | %{ $meta->{"" } || {} }, |
512 | %{ $meta->{"" } || {} }, |
502 | %{ $meta->{$file} || {} }, |
513 | %{ $meta->{$file} || {} }, |
503 | }; |
514 | }; |
… | |
… | |
519 | substr $dir, 0, 1 + length $PATH, ""; |
530 | substr $dir, 0, 1 + length $PATH, ""; |
520 | |
531 | |
521 | $RESOURCE{"$dir/$file"} = { |
532 | $RESOURCE{"$dir/$file"} = { |
522 | type => (delete $meta->{type}) || $type, |
533 | type => (delete $meta->{type}) || $type, |
523 | data => $data, |
534 | data => $data, |
524 | chksum => (Digest::MD5::md5 $data), |
|
|
525 | %$meta ? (meta => $meta) : (), |
535 | %$meta ? (meta => $meta) : (), |
526 | }; |
536 | }; |
527 | } |
537 | } |
528 | } |
538 | } |
529 | |
539 | |
… | |
… | |
679 | length $v->{data64} or warn "$k: face has no png64. this will not work very well.\n"; |
689 | length $v->{data64} or warn "$k: face has no png64. this will not work very well.\n"; |
680 | |
690 | |
681 | length $v->{data32} <= 10000 or warn "$k: face32 larger than 10000 bytes, will not work with crossfire client.\n"; |
691 | length $v->{data32} <= 10000 or warn "$k: face32 larger than 10000 bytes, will not work with crossfire client.\n"; |
682 | #length $v->{data64} <= 10000 or warn "$k: face64 larger than 10000 bytes.\n"; |
692 | #length $v->{data64} <= 10000 or warn "$k: face64 larger than 10000 bytes.\n"; |
683 | |
693 | |
684 | $v->{chksum32} = Digest::MD5::md5 $v->{data32}; |
|
|
685 | $v->{chksum64} = Digest::MD5::md5 $v->{data64}; |
|
|
686 | |
|
|
687 | if (my $magicmap = $v->{magicmap}) { |
694 | if (my $magicmap = $v->{magicmap}) { |
688 | $magicmap =~ y/A-Z_\-/a-z/d; |
695 | $magicmap =~ y/A-Z_\-/a-z/d; |
689 | $v->{magicmap} = $COLOR{$magicmap}; |
696 | $v->{magicmap} = $COLOR{$magicmap}; |
690 | } |
697 | } |
691 | |
698 | |