… | |
… | |
14 | my $PNGNQ = "@PNGNQ@"; |
14 | my $PNGNQ = "@PNGNQ@"; |
15 | |
15 | |
16 | use Getopt::Long; |
16 | use Getopt::Long; |
17 | use Coro::Event; |
17 | use Coro::Event; |
18 | use AnyEvent; |
18 | use AnyEvent; |
|
|
19 | use YAML::Syck (); |
|
|
20 | use JSON::XS (); |
19 | use IO::AIO (); |
21 | use IO::AIO (); |
20 | use File::Temp; |
22 | use File::Temp; |
21 | use Crossfire; |
23 | use Crossfire; |
22 | use Coro; |
24 | use Coro; |
23 | use Coro::AIO; |
25 | use Coro::AIO; |
… | |
… | |
96 | if (!-f "$path/regions") { |
98 | if (!-f "$path/regions") { |
97 | warn "'$path' does not look like a maps directory ('regions' file is missing).\n"; |
99 | warn "'$path' does not look like a maps directory ('regions' file is missing).\n"; |
98 | exit 1 unless $FORCE; |
100 | exit 1 unless $FORCE; |
99 | } |
101 | } |
100 | |
102 | |
101 | system $RSYNC, "-a", "--chmod=u=rwX,go=rX", "$path/.", "$DATADIR/maps/.", "--delete", "--exclude", "CVS", "--delete-excluded" |
103 | system $RSYNC, "-av", "--chmod=u=rwX,go=rX", |
|
|
104 | "$path/.", "$DATADIR/maps/.", |
|
|
105 | "--exclude", "CVS", "--exclude", "/world-precomposed", |
|
|
106 | "--delete", "--delete-excluded" |
102 | and die "map installation failed.\n"; |
107 | and die "map installation failed.\n"; |
103 | |
108 | |
104 | print "maps installed successfully.\n"; |
109 | print "maps installed successfully.\n"; |
105 | } |
110 | } |
106 | |
111 | |
… | |
… | |
494 | my ($dir, $file, $type) = @$job; |
499 | my ($dir, $file, $type) = @$job; |
495 | |
500 | |
496 | my $data; |
501 | my $data; |
497 | aio_load "$dir/$file", $data; |
502 | aio_load "$dir/$file", $data; |
498 | |
503 | |
499 | |
|
|
500 | my $meta = load_cached "$dir/meta", sub { JSON::XS->new->utf8->relaxed->decode (shift) }; |
504 | my $meta = load_cached "$dir/meta", sub { JSON::XS->new->utf8->relaxed->decode (shift) }; |
501 | |
505 | |
502 | utf8::decode $dir; |
506 | utf8::decode $dir; |
503 | utf8::decode $file; |
507 | utf8::decode $file; |
504 | |
508 | |
505 | # a meta file for resources is now mandatory |
509 | # a meta file for resources is now mandatory |
506 | unless (exists $meta->{$file}) { |
510 | unless (exists $meta->{$file}) { |
507 | warn "skipping $dir/$file\n" if $VERBOSE >= 3; |
511 | warn "skipping $dir/$file\n" if $VERBOSE >= 3; |
508 | next; |
|
|
509 | } |
512 | } |
510 | |
513 | |
511 | $meta = { |
514 | $meta = { |
512 | %{ $meta->{"" } || {} }, |
515 | %{ $meta->{"" } || {} }, |
513 | %{ $meta->{$file} || {} }, |
516 | %{ $meta->{$file} || {} }, |
… | |
… | |
527 | $file =~ s/\.res$//; |
530 | $file =~ s/\.res$//; |
528 | $file =~ s/\.(ogg|wav|jpg|png)$//; |
531 | $file =~ s/\.(ogg|wav|jpg|png)$//; |
529 | |
532 | |
530 | substr $dir, 0, 1 + length $PATH, ""; |
533 | substr $dir, 0, 1 + length $PATH, ""; |
531 | |
534 | |
|
|
535 | if (my $filter = $meta->{cfutil_filter}) { |
|
|
536 | if ($filter eq "yaml2json") { |
|
|
537 | $data = JSON::XS::encode_json YAML::Syck::Load $data; |
|
|
538 | } else { |
|
|
539 | warn "$dir/$file: unknown filter $filter, skipping\n"; |
|
|
540 | } |
|
|
541 | } |
|
|
542 | |
532 | $RESOURCE{"$dir/$file"} = { |
543 | $RESOURCE{"$dir/$file"} = { |
533 | type => (delete $meta->{type}) || $type, |
544 | type => (exists $meta->{type} ? delete $meta->{type} : $type), |
534 | data => $data, |
545 | data => $data, |
535 | %$meta ? (meta => $meta) : (), |
546 | %$meta ? (meta => $meta) : (), |
536 | }; |
547 | }; |
537 | } |
548 | } |
538 | } |
549 | } |
… | |
… | |
559 | } elsif ($dir =~ /^sound(?:\/|$)/) { |
570 | } elsif ($dir =~ /^sound(?:\/|$)/) { |
560 | $c_res->put ([$path, $file, 5]) # FT_SOUND |
571 | $c_res->put ([$path, $file, 5]) # FT_SOUND |
561 | if $file =~ /\.(wav|ogg)$/; |
572 | if $file =~ /\.(wav|ogg)$/; |
562 | |
573 | |
563 | } elsif ($dir =~ /^res(?:\/|$)/) { |
574 | } elsif ($dir =~ /^res(?:\/|$)/) { |
|
|
575 | if ($file =~ /\.(jpg|png)$/) { |
564 | $c_res->put ([$path, $file, 0]) # FT_FACE |
576 | $c_res->put ([$path, $file, 0]) # FT_FACE |
565 | if $file =~ /\.(jpg|png)$/; |
577 | } elsif ($file =~ /\.(res)$/) { |
566 | $c_res->put ([$path, $file, 7]) # FT_RSRC |
578 | $c_res->put ([$path, $file, 7]) # FT_RSRC |
567 | if $file =~ /\.(res)$/; |
579 | } else { |
|
|
580 | $c_res->put ([$path, $file, undef]); |
|
|
581 | } |
568 | |
582 | |
569 | } elsif ($file =~ /\.png$/) { |
583 | } elsif ($file =~ /\.png$/) { |
570 | push @c_png, ["$path/$file", 0]; |
584 | push @c_png, ["$path/$file", 0]; |
571 | |
585 | |
572 | } elsif ($file =~ /\.trs$/) { |
586 | } elsif ($file =~ /\.trs$/) { |