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

Comparing deliantra/server/utils/cfutil.in (file contents):
Revision 1.62 by root, Mon Sep 10 18:30:30 2007 UTC vs.
Revision 1.63 by root, Mon Dec 17 08:03:22 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
508 # a meta file for resources is now mandatory 509 # a meta file for resources is now mandatory
509 unless (exists $meta->{$file}) { 510 unless (exists $meta->{$file}) {
510 warn "skipping $dir/$file\n" if $VERBOSE >= 3; 511 warn "skipping $dir/$file\n" if $VERBOSE >= 3;
511 next;
512 } 512 }
513 513
514 $meta = { 514 $meta = {
515 %{ $meta->{"" } || {} }, 515 %{ $meta->{"" } || {} },
516 %{ $meta->{$file} || {} }, 516 %{ $meta->{$file} || {} },
530 $file =~ s/\.res$//; 530 $file =~ s/\.res$//;
531 $file =~ s/\.(ogg|wav|jpg|png)$//; 531 $file =~ s/\.(ogg|wav|jpg|png)$//;
532 532
533 substr $dir, 0, 1 + length $PATH, ""; 533 substr $dir, 0, 1 + length $PATH, "";
534 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
535 $RESOURCE{"$dir/$file"} = { 543 $RESOURCE{"$dir/$file"} = {
536 type => (delete $meta->{type}) || $type, 544 type => (exists $meta->{type} ? delete $meta->{type} : $type),
537 data => $data, 545 data => $data,
538 %$meta ? (meta => $meta) : (), 546 %$meta ? (meta => $meta) : (),
539 }; 547 };
540 } 548 }
541 } 549 }
562 } elsif ($dir =~ /^sound(?:\/|$)/) { 570 } elsif ($dir =~ /^sound(?:\/|$)/) {
563 $c_res->put ([$path, $file, 5]) # FT_SOUND 571 $c_res->put ([$path, $file, 5]) # FT_SOUND
564 if $file =~ /\.(wav|ogg)$/; 572 if $file =~ /\.(wav|ogg)$/;
565 573
566 } elsif ($dir =~ /^res(?:\/|$)/) { 574 } elsif ($dir =~ /^res(?:\/|$)/) {
575 if ($file =~ /\.(jpg|png)$/) {
567 $c_res->put ([$path, $file, 0]) # FT_FACE 576 $c_res->put ([$path, $file, 0]) # FT_FACE
568 if $file =~ /\.(jpg|png)$/; 577 } elsif ($file =~ /\.(res)$/) {
569 $c_res->put ([$path, $file, 7]) # FT_RSRC 578 $c_res->put ([$path, $file, 7]) # FT_RSRC
570 if $file =~ /\.(res)$/; 579 } else {
580 $c_res->put ([$path, $file, undef]);
581 }
571 582
572 } elsif ($file =~ /\.png$/) { 583 } elsif ($file =~ /\.png$/) {
573 push @c_png, ["$path/$file", 0]; 584 push @c_png, ["$path/$file", 0];
574 585
575 } elsif ($file =~ /\.trs$/) { 586 } elsif ($file =~ /\.trs$/) {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines