--- deliantra/server/utils/cfutil.in 2007/09/10 18:30:30 1.62 +++ deliantra/server/utils/cfutil.in 2007/12/17 08:03:22 1.63 @@ -16,6 +16,8 @@ use Getopt::Long; use Coro::Event; use AnyEvent; +use YAML::Syck (); +use JSON::XS (); use IO::AIO (); use File::Temp; use Crossfire; @@ -499,7 +501,6 @@ my $data; aio_load "$dir/$file", $data; - my $meta = load_cached "$dir/meta", sub { JSON::XS->new->utf8->relaxed->decode (shift) }; utf8::decode $dir; @@ -508,7 +509,6 @@ # a meta file for resources is now mandatory unless (exists $meta->{$file}) { warn "skipping $dir/$file\n" if $VERBOSE >= 3; - next; } $meta = { @@ -532,8 +532,16 @@ substr $dir, 0, 1 + length $PATH, ""; + if (my $filter = $meta->{cfutil_filter}) { + if ($filter eq "yaml2json") { + $data = JSON::XS::encode_json YAML::Syck::Load $data; + } else { + warn "$dir/$file: unknown filter $filter, skipping\n"; + } + } + $RESOURCE{"$dir/$file"} = { - type => (delete $meta->{type}) || $type, + type => (exists $meta->{type} ? delete $meta->{type} : $type), data => $data, %$meta ? (meta => $meta) : (), }; @@ -564,10 +572,13 @@ if $file =~ /\.(wav|ogg)$/; } elsif ($dir =~ /^res(?:\/|$)/) { - $c_res->put ([$path, $file, 0]) # FT_FACE - if $file =~ /\.(jpg|png)$/; - $c_res->put ([$path, $file, 7]) # FT_RSRC - if $file =~ /\.(res)$/; + if ($file =~ /\.(jpg|png)$/) { + $c_res->put ([$path, $file, 0]) # FT_FACE + } elsif ($file =~ /\.(res)$/) { + $c_res->put ([$path, $file, 7]) # FT_RSRC + } else { + $c_res->put ([$path, $file, undef]); + } } elsif ($file =~ /\.png$/) { push @c_png, ["$path/$file", 0];