ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/cf.schmorp.de/server/utils/cfutil.in
(Generate patch)

Comparing cf.schmorp.de/server/utils/cfutil.in (file contents):
Revision 1.62 by root, Mon Sep 10 18:30:30 2007 UTC vs.
Revision 1.64 by root, Mon Dec 17 08:50:15 2007 UTC

14my $PNGNQ = "@PNGNQ@"; 14my $PNGNQ = "@PNGNQ@";
15 15
16use Getopt::Long; 16use Getopt::Long;
17use Coro::Event; 17use Coro::Event;
18use AnyEvent; 18use AnyEvent;
19use YAML::Syck ();
20use JSON::XS ();
19use IO::AIO (); 21use IO::AIO ();
20use File::Temp; 22use File::Temp;
21use Crossfire; 23use Crossfire;
22use Coro; 24use Coro;
23use Coro::AIO; 25use Coro::AIO;
497 my ($dir, $file, $type) = @$job; 499 my ($dir, $file, $type) = @$job;
498 500
499 my $data; 501 my $data;
500 aio_load "$dir/$file", $data; 502 aio_load "$dir/$file", $data;
501 503
502
503 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) };
504 505
505 utf8::decode $dir; 506 utf8::decode $dir;
506 utf8::decode $file; 507 utf8::decode $file;
507 508
530 $file =~ s/\.res$//; 531 $file =~ s/\.res$//;
531 $file =~ s/\.(ogg|wav|jpg|png)$//; 532 $file =~ s/\.(ogg|wav|jpg|png)$//;
532 533
533 substr $dir, 0, 1 + length $PATH, ""; 534 substr $dir, 0, 1 + length $PATH, "";
534 535
536 if (my $filter = $meta->{cfutil_filter}) {
537 if ($filter eq "yaml2json") {
538 $data = JSON::XS::encode_json YAML::Syck::Load $data;
539 } else {
540 warn "$dir/$file: unknown filter $filter, skipping\n";
541 }
542 }
543
535 $RESOURCE{"$dir/$file"} = { 544 $RESOURCE{"$dir/$file"} = {
536 type => (delete $meta->{type}) || $type, 545 type => (exists $meta->{type} ? delete $meta->{type} : $type),
537 data => $data, 546 data => $data,
538 %$meta ? (meta => $meta) : (), 547 %$meta ? (meta => $meta) : (),
539 }; 548 };
540 } 549 }
541 } 550 }
562 } elsif ($dir =~ /^sound(?:\/|$)/) { 571 } elsif ($dir =~ /^sound(?:\/|$)/) {
563 $c_res->put ([$path, $file, 5]) # FT_SOUND 572 $c_res->put ([$path, $file, 5]) # FT_SOUND
564 if $file =~ /\.(wav|ogg)$/; 573 if $file =~ /\.(wav|ogg)$/;
565 574
566 } elsif ($dir =~ /^res(?:\/|$)/) { 575 } elsif ($dir =~ /^res(?:\/|$)/) {
576 if ($file =~ /\.(jpg|png)$/) {
567 $c_res->put ([$path, $file, 0]) # FT_FACE 577 $c_res->put ([$path, $file, 0]) # FT_FACE
568 if $file =~ /\.(jpg|png)$/; 578 } elsif ($file =~ /\.(res)$/) {
569 $c_res->put ([$path, $file, 7]) # FT_RSRC 579 $c_res->put ([$path, $file, 7]) # FT_RSRC
570 if $file =~ /\.(res)$/; 580 } else {
581 $c_res->put ([$path, $file, undef]);
582 }
571 583
572 } elsif ($file =~ /\.png$/) { 584 } elsif ($file =~ /\.png$/) {
573 push @c_png, ["$path/$file", 0]; 585 push @c_png, ["$path/$file", 0];
574 586
575 } elsif ($file =~ /\.trs$/) { 587 } elsif ($file =~ /\.trs$/) {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines