… | |
… | |
12 | my $OPTIPNG = "@OPTIPNG@"; |
12 | my $OPTIPNG = "@OPTIPNG@"; |
13 | my $RSYNC = "@RSYNC@"; |
13 | my $RSYNC = "@RSYNC@"; |
14 | my $PNGNQ = "@PNGNQ@"; |
14 | my $PNGNQ = "@PNGNQ@"; |
15 | |
15 | |
16 | use Getopt::Long; |
16 | use Getopt::Long; |
|
|
17 | use File::Temp; |
|
|
18 | use POSIX (); |
|
|
19 | use Carp; |
|
|
20 | |
17 | use Coro::EV; |
21 | use Coro::EV; |
18 | use AnyEvent; |
22 | use AnyEvent; |
19 | use YAML (); |
23 | use YAML::XS (); |
20 | use JSON::XS (); |
24 | use JSON::XS (); |
21 | use IO::AIO (); |
25 | use IO::AIO (); |
22 | use File::Temp; |
26 | |
23 | use Deliantra; |
|
|
24 | use Coro; |
27 | use Coro 5.12; |
25 | use Coro::AIO; |
28 | use Coro::AIO; |
26 | use Coro::Util; |
29 | use Coro::Util; |
27 | use POSIX (); |
|
|
28 | use Carp; |
|
|
29 | use Coro::Channel; |
30 | use Coro::Channel; |
30 | use Coro::Storable; $Storable::canonical = 1; |
31 | use Coro::Storable; $Storable::canonical = 1; |
|
|
32 | |
|
|
33 | use Deliantra; |
31 | |
34 | |
32 | $SIG{QUIT} = sub { Carp::cluck "QUIT" }; |
35 | $SIG{QUIT} = sub { Carp::cluck "QUIT" }; |
33 | |
36 | |
34 | sub usage { |
37 | sub usage { |
35 | warn <<EOF; |
38 | warn <<EOF; |
… | |
… | |
273 | fork_sub { |
276 | fork_sub { |
274 | system "convert png:\Q$path\E -geometry 50% -filter lanczos $QUANTIZE -quality 00 png32:\Q$other\E~"; |
277 | system "convert png:\Q$path\E -geometry 50% -filter lanczos $QUANTIZE -quality 00 png32:\Q$other\E~"; |
275 | system $OPTIPNG, "-i0", "-q", "$other~"; |
278 | system $OPTIPNG, "-i0", "-q", "$other~"; |
276 | |
279 | |
277 | # reduce smoothfaces >10000 bytes |
280 | # reduce smoothfaces >10000 bytes |
|
|
281 | # obsolete, no longer required |
278 | if ($stem =~ /_S\./ && (-s "$other~") > 10000) { |
282 | if (0 && $stem =~ /_S\./ && (-s "$other~") > 10000) { |
279 | my $ncolor = 256; |
283 | my $ncolor = 256; |
280 | while () { |
284 | while () { |
281 | system "<\Q$other~\E $PNGNQ -s1 -n$ncolor >\Q$other~~\E"; |
285 | system "<\Q$other~\E $PNGNQ -s1 -n$ncolor >\Q$other~~\E"; |
282 | system $OPTIPNG, "-i0", "-q", "$other~~"; |
286 | system $OPTIPNG, "-i0", "-q", "$other~~"; |
283 | last if 10000 > -s "$other~~"; |
287 | last if 10000 > -s "$other~~"; |
… | |
… | |
533 | |
537 | |
534 | substr $dir, 0, 1 + length $PATH, ""; |
538 | substr $dir, 0, 1 + length $PATH, ""; |
535 | |
539 | |
536 | if (my $filter = $meta->{cfutil_filter}) { |
540 | if (my $filter = $meta->{cfutil_filter}) { |
537 | if ($filter eq "yaml2json") { |
541 | if ($filter eq "yaml2json") { |
538 | $data = JSON::XS::encode_json YAML::Load $data; |
542 | $data = JSON::XS::encode_json YAML::XS::Load $data; |
539 | } elsif ($filter eq "json2json") { |
543 | } elsif ($filter eq "json2json") { |
540 | $data = JSON::XS::encode_json JSON::XS->relaxed->utf8->decode ($data); |
544 | $data = JSON::XS::encode_json JSON::XS->relaxed->utf8->decode ($data); |
541 | } elsif ($filter eq "perl2json") { |
545 | } elsif ($filter eq "perl2json") { |
542 | $data = eval $data; die if $@; |
546 | $data = eval $data; die if $@; |
543 | $data = JSON::XS::encode_json $data; |
547 | $data = JSON::XS::encode_json $data; |
… | |
… | |
598 | } else { |
602 | } else { |
599 | warn "ignoring $path/$file\n" if $VERBOSE >= 3; |
603 | warn "ignoring $path/$file\n" if $VERBOSE >= 3; |
600 | } |
604 | } |
601 | } |
605 | } |
602 | }; |
606 | }; |
|
|
607 | } |
|
|
608 | |
|
|
609 | sub generate_plurals { |
|
|
610 | # use Lingua::EN::Inflect (); |
|
|
611 | # Lingua::EN::Inflect::classical; |
|
|
612 | # Lingua::EN::Inflect::def_noun 'talisman' => 'talismans'; |
|
|
613 | # Lingua::EN::Inflect::def_noun '(.*)boots' => '$1boots'; # hack |
|
|
614 | # |
|
|
615 | # for my $a (@ARC) { |
|
|
616 | # my $name = $a->{name} || $a->{_name}; |
|
|
617 | # |
|
|
618 | # next unless $a->{name_pl}; |
|
|
619 | # |
|
|
620 | # |
|
|
621 | # my $test = Lingua::EN::Inflect::PL_N_eq $name, Lingua::EN::Inflect::PL $name; |
|
|
622 | # my $pl = $test =~ /^(?:eq|p:.)$/ |
|
|
623 | # ? $name |
|
|
624 | # : Lingua::EN::Inflect::PL $name; |
|
|
625 | # die "$test $pl" if $pl =~ /bootss/;#d# |
|
|
626 | # |
|
|
627 | # if ($pl ne $a->{name_pl}) { |
|
|
628 | # warn "$a->{_name}: plural differs, $pl vs $a->{name_pl}\n"; |
|
|
629 | # } |
|
|
630 | # } |
603 | } |
631 | } |
604 | |
632 | |
605 | sub inst_arch($) { |
633 | sub inst_arch($) { |
606 | my (undef, $path) = @_; |
634 | my (undef, $path) = @_; |
607 | |
635 | |
… | |
… | |
630 | my @a_res = map +(async \&process_res), 1..2; |
658 | my @a_res = map +(async \&process_res), 1..2; |
631 | my @a_trs = map +(async \&process_trs), 1..2; |
659 | my @a_trs = map +(async \&process_trs), 1..2; |
632 | |
660 | |
633 | IO::AIO::flush; |
661 | IO::AIO::flush; |
634 | |
662 | |
635 | $c_res->put (undef) for @a_res; |
663 | $c_res->shutdown; |
636 | $c_arc->put (undef) for @a_arc; |
664 | $c_arc->shutdown; |
637 | $c_trs->put (undef) for @a_trs; |
665 | $c_trs->shutdown; |
638 | |
666 | |
639 | print "start file scan, arc, res processing...\n" if $VERBOSE; |
667 | print "start file scan, arc, res processing...\n" if $VERBOSE; |
640 | |
668 | |
641 | $_->join for @a_arc; # need to parse all archetypes before png processing |
669 | $_->join for @a_arc; # need to parse all archetypes before png processing |
642 | |
670 | |
… | |
… | |
687 | } |
715 | } |
688 | |
716 | |
689 | # remove base classes (by naming scheme, should use something like "baseclass xxx" to inherit |
717 | # remove base classes (by naming scheme, should use something like "baseclass xxx" to inherit |
690 | @ARC = grep $_->{_name} !~ /^(?:type|class)_/, @ARC; |
718 | @ARC = grep $_->{_name} !~ /^(?:type|class)_/, @ARC; |
691 | |
719 | |
|
|
720 | print "generating plurals...\n" if $VERBOSE; |
|
|
721 | generate_plurals; |
|
|
722 | |
692 | print "writing archetypes...\n" if $VERBOSE; |
723 | print "writing archetypes...\n" if $VERBOSE; |
693 | open my $fh, ">:utf8", "$DATADIR/archetypes~" |
724 | open my $fh, ">:utf8", "$DATADIR/archetypes~" |
694 | or die "$DATADIR/archetypes~: $!"; |
725 | or die "$DATADIR/archetypes~: $!"; |
695 | print $fh Deliantra::archlist_to_string [sort { $a->{_name} cmp $b->{_name} } @ARC]; |
726 | print $fh Deliantra::archlist_to_string [sort { $a->{_name} cmp $b->{_name} } @ARC]; |
696 | } |
727 | } |
… | |
… | |
706 | print "processing facedata...\n" if $VERBOSE; |
737 | print "processing facedata...\n" if $VERBOSE; |
707 | while (my ($k, $v) = each %FACEINFO) { |
738 | while (my ($k, $v) = each %FACEINFO) { |
708 | length $v->{data32} or warn "$k: face has no png32. this will not work (shoddy gcfclient will crash of course).\n"; |
739 | length $v->{data32} or warn "$k: face has no png32. this will not work (shoddy gcfclient will crash of course).\n"; |
709 | length $v->{data64} or warn "$k: face has no png64. this will not work very well.\n"; |
740 | length $v->{data64} or warn "$k: face has no png64. this will not work very well.\n"; |
710 | |
741 | |
711 | length $v->{data32} <= 10000 or warn "$k: face32 larger than 10000 bytes, will not work with crossfire client.\n"; |
742 | #length $v->{data32} <= 10000 or warn "$k: face32 larger than 10000 bytes, will not work with crossfire client.\n"; |
712 | #length $v->{data64} <= 10000 or warn "$k: face64 larger than 10000 bytes.\n"; |
743 | #length $v->{data64} <= 10000 or warn "$k: face64 larger than 10000 bytes.\n"; |
713 | |
744 | |
714 | if (my $magicmap = $v->{magicmap}) { |
745 | if (my $magicmap = $v->{magicmap}) { |
715 | $magicmap =~ y/A-Z_\-/a-z/d; |
746 | $magicmap =~ y/A-Z_\-/a-z/d; |
716 | $v->{magicmap} = $COLOR{$magicmap}; |
747 | $v->{magicmap} = $COLOR{$magicmap}; |