… | |
… | |
18 | use AnyEvent; |
18 | use AnyEvent; |
19 | use YAML::Syck (); |
19 | use YAML::Syck (); |
20 | use JSON::XS (); |
20 | use JSON::XS (); |
21 | use IO::AIO (); |
21 | use IO::AIO (); |
22 | use File::Temp; |
22 | use File::Temp; |
23 | use Crossfire; |
23 | use Deliantra; |
24 | use Coro; |
24 | use Coro; |
25 | use Coro::AIO; |
25 | use Coro::AIO; |
26 | use Coro::Util; |
26 | use Coro::Util; |
27 | use POSIX (); |
27 | use POSIX (); |
28 | use Carp; |
28 | use Carp; |
… | |
… | |
507 | utf8::decode $file; |
507 | utf8::decode $file; |
508 | |
508 | |
509 | # a meta file for resources is now mandatory |
509 | # a meta file for resources is now mandatory |
510 | unless (exists $meta->{$file}) { |
510 | unless (exists $meta->{$file}) { |
511 | warn "skipping $dir/$file\n" if $VERBOSE >= 3; |
511 | warn "skipping $dir/$file\n" if $VERBOSE >= 3; |
|
|
512 | next; |
512 | } |
513 | } |
513 | |
514 | |
514 | $meta = { |
515 | $meta = { |
515 | %{ $meta->{"" } || {} }, |
516 | %{ $meta->{"" } || {} }, |
516 | %{ $meta->{$file} || {} }, |
517 | %{ $meta->{$file} || {} }, |
… | |
… | |
533 | substr $dir, 0, 1 + length $PATH, ""; |
534 | substr $dir, 0, 1 + length $PATH, ""; |
534 | |
535 | |
535 | if (my $filter = $meta->{cfutil_filter}) { |
536 | if (my $filter = $meta->{cfutil_filter}) { |
536 | if ($filter eq "yaml2json") { |
537 | if ($filter eq "yaml2json") { |
537 | $data = JSON::XS::encode_json YAML::Syck::Load $data; |
538 | $data = JSON::XS::encode_json YAML::Syck::Load $data; |
|
|
539 | } elsif ($filter eq "json2json") { |
|
|
540 | $data = JSON::XS::encode_json JSON::XS->relaxed->utf8->decode ($data); |
538 | } else { |
541 | } else { |
539 | warn "$dir/$file: unknown filter $filter, skipping\n"; |
542 | warn "$dir/$file: unknown filter $filter, skipping\n"; |
540 | } |
543 | } |
541 | } |
544 | } |
542 | |
545 | |
… | |
… | |
684 | @ARC = grep $_->{_name} !~ /^(?:type|class)_/, @ARC; |
687 | @ARC = grep $_->{_name} !~ /^(?:type|class)_/, @ARC; |
685 | |
688 | |
686 | print "writing archetypes...\n" if $VERBOSE; |
689 | print "writing archetypes...\n" if $VERBOSE; |
687 | open my $fh, ">:utf8", "$DATADIR/archetypes~" |
690 | open my $fh, ">:utf8", "$DATADIR/archetypes~" |
688 | or die "$DATADIR/archetypes~: $!"; |
691 | or die "$DATADIR/archetypes~: $!"; |
689 | print $fh Crossfire::archlist_to_string [sort { $a->{_name} cmp $b->{_name} } @ARC]; |
692 | print $fh Deliantra::archlist_to_string [sort { $a->{_name} cmp $b->{_name} } @ARC]; |
690 | } |
693 | } |
691 | |
694 | |
692 | { |
695 | { |
693 | print "writing treasures...\n" if $VERBOSE; |
696 | print "writing treasures...\n" if $VERBOSE; |
694 | open my $fh, ">:utf8", "$DATADIR/treasures~" |
697 | open my $fh, ">:utf8", "$DATADIR/treasures~" |